Compare commits

..

6 Commits

Author SHA1 Message Date
tteckster 5826ee33b3
Update nginxproxymanager.sh
lock script version to 2.9.22
2023-03-31 20:04:57 -04:00
tteckster d8ed7b5060
Update nginxproxymanager-install.sh
lock script to version 2.9.22
2023-03-31 20:02:47 -04:00
tteckster 1f17d282a6
Update nginxproxymanager.sh 2023-03-31 18:04:25 -04:00
tteckster daa1720d85
Update nginxproxymanager-install.sh 2023-03-31 18:02:24 -04:00
tteckster 324a485930
Update CHANGELOG.MD 2023-03-31 17:30:53 -04:00
tteckster 59bfc8d3e3
Update haos-vm.sh
Include a choice within the "Advanced" settings to configure the disk cache.
2023-03-31 17:26:56 -04:00
4 changed files with 199 additions and 157 deletions

View File

@ -2,6 +2,13 @@
# Change Log
All notable changes to this project will be documented in this file.
## 2023-03-31
### Changed
- **Home Assistant OS VM**
- Include a choice within the "Advanced" settings to configure the disk cache.
## 2023-03-27
### Changed

View File

@ -1,104 +1,100 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
# Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
clear
cat <<"EOF"
_ __ _ ____ __ ___
/ | / /___ _(_)___ _ __ / __ \_________ __ ____ __ / |/ /___ _____ ____ _____ ____ _____
/ |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/
/ /| / /_/ / / / / /> < / ____/ / / /_/ /> </ /_/ / / / / / /_/ / / / / /_/ / /_/ / __/ /
/_/ |_/\__, /_/_/ /_/_/|_| /_/ /_/ \____/_/|_|\__, / /_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/
/____/ /____/ /____/
EOF
}
header_info
echo -e "Loading..."
APP="Nginx Proxy Manager"
var_disk="4"
var_cpu="1"
var_ram="1024"
var_os="debian"
var_version="11"
variables
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
function default_settings() {
CT_TYPE="1"
PW=""
CT_ID=$NEXTID
HN=$NSAPP
DISK_SIZE="$var_disk"
CORE_COUNT="$var_cpu"
RAM_SIZE="$var_ram"
BRG="vmbr0"
NET=dhcp
GATE=""
DISABLEIP6="no"
MTU=""
SD=""
NS=""
MAC=""
VLAN=""
SSH="no"
VERB="no"
echo_default
}
msg_info "Installing Dependencies"
$STD apt-get update
$STD apt-get -y install \
sudo \
mc \
curl \
gnupg \
make \
g++ \
gcc \
ca-certificates \
apache2-utils \
logrotate \
build-essential \
python3-dev \
git \
lsb-release
msg_ok "Installed Dependencies"
function update_script() {
header_info
if [[ ! -f /lib/systemd/system/npm.service ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest |
msg_info "Installing Python"
$STD apt-get install -y -q --no-install-recommends python3 python3-pip python3-venv
$STD pip3 install --upgrade setuptools
$STD pip3 install --upgrade pip
$STD python3 -m venv /opt/certbot/
if [ "$(getconf LONG_BIT)" = "32" ]; then
$STD python3 -m pip install --no-cache-dir -U cryptography==3.3.2
fi
$STD python3 -m pip install --no-cache-dir cffi certbot
msg_ok "Installed Python"
msg_info "Installing Openresty"
$STD apt-key add <(curl -fsSL https://openresty.org/package/pubkey.gpg)
sh -c 'echo "deb http://openresty.org/package/debian $(lsb_release -cs) openresty" > /etc/apt/sources.list.d/openresty.list'
$STD apt-get -y update
$STD apt-get -y install --no-install-recommends openresty
msg_ok "Installed Openresty"
msg_info "Setting up Node.js Repository"
$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
msg_ok "Set up Node.js Repository"
msg_info "Installing Node.js"
$STD apt-get install -y nodejs
msg_ok "Installed Node.js"
msg_info "Installing Yarn"
$STD npm install --global yarn
msg_ok "Installed Yarn"
RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest |
grep "tag_name" |
awk '{print substr($2, 3, length($2)-4) }')
msg_info "Stopping Services"
systemctl stop openresty
systemctl stop npm
msg_ok "Stopped Services"
msg_info "Cleaning Old Files"
rm -rf /app \
/var/www/html \
/etc/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/cache/nginx &>/dev/null
msg_ok "Cleaned Old Files"
msg_info "Downloading Nginx Proxy Manager v2.9.22"
wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.9.22 -O - | tar -xz
cd ./nginx-proxy-manager-2.9.22
msg_ok "Downloaded Nginx Proxy Manager v2.9.22"
msg_info "Downloading NPM v${RELEASE}"
wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz &>/dev/null
cd nginx-proxy-manager-${RELEASE}
msg_ok "Downloaded NPM v${RELEASE}"
msg_info "Setting up Enviroment"
ln -sf /usr/bin/python3 /usr/bin/python
ln -sf /usr/bin/certbot /opt/certbot/bin/certbot
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
ln -sf /usr/local/openresty/nginx/ /etc/nginx
msg_info "Setting up Enviroment"
ln -sf /usr/bin/python3 /usr/bin/python
ln -sf /usr/bin/certbot /opt/certbot/bin/certbot
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
ln -sf /usr/local/openresty/nginx/ /etc/nginx
sed -i "s+0.0.0+${RELEASE}+g" backend/package.json
sed -i "s+0.0.0+${RELEASE}+g" frontend/package.json
sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")
for NGINX_CONF in $NGINX_CONFS; do
sed -i "s+0.0.0+2.9.22+g" backend/package.json
sed -i "s+0.0.0+2.9.22+g" frontend/package.json
sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")
for NGINX_CONF in $NGINX_CONFS; do
sed -i 's+include conf.d+include /etc/nginx/conf.d+g' "$NGINX_CONF"
done
mkdir -p /var/www/html /etc/nginx/logs
cp -r docker/rootfs/var/www/html/* /var/www/html/
cp -r docker/rootfs/etc/nginx/* /etc/nginx/
cp docker/rootfs/etc/letsencrypt.ini /etc/letsencrypt.ini
cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-proxy-manager
ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf
rm -f /etc/nginx/conf.d/dev.conf
mkdir -p /tmp/nginx/body \
done
mkdir -p /var/www/html /etc/nginx/logs
cp -r docker/rootfs/var/www/html/* /var/www/html/
cp -r docker/rootfs/etc/nginx/* /etc/nginx/
cp docker/rootfs/etc/letsencrypt.ini /etc/letsencrypt.ini
cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-proxy-manager
ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf
rm -f /etc/nginx/conf.d/dev.conf
mkdir -p /tmp/nginx/body \
/run/nginx \
/data/nginx \
/data/custom_ssl \
@ -114,30 +110,34 @@ function update_script() {
/var/lib/nginx/cache/public \
/var/lib/nginx/cache/private \
/var/cache/nginx/proxy_temp
chmod -R 777 /var/cache/nginx
chown root /tmp/nginx
echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf
if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then
echo -e "${CHECKMARK} \e[1;92m Generating dummy SSL Certificate... \e[0m"
chmod -R 777 /var/cache/nginx
chown root /tmp/nginx
echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf
if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then
echo -en "${GN} Generating dummy SSL Certificate... "
openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/O=Nginx Proxy Manager/OU=Dummy Certificate/CN=localhost" -keyout /data/nginx/dummykey.pem -out /data/nginx/dummycert.pem &>/dev/null
fi
mkdir -p /app/global /app/frontend/images
cp -r backend/* /app
cp -r global/* /app/global
msg_ok "Setup Enviroment"
fi
msg_info "Building Frontend"
cd ./frontend
export NODE_ENV=development
yarn install --network-timeout=30000 &>/dev/null
yarn build &>/dev/null
cp -r dist/* /app/frontend
cp -r app-images/* /app/frontend/images
msg_ok "Built Frontend"
mkdir -p /app/global /app/frontend/images
cp -r backend/* /app
cp -r global/* /app/global
msg_ok "Set up Enviroment"
msg_info "Initializing Backend"
rm -rf /app/config/default.json &>/dev/null
if [ ! -f /app/config/production.json ]; then
msg_info "Building Frontend"
cd ./frontend
export NODE_ENV=development
$STD yarn install --network-timeout=30000
$STD yarn build
cp -r dist/* /app/frontend
cp -r app-images/* /app/frontend/images
msg_ok "Built Frontend"
msg_info "Initializing Backend"
rm -rf /app/config/default.json
if [ ! -f /app/config/production.json ]; then
cat <<'EOF' >/app/config/production.json
{
"database": {
@ -151,31 +151,42 @@ function update_script() {
}
}
EOF
fi
cd /app
export NODE_ENV=development
yarn install --network-timeout=30000 &>/dev/null
msg_ok "Initialized Backend"
fi
cd /app
export NODE_ENV=development
$STD yarn install --network-timeout=30000
msg_ok "Initialized Backend"
msg_info "Starting Services"
sed -i -e 's/^pid/#pid/' -e 's/^user/#user/' /usr/local/openresty/nginx/conf/nginx.conf
systemctl enable npm &>/dev/null
systemctl start openresty
systemctl start npm
msg_ok "Started Services"
msg_info "Creating Service"
cat <<'EOF' >/lib/systemd/system/npm.service
[Unit]
Description=Nginx Proxy Manager
After=network.target
Wants=openresty.service
msg_info "Cleaning up"
rm -rf ~/nginx-proxy-manager-*
msg_ok "Cleaned"
[Service]
Type=simple
Environment=NODE_ENV=production
ExecStartPre=-mkdir -p /tmp/nginx/body /data/letsencrypt-acme-challenge
ExecStart=/usr/bin/node index.js --abort_on_uncaught_exception --max_old_space_size=250
WorkingDirectory=/app
Restart=on-failure
msg_ok "Update Successfull"
exit
}
[Install]
WantedBy=multi-user.target
EOF
msg_ok "Created Service"
start
build_container
description
motd_ssh
root
msg_ok "Completed Successfully!\n"
echo -e "${APP} should be reachable by going to the following URL.
${BL}http://${IP}:81${CL} \n"
msg_info "Starting Services"
$STD systemctl enable --now openresty
$STD systemctl enable --now npm
msg_ok "Started Services"
msg_info "Cleaning up"
rm -rf ../nginx-proxy-manager-*
$STD apt-get autoremove
$STD apt-get autoclean
msg_ok "Cleaned"

View File

@ -66,10 +66,10 @@ RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-man
grep "tag_name" |
awk '{print substr($2, 3, length($2)-4) }')
msg_info "Downloading Nginx Proxy Manager v${RELEASE}"
wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz
cd ./nginx-proxy-manager-${RELEASE}
msg_ok "Downloaded Nginx Proxy Manager v${RELEASE}"
msg_info "Downloading Nginx Proxy Manager v2.9.22"
wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.9.22 -O - | tar -xz
cd ./nginx-proxy-manager-2.9.22
msg_ok "Downloaded Nginx Proxy Manager v2.9.22"
msg_info "Setting up Enviroment"
ln -sf /usr/bin/python3 /usr/bin/python
@ -77,8 +77,8 @@ ln -sf /usr/bin/certbot /opt/certbot/bin/certbot
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
ln -sf /usr/local/openresty/nginx/ /etc/nginx
sed -i "s+0.0.0+${RELEASE}+g" backend/package.json
sed -i "s+0.0.0+${RELEASE}+g" frontend/package.json
sed -i "s+0.0.0+2.9.22+g" backend/package.json
sed -i "s+0.0.0+2.9.22+g" frontend/package.json
sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")
@ -181,7 +181,6 @@ motd_ssh
root
msg_info "Starting Services"
sed -i -e 's/^pid/#pid/' -e 's/^user/#user/' /usr/local/openresty/nginx/conf/nginx.conf
$STD systemctl enable --now openresty
$STD systemctl enable --now npm
msg_ok "Started Services"

View File

@ -112,6 +112,7 @@ function default_settings() {
VMID="$NEXTID"
FORMAT=",efitype=4m"
MACHINE=""
DISK_CACHE=""
HN="haos$stable"
CORE_COUNT="2"
RAM_SIZE="4096"
@ -123,6 +124,7 @@ function default_settings() {
echo -e "${DGN}Using HAOS Version: ${BGN}${BRANCH}${CL}"
echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
echo -e "${DGN}Using Disk Cache: ${BGN}Default${CL}"
echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}"
echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}"
echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}"
@ -141,6 +143,7 @@ function advanced_settings() {
3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi
while true; do
VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
@ -173,6 +176,20 @@ function advanced_settings() {
FORMAT=",efitype=4m"
MACHINE=""
fi
DISK_CACHE1=$(whiptail --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \
"0" "Default" ON \
"1" "Write Through" OFF \
3>&1 1>&2 2>&3)
exitstatus=$?
if [ $DISK_CACHE1 = "1" ]; then
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
DISK_CACHE="cache=writethrough,"
else
echo -e "${DGN}Using Disk Cache: ${BGN}Default${CL}"
DISK_CACHE=""
fi
VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $VM_NAME ]; then
@ -184,6 +201,7 @@ function advanced_settings() {
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
@ -192,6 +210,7 @@ function advanced_settings() {
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi
fi
RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
@ -200,6 +219,7 @@ function advanced_settings() {
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi
fi
BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $BRG ]; then
@ -208,6 +228,7 @@ function advanced_settings() {
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $MAC1 ]; then
@ -219,6 +240,7 @@ function advanced_settings() {
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi
fi
VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
@ -230,6 +252,7 @@ function advanced_settings() {
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
@ -241,6 +264,7 @@ function advanced_settings() {
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
fi
fi
if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
START_VM="yes"
@ -248,6 +272,7 @@ function advanced_settings() {
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
START_VM="no"
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}"
else
@ -342,7 +367,7 @@ pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
qm set $VMID \
-efidisk0 ${DISK0_REF}${FORMAT} \
-scsi0 ${DISK1_REF},${THIN}size=32G \
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=32G \
-boot order=scsi0 \
-description "# Home Assistant OS
### https://github.com/tteck/Proxmox