pull/1312/head
nicedevil007 2 years ago
commit c49b6a7396
  1. 2
      .github/CONTRIBUTING.md
  2. 31
      CHANGELOG.MD
  3. 4
      README.md
  4. 88
      ct/alpine-esphome.sh
  5. 2
      ct/jellyfin.sh
  6. 12
      ct/nginxproxymanager.sh
  7. 6
      install/blocky-install.sh
  8. 2
      install/grafana-install.sh
  9. 1
      install/heimdalldashboard-install.sh
  10. 7
      install/homepage-install.sh
  11. 47
      install/jellyfin-install.sh
  12. 12
      install/nginxproxymanager-install.sh
  13. 6
      misc/build.func
  14. 236
      vm/haos-vm.sh

@ -2,4 +2,4 @@
Everybody is invited and welcome to contribute to Proxmox Helper Scripts. Everybody is invited and welcome to contribute to Proxmox Helper Scripts.
- Pull requests are always created against the [**pull-requests**](https://github.com/tteck/Proxmox/tree/pull-requests) branch. - Pull requests submitted against [**main**](https://github.com/tteck/Proxmox/tree/main) are meticulously scrutinized, so please do not take it personally if I reject your request. If you follow the patterns that have been established throughout the codebase, you greatly increase the likelihood that your changes will get merged into [**main**](https://github.com/tteck/Proxmox/tree/main) :partying_face:!

@ -2,6 +2,37 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## 2023-04-05
### Changed
- **Jellyfin LXC**
- Set Ubuntu 22.04 as default
- Use the Deb822 format jellyfin.sources configuration (jellyfin.list configuration has been obsoleted)
## 2023-04-02
### Changed
- **Home Assistant OS VM**
- Include a choice within the "Advanced" settings to configure the CPU model between kvm64 (default) or host.
## 2023-03-31
### Changed
- **Home Assistant OS VM**
- Include a choice within the "Advanced" settings to configure the disk cache between none (default) or Write Through.
## 2023-03-27
### Changed
- **Removed Alpine-ESPHome LXC**
- Nonoperational
- **All Scripts**
- Incorporate code that examines whether SSH is being used and, if yes, offers a suggestion against it without restricting or blocking its usage.
## 2023-03-25 ## 2023-03-25
### Changed ### Changed

@ -1,4 +1,6 @@
<sub>These script's allows for the creation of a Linux container or virtual machine in an interactive manner, with options for both basic and advanced configurations. The basic setup uses default settings, while the advanced setup provides additional options such as container type, root password, hostname, disk size, core count, RAM size, network settings, and others. The options are presented in a dialog box format using the whiptail command and the script collects and validates the user's input to generate the final configuration of the container or virtual machine.</sub> <h3><p align="center"><a href="https://github.com/tteck/Proxmox/blob/main/.github/CONTRIBUTING.md">Contributing to Proxmox Helper Scripts</a></p></h3>
<sub>These script's allows for the creation of a Linux container or virtual machine in an interactive manner, with options for both basic and advanced configurations. The basic setup uses default settings, while the advanced setup offers the possibility to modify the default settings. The options are presented in a dialog box format using the whiptail command and the script collects and validates the user's input to generate the final configuration of the container or virtual machine.</sub>
<h1><p align="center"><a href="https://tteck.github.io/Proxmox/">Proxmox Helper Scripts</a></p></h1> <h1><p align="center"><a href="https://tteck.github.io/Proxmox/">Proxmox Helper Scripts</a></p></h1>
<sub><div align="center"> Be cautious and thoroughly evaluate scripts and automation tasks obtained from external sources.</div></sub> <sub><div align="center"> Be cautious and thoroughly evaluate scripts and automation tasks obtained from external sources.</div></sub>

@ -1,88 +0,0 @@
#!/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"
___________ ____ __ __
/ ____/ ___// __ \/ / / /___ ____ ___ ___
/ __/ \__ \/ /_/ / /_/ / __ \/ __ `__ \/ _ \
/ /___ ___/ / ____/ __ / /_/ / / / / / / __/
/_____//____/_/ /_/ /_/\____/_/ /_/ /_/\___/
Alpine
EOF
}
header_info
echo -e "Loading..."
APP="Alpine-ESPHome"
var_disk="2"
var_cpu="1"
var_ram="512"
var_os="alpine"
var_version="3.17"
variables
color
catch_errors
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
}
function update_script() {
if [[ ! -f /usr/bin/esphome ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
while true; do
CHOICE=$(
whiptail --title "SUPPORT" --menu "Select option" 11 58 1 \
"1" "Check for ESPHome Updates" 3>&2 2>&1 1>&3
)
exit_status=$?
if [ $exit_status == 1 ]; then
clear
exit-script
fi
header_info
case $CHOICE in
1)
msg_info "Updating ESPHome"
pip3 install esphome --upgrade &>/dev/null
rc-service -q esphome restart
msg_ok "Updated Successfully!"
exit
;;
esac
done
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${APP} should be reachable by going to the following URL.
${BL}http://${IP}:6052${CL} \n"

@ -24,7 +24,7 @@ var_disk="8"
var_cpu="2" var_cpu="2"
var_ram="2048" var_ram="2048"
var_os="ubuntu" var_os="ubuntu"
var_version="20.04" var_version="22.04"
variables variables
color color
catch_errors catch_errors

@ -74,18 +74,18 @@ function update_script() {
/var/cache/nginx &>/dev/null /var/cache/nginx &>/dev/null
msg_ok "Cleaned Old Files" msg_ok "Cleaned Old Files"
msg_info "Downloading NPM v${RELEASE}" msg_info "Downloading NPM v2.9.22"
wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz &>/dev/null wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.9.22 -O - | tar -xz &>/dev/null
cd nginx-proxy-manager-${RELEASE} cd nginx-proxy-manager-2.9.22
msg_ok "Downloaded NPM v${RELEASE}" msg_ok "Downloaded NPM v2.9.22"
msg_info "Setting up Enviroment" msg_info "Setting up Enviroment"
ln -sf /usr/bin/python3 /usr/bin/python ln -sf /usr/bin/python3 /usr/bin/python
ln -sf /usr/bin/certbot /opt/certbot/bin/certbot 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/sbin/nginx /usr/sbin/nginx
ln -sf /usr/local/openresty/nginx/ /etc/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+2.9.22+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" frontend/package.json
sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf") NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")
for NGINX_CONF in $NGINX_CONFS; do for NGINX_CONF in $NGINX_CONFS; do

@ -23,10 +23,10 @@ msg_info "Installing Blocky"
systemctl stop systemd-resolved systemctl stop systemd-resolved
$STD systemctl disable systemd-resolved.service $STD systemctl disable systemd-resolved.service
RELEASE=$(curl -s https://api.github.com/repos/0xERR0R/blocky/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') RELEASE=$(curl -s https://api.github.com/repos/0xERR0R/blocky/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q https://github.com/0xERR0R/blocky/releases/download/v$RELEASE/blocky_${RELEASE}_Linux_x86_64.tar.gz wget -q https://github.com/0xERR0R/blocky/releases/download/v$RELEASE/blocky_v${RELEASE}_Linux_x86_64.tar.gz
mkdir -p /opt/blocky mkdir -p /opt/blocky
tar -xf blocky_${RELEASE}_Linux_x86_64.tar.gz -C /opt/blocky tar -xf blocky_v${RELEASE}_Linux_x86_64.tar.gz -C /opt/blocky
rm -rf blocky_${RELEASE}_Linux_x86_64.tar.gz rm -rf blocky_v${RELEASE}_Linux_x86_64.tar.gz
cat <<EOF >/opt/blocky/config.yml cat <<EOF >/opt/blocky/config.yml
upstream: upstream:
# these external DNS resolvers will be used. Blocky picks 2 random resolvers from the list for each query # these external DNS resolvers will be used. Blocky picks 2 random resolvers from the list for each query

@ -30,6 +30,8 @@ msg_ok "Set up Grafana Repository"
msg_info "Installing Grafana" msg_info "Installing Grafana"
$STD apt-get update $STD apt-get update
$STD apt-get install -y grafana $STD apt-get install -y grafana
systemctl start grafana-server
systemctl enable --now -q grafana-server.service
msg_ok "Installed Grafana" msg_ok "Installed Grafana"
motd_ssh motd_ssh

@ -23,6 +23,7 @@ msg_info "Installing PHP"
$STD apt-get install -y php $STD apt-get install -y php
$STD apt-get install -y php-sqlite3 $STD apt-get install -y php-sqlite3
$STD apt-get install -y php-zip $STD apt-get install -y php-zip
$STD apt-get install -y php-xml
msg_ok "Installed PHP" msg_ok "Installed PHP"
RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]')

@ -30,7 +30,12 @@ $STD npm install -g pnpm
msg_ok "Installed Node.js" msg_ok "Installed Node.js"
msg_info "Installing Homepage (Patience)" msg_info "Installing Homepage (Patience)"
$STD git clone https://github.com/benphelps/homepage.git /opt/homepage RELEASE=$(curl -s https://api.github.com/repos/benphelps/homepage/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q https://github.com/benphelps/homepage/archive/refs/tags/v${RELEASE}.tar.gz
$STD tar -xvf v${RELEASE}.tar.gz
mkdir -p /opt/homepage
cp -r homepage-${RELEASE}/* /opt/homepage
rm -rf v${RELEASE}.tar.gz homepage-${RELEASE}
cd /opt/homepage cd /opt/homepage
mkdir -p config mkdir -p config
cp /opt/homepage/src/skeleton/* /opt/homepage/config cp /opt/homepage/src/skeleton/* /opt/homepage/config

@ -16,9 +16,8 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y curl $STD apt-get install -y curl
$STD apt-get install -y sudo $STD apt-get install -y sudo
$STD apt-get install -y gnupg
$STD apt-get install -y mc $STD apt-get install -y mc
$STD apt-get install -y apt-transport-https
$STD apt-get install -y software-properties-common
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then
@ -37,36 +36,28 @@ if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then
msg_ok "Set Up Hardware Acceleration" msg_ok "Set Up Hardware Acceleration"
fi fi
msg_info "Setting Up Jellyfin Repository"
$STD add-apt-repository universe -y
$STD apt-key add <(curl -fsSL https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key)
sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/ubuntu $(lsb_release -c -s) main" > /etc/apt/sources.list.d/jellyfin.list'
msg_ok "Set Up Jellyfin Repository"
msg_info "Installing Jellyfin" msg_info "Installing Jellyfin"
VERSION="$( awk -F'=' '/^UBUNTU_CODENAME=/{ print $NF }' /etc/os-release )"
# If the keyring directory is absent, create it
if [[ ! -d /etc/apt/keyrings ]]; then
mkdir -p /etc/apt/keyrings
fi
# Download the repository signing key and install it to the keyring directory
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | gpg --dearmor --yes --output /etc/apt/keyrings/jellyfin.gpg
# Install the Deb822 format jellyfin.sources entry
cat <<EOF >/etc/apt/sources.list.d/jellyfin.sources
Types: deb
URIs: https://repo.jellyfin.org/${PCT_OSTYPE}
Suites: ${VERSION}
Components: main
Architectures: amd64
Signed-By: /etc/apt/keyrings/jellyfin.gpg
EOF
# Install Jellyfin using the metapackage (which will fetch jellyfin-server, jellyfin-web, and jellyfin-ffmpeg5)
$STD apt-get update $STD apt-get update
$STD apt install jellyfin-server -y $STD apt-get install -y jellyfin
$STD apt install jellyfin-ffmpeg5 -y
msg_ok "Installed Jellyfin" msg_ok "Installed Jellyfin"
msg_info "Creating Service"
cat <<'EOF' >/lib/systemd/system/jellyfin.service
[Unit]
Description = Jellyfin Media Server
After = network.target
[Service]
Type = simple
EnvironmentFile = /etc/default/jellyfin
User = root
ExecStart = /usr/bin/jellyfin
Restart = on-failure
TimeoutSec = 15
[Install]
WantedBy = multi-user.target
EOF
ln -s /usr/share/jellyfin/web/ /usr/lib/jellyfin/bin/jellyfin-web
msg_ok "Created Service"
motd_ssh motd_ssh
root root

@ -66,10 +66,10 @@ RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-man
grep "tag_name" | grep "tag_name" |
awk '{print substr($2, 3, length($2)-4) }') awk '{print substr($2, 3, length($2)-4) }')
msg_info "Downloading 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/v$RELEASE -O - | tar -xz wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.9.22 -O - | tar -xz
cd ./nginx-proxy-manager-$RELEASE cd ./nginx-proxy-manager-2.9.22
msg_ok "Downloaded Nginx Proxy Manager v$RELEASE" msg_ok "Downloaded Nginx Proxy Manager v2.9.22"
msg_info "Setting up Enviroment" msg_info "Setting up Enviroment"
ln -sf /usr/bin/python3 /usr/bin/python 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/sbin/nginx /usr/sbin/nginx
ln -sf /usr/local/openresty/nginx/ /etc/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+2.9.22+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" frontend/package.json
sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf") NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")

@ -67,10 +67,11 @@ arch_check() {
ssh_check() { ssh_check() {
if command -v pveversion >/dev/null 2>&1; then if command -v pveversion >/dev/null 2>&1; then
if [ -n "$SSH_CLIENT" ]; then if [ -n "${SSH_CLIENT:+x}" ]; then
if whiptail --defaultno --title "SSH DETECTED" --yesno "The scripts suggest using the Proxmox shell instead of SSH, since the latter can create issues while gathering variables. Would you like to proceed with using SSH?" 10 68; then if whiptail --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
echo "you've been warned" echo "you've been warned"
else else
clear
exit exit
fi fi
fi fi
@ -341,6 +342,7 @@ advanced_settings() {
} }
install_script() { install_script() {
ssh_check
arch_check arch_check
pve_check pve_check
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)

@ -48,16 +48,19 @@ function error_handler() {
echo -e "\n$error_message\n" echo -e "\n$error_message\n"
cleanup_vmid cleanup_vmid
} }
function cleanup_vmid() { function cleanup_vmid() {
if qm status $VMID &>/dev/null; then if qm status $VMID &>/dev/null; then
qm stop $VMID &>/dev/null qm stop $VMID &>/dev/null
qm destroy $VMID &>/dev/null qm destroy $VMID &>/dev/null
fi fi
} }
function cleanup() { function cleanup() {
popd >/dev/null popd >/dev/null
rm -rf $TEMP_DIR rm -rf $TEMP_DIR
} }
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
if whiptail --title "HOME ASSISTANT OS VM" --yesno "This will create a New Home Assistant OS VM. Proceed?" 10 58; then if whiptail --title "HOME ASSISTANT OS VM" --yesno "This will create a New Home Assistant OS VM. Proceed?" 10 58; then
@ -70,15 +73,18 @@ function msg_info() {
local msg="$1" local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..." echo -ne " ${HOLD} ${YW}${msg}..."
} }
function msg_ok() { function msg_ok() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}" echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
} }
function msg_error() { function msg_error() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
function PVE_CHECK() {
function pve_check() {
if [ $(pveversion | grep -c "pve-manager/7\.[2-9]") -eq 0 ]; then if [ $(pveversion | grep -c "pve-manager/7\.[2-9]") -eq 0 ]; then
echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported"
echo -e "Requires PVE Version 7.2 or higher" echo -e "Requires PVE Version 7.2 or higher"
@ -87,7 +93,8 @@ function PVE_CHECK() {
exit exit
fi fi
} }
function ARCH_CHECK() {
function arch_check() {
if [ "$(dpkg --print-architecture)" != "amd64" ]; then if [ "$(dpkg --print-architecture)" != "amd64" ]; then
echo -e "\n ${CROSS} This script will not work with PiMox! \n" echo -e "\n ${CROSS} This script will not work with PiMox! \n"
echo -e "Exiting..." echo -e "Exiting..."
@ -95,12 +102,34 @@ function ARCH_CHECK() {
exit exit
fi fi
} }
function ssh_check() {
if command -v pveversion >/dev/null 2>&1; then
if [ -n "${SSH_CLIENT:+x}" ]; then
if whiptail --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
echo "you've been warned"
else
clear
exit
fi
fi
fi
}
function exit-script() {
clear
echo -e "⚠ User exited script \n"
exit
}
function default_settings() { function default_settings() {
BRANCH="$stable" BRANCH="$stable"
VMID="$NEXTID" VMID="$NEXTID"
FORMAT=",efitype=4m" FORMAT=",efitype=4m"
MACHINE="" MACHINE=""
DISK_CACHE=""
HN="haos$stable" HN="haos$stable"
CPU_TYPE=""
CORE_COUNT="2" CORE_COUNT="2"
RAM_SIZE="4096" RAM_SIZE="4096"
BRG="vmbr0" BRG="vmbr0"
@ -111,7 +140,9 @@ function default_settings() {
echo -e "${DGN}Using HAOS Version: ${BGN}${BRANCH}${CL}" echo -e "${DGN}Using HAOS Version: ${BGN}${BRANCH}${CL}"
echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
echo -e "${DGN}Using Machine Type: ${BGN}i440fx${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}Using Hostname: ${BGN}${HN}${CL}"
echo -e "${DGN}Using CPU Model: ${BGN}Default${CL}"
echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}"
echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}"
echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}"
@ -121,114 +152,168 @@ function default_settings() {
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
echo -e "${BL}Creating a HAOS VM using the above default settings${CL}" echo -e "${BL}Creating a HAOS VM using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \ if BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
"$stable" "Stable " ON \ "$stable" "Stable " ON \
"$beta" "Beta " OFF \ "$beta" "Beta " OFF \
"$dev" "Dev " OFF \ "$dev" "Dev " OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3); then
exitstatus=$? echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi else
exit-script
fi
while true; do 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) if VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
exitstatus=$? if [ -z "$VMID" ]; then
if [ -z "$VMID" ]; then VMID="$NEXTID"
VMID="$NEXTID" echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"
echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" break
break else
else if pct status "$VMID" &>/dev/null || qm status "$VMID" &>/dev/null; then
if pct status "$VMID" &>/dev/null || qm status "$VMID" &>/dev/null; then echo -e "${CROSS}${RD} ID $VMID is already in use${CL}"
echo -e "${CROSS}${RD} ID $VMID is already in use${CL}" sleep 2
sleep 2 continue
continue fi
echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"
break
fi fi
echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" else
break exit-script
fi fi
done done
MACH=$(whiptail --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \ if MACH=$(whiptail --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \
"i440fx" "Machine i440fx" ON \ "i440fx" "Machine i440fx" ON \
"q35" "Machine q35" OFF \ "q35" "Machine q35" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3); then
exitstatus=$? if [ $MACH = q35 ]; then
if [ $MACH = q35 ]; then echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" FORMAT=""
FORMAT="" MACHINE=" -machine q35"
MACHINE=" -machine q35" else
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
FORMAT=",efitype=4m"
MACHINE=""
fi
else else
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" exit-script
FORMAT=",efitype=4m"
MACHINE=""
fi 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 DISK_CACHE1=$(whiptail --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \
if [ -z $VM_NAME ]; then "0" "Default" ON \
HN="haos${BRANCH}" "1" "Write Through" OFF \
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" 3>&1 1>&2 2>&3); then
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
else else
if [ $exitstatus = 0 ]; then exit-script
fi
if VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z $VM_NAME ]; then
HN="haos${BRANCH}"
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
else
HN=$(echo ${VM_NAME,,} | tr -d ' ') HN=$(echo ${VM_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi fi
else
exit-script
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 CPU_TYPE1=$(whiptail --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \
if [ -z $CORE_COUNT ]; then "0" "KVM64 (Default)" ON \
CORE_COUNT="2" "1" "Host" OFF \
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" 3>&1 1>&2 2>&3); then
if [ $CPU_TYPE1 = "1" ]; then
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
CPU_TYPE=" -cpu host"
else
echo -e "${DGN}Using CPU Model: ${BGN}Default${CL}"
CPU_TYPE=""
fi
else else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi exit-script
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 CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z $RAM_SIZE ]; then if [ -z $CORE_COUNT ]; then
RAM_SIZE="4096" CORE_COUNT="2"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
else
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
fi
else else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi exit-script
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 RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z $BRG ]; then if [ -z $RAM_SIZE ]; then
BRG="vmbr0" RAM_SIZE="4096"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
else
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
fi
else else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi exit-script
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 BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z $MAC1 ]; then if [ -z $BRG ]; then
MAC="$GEN_MAC" BRG="vmbr0"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
fi
else else
if [ $exitstatus = 0 ]; then exit-script
fi
if MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z $MAC1 ]; then
MAC="$GEN_MAC"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
else
MAC="$MAC1" MAC="$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
else
exit-script
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 VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ $exitstatus = 0 ]; then
if [ -z $VLAN1 ]; then if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN="" VLAN1="Default"
VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else else
VLAN=",tag=$VLAN1" VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi fi
else
exit-script
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 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); then
if [ $exitstatus = 0 ]; then
if [ -z $MTU1 ]; then if [ -z $MTU1 ]; then
MTU1="Default" MTU="" MTU1="Default"
MTU=""
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
else else
MTU=",mtu=$MTU1" MTU=",mtu=$MTU1"
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
fi fi
else
exit-script
fi fi
if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
START_VM="yes" START_VM="yes"
@ -236,6 +321,7 @@ function advanced_settings() {
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
START_VM="no" START_VM="no"
fi fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then 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}" echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}"
else else
@ -244,7 +330,8 @@ function advanced_settings() {
advanced_settings advanced_settings
fi fi
} }
function START_SCRIPT() {
function start_script() {
if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
header_info header_info
echo -e "${BL}Using Default Settings${CL}" echo -e "${BL}Using Default Settings${CL}"
@ -255,9 +342,12 @@ function START_SCRIPT() {
advanced_settings advanced_settings
fi fi
} }
ARCH_CHECK
PVE_CHECK arch_check
START_SCRIPT pve_check
ssh_check
start_script
msg_info "Validating Storage" msg_info "Validating Storage"
while read -r line; do while read -r line; do
TAG=$(echo $line | awk '{print $1}') TAG=$(echo $line | awk '{print $1}')
@ -323,13 +413,13 @@ for i in {0,1}; do
done done
msg_ok "Extracted KVM Disk Image" msg_ok "Extracted KVM Disk Image"
msg_info "Creating HAOS VM" msg_info "Creating HAOS VM"
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE \ qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
-name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
qm set $VMID \ qm set $VMID \
-efidisk0 ${DISK0_REF}${FORMAT} \ -efidisk0 ${DISK0_REF}${FORMAT} \
-scsi0 ${DISK1_REF},${THIN}size=32G \ -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=32G \
-boot order=scsi0 \ -boot order=scsi0 \
-description "# Home Assistant OS -description "# Home Assistant OS
### https://github.com/tteck/Proxmox ### https://github.com/tteck/Proxmox

Loading…
Cancel
Save