Maintenance (#681)

* Maintenance
This commit is contained in:
tteckster 2022-10-29 21:04:45 -04:00 committed by GitHub
parent e7ec3d0275
commit 8e331fcbff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
155 changed files with 12962 additions and 11552 deletions

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${GN} echo -e "${GN}
___ __ __ ___ __ __
/ | ____/ /___ ___ ______ __________/ / / | ____/ /___ ___ ______ __________/ /
/ /| |/ __ / __ / / / / __ / ___/ __ / / /| |/ __ / __ / / / / __ / ___/ __ /
@ -53,168 +53,192 @@ echo -e "${GN}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
____ __ __ ____ __ __
/ __ )/ /___v4_____/ /____ __ / __ )/ /___v4_____/ /____ __
/ __ / / __ \/ ___/ //_/ / / / / __ / / __ \/ ___/ //_/ / / /
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
______ ____ _____ ______ ____ _____
/ ____/___ __v4______ _/ __ \/ ___/ / ____/___ __v4______ _/ __ \/ ___/
/ / / __ `/ ___/ __ `/ / / /\__ \ / / / __ `/ ___/ __ `/ / / /\__ \
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
EOF EOF

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ _____ ____ _____
/ __ \____ ____ ____ ___ ____ ____ / ___/__ ______ _____ / __ \____ ____ ____ ___ ____ ____ / ___/__ ______ _____
/ / / / __ / _ \/ __ __ \/ __ \/ __ \ \__ \/ / / / __ \/ ___/ / / / / __ / _ \/ __ __ \/ __ \/ __ \ \__ \/ / / / __ \/ ___/
@ -53,168 +53,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
____ __ ____ __
/ __ \____ ______/ /_ __ __ / __ \____ ______/ /_ __ __
/ / / / __ / ___/ __ \/ / / / / / / / __ / ___/ __ \/ / / /
@ -53,168 +53,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
__ __________ _ _______ __ __________ _ _______
____/ /v4 / ____/ __ \/ | / /__ / ____/ /v4 / ____/ __ \/ | / /__ /
/ __ / _ \/ / / / / / |/ / / / / __ / _ \/ / / / / / |/ / / /
@ -52,169 +52,193 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ __ ____ __
/ __ \____ _____/ /_v4__ _____ / __ \____ _____/ /_v4__ _____
/ / / / __ \/ ___/ //_/ _ \/ ___/ / / / / __ \/ ___/ //_/ _ \/ ___/
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -232,7 +256,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
EOF EOF

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${DGN} echo -e "${DGN}
______ __ ______ __
/ ____/___ v4_ / /_ __ __ / ____/___ v4_ / /_ __ __
/ __/ / __ __ \/ __ \/ / / / / __/ / __ __ \/ __ \/ / / /
@ -53,176 +53,200 @@ echo -e "${DGN}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \ var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \
"18.04" "Bionic" OFF \ "18.04" "Bionic" OFF \
"20.04" "Focal" ON \ "20.04" "Focal" ON \
"21.10" "Impish" OFF \ "21.10" "Impish" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" OFF \ "1" "Unprivileged" OFF \
"0" "Privileged" ON \ "0" "Privileged" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -241,7 +265,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: c 226:0 rwm lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm lxc.cgroup2.devices.allow: c 29:0 rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
________ _______v4 _ __ ________ _______v4 _ __
/ ____/ |/ / __ \ | |/ / / ____/ |/ / __ \ | |/ /
/ __/ / /|_/ / / / / | / / __/ / /|_/ / / / / | /
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${CL} echo -e "${CL}
___________ ____ __ ______ __ _________ ___________ ____ __ ______ __ _________
/ ____/ ___// __ \/ / / / __ \/ |/ / ____/ / ____/ ___// __ \/ / / / __ \/ |/ / ____/
/ __/ \__ \/ /_/ / /_/ / / / / /|_/ / __/ / __/ \__ \/ /_/ / /_/ / / / / /|_/ / __/
@ -52,168 +52,192 @@ echo -e "${CL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
______ ____ ______ ____
/ ____/________ _/ __/___ _____ ____ _ / ____/________ _/ __/___ _____ ____ _
/ / __/ ___/ __ / /_/ __ / __ \/ __ / / / __/ ___/ __ / /_/ __ / __ \/ __ /
@ -52,168 +52,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ __________ _______ __ ____ __________ _______ __
/ __ / ___/ __ \/ ___/ / / / / __ / ___/ __ \/ ___/ / / /
/ /_/ / / / /_/ / /__/ /_/ / / /_/ / / / /_/ / /__/ /_/ /
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ __ _ __ ____ ____ __ __ __ __ __ _ __ ____ ____ __ __ __
/ / / /__ (_)___ ___ ____/ /_v4 _/ / / / __ \____ ______/ /_ / /_ ____ ____ __________/ / / / / /__ (_)___ ___ ____/ /_v4 _/ / / / __ \____ ______/ /_ / /_ ____ ____ __________/ /
/ /_/ / _ \/ / __ __ \/ __ / __ / / / / / / / __ / ___/ __ \/ __ \/ __ \/ __ / ___/ __ / / /_/ / _ \/ / __ __ \/ __ / __ / / / / / / / __ / ___/ __ \/ __ \/ __ \/ __ / ___/ __ /
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ ___ _ __ __ ______ __ __ ___ _ __ __ ______
/ / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___v4________ / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___v4________
/ /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,8 +257,8 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
if [ "$CT_TYPE" == "0" ]; then if [ "$CT_TYPE" == "0" ]; then
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ __ ___ _ __ __ __ __ ___ _ __ __
/ / / /___ ____ ___ ___ v4 / | __________(_)____/ /_____ _____ / /_ / / / /___ ____ ___ ___ v4 / | __________(_)____/ /_____ _____ / /_
/ /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/ / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
if [ "$CT_TYPE" == "0" ]; then if [ "$CT_TYPE" == "0" ]; then
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm
@ -244,7 +268,7 @@ lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=
lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file
EOF EOF
else else
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
EOF EOF

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
__ ______ __ _____________ ____ ________ ____________ __ ______ __ _____________ ____ ________ ____________
/ / / / __ \/ |/ / ____/ __ )/ __ \/ _/ __ \/ ____/ ____/ / / / / __ \/ |/ / ____/ __ )/ __ \/ _/ __ \/ ____/ ____/
/ /_/ / / / / /|_/ / __/ / __ / /_/ // // / / / / __/ __/ / /_/ / / / / /|_/ / __/ / __ / /_/ // // / / / / __/ __/
@ -52,168 +52,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ __ __
/ / / /___ ____ ___ ___ ____ ____ _____ ____ / / / /___ ____ ___ ___ ____ ____ _____ ____
/ /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \ / /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
____ ______ ____ ____ ____ ______ ____ ____
/ _/_v4 / __/ /_ ___ __/ __ \/ __ ) / _/_v4 / __/ /_ ___ __/ __ \/ __ )
/ // __ \/ /_/ / / / / |/_/ / / / __ | / // __ \/ /_/ / / / / |/_/ / / / __ |
@ -52,168 +52,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
_ ____ __ _ ____ __
(_)___ / __ )_________ / /_____ _____ (_)___ / __ )_________ / /_____ _____
/ / __ \/ __ / ___/ __ \/ //_/ _ \/ ___/ / / __ \/ __ / ___/ __ \/ //_/ _ \/ ___/
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${DGN} echo -e "${DGN}
__________ ____ _____________ __ __________ ____ _____________ __
/ / ____/ / / /\ \/ / ____/ _/ | / / / / ____/ / / /\ \/ / ____/ _/ | / /
__ / / __/ / / / / \ / /_ / // |/ / __ / / __/ / / / / \ / /_ / // |/ /
@ -52,177 +52,201 @@ echo -e "${DGN}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \ var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \
"18.04" "Bionic" OFF \ "18.04" "Bionic" OFF \
"20.04" "Focal" ON \ "20.04" "Focal" ON \
"21.10" "Impish" OFF \ "21.10" "Impish" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" OFF \ "1" "Unprivileged" OFF \
"0" "Privileged" ON \ "0" "Privileged" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -241,7 +265,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: c 226:0 rwm lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm lxc.cgroup2.devices.allow: c 29:0 rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
__ __ __ __ __ __ __ __
/ //_/__ __ _______/ /___ ____ _/ /__ / //_/__ __ _______/ /___ ____ _/ /__
/ ,< / _ \/ / / / ___/ / __ \/ __ / //_/ / ,< / _ \/ / / / ___/ / __ \/ __ / //_/
@ -53,168 +53,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ ___ _ __ ____ __ ___ _ __ ____
/ |/ /___ _____ _(_)____/ |/ (_)_____________ _____ / |/ /___ _____ _(_)____/ |/ (_)_____________ _____
/ /|_/ / __ / __ / / ___/ /|_/ / / ___/ ___/ __ \/ ___/ / /|_/ / __ / __ / / ___/ /|_/ / / ___/ ___/ __ \/ ___/
@ -53,168 +53,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ ___ _ ____ ____ __ ___ _ ____ ____
/ |/ /___ ______(_)___ _/ __ \/ __ ) / |/ /___ ______(_)___ _/ __ \/ __ )
/ /|_/ / __ / ___/ / __ / / / / __ | / /|_/ / __ / ___/ / __ / / / / __ |
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ ___ __ ______ __ __ __ ___ __ ______ __ __
/ |/ /__ _____/ /_ / ____/__ ____ / /__________ _/ / / |/ /__ _____/ /_ / ____/__ ____ / /__________ _/ /
/ /|_/ / _ \/ ___/ __ \/ / / _ \/ __ \/ __/ ___/ __ / / / /|_/ / _ \/ ___/ __ \/ / / _ \/ __ \/ __/ ___/ __ / /
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ ___ __ _ ________ ________ __ ___ __ _ ________ ________
/ |/ /___ / /_(_)___ ____ / ____/\ \/ / ____/ / |/ /___ / /_(_)___ ____ / ____/\ \/ / ____/
/ /|_/ / __ \/ __/ / __ \/ __ \/ __/ \ / __/ / /|_/ / __ \/ __/ / __ \/ __ \/ __/ \ / __/
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
___ ___
/ _ \ / _ \
_ __ | (_) |_v4_ _ __ | (_) |_v4_
@ -53,168 +53,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
_ __ _ __ _ __ _ __
/ | / /___ __ v4__(_)___/ /________ ____ ___ ___ / | / /___ __ v4__(_)___/ /________ ____ ___ ___
/ |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \ / |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \
@ -52,168 +52,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
_ __ __ ________ ______ _ _ __ __ ________ ______ _
/ | / /__ _ __/ /_/ ____/ /___ __v4______/ / __ \(_) / | / /__ _ __/ /_/ ____/ /___ __v4______/ / __ \(_)
/ |/ / _ \| |/_/ __/ / / / __ \/ / / / __ / /_/ / / / |/ / _ \| |/_/ __/ / / / __ \/ / / / __ / /_/ / /
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
_ __ _ ____ __ ___ _ __ _ ____ __ ___
/ | / /___ _(_)___ _ __ / __ \_________ _ ____ __ / |/ /___ _____ ____ _____ ____ _____ / | / /___ _(_)___ _ __ / __ \_________ _ ____ __ / |/ /___ _____ ____ _____ ____ _____
/ |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/ / |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/
@ -53,168 +53,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
_ __ ____ ____ _ __ ____ ____
/ | / /___ ____v4___ / __ \/ __ ) / | / /___ ____v4___ / __ \/ __ )
/ |/ / __ \/ ___/ __ \/ / / / __ | / |/ / __ \/ ___/ __ \/ / / / __ |
@ -52,168 +52,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
_ __ __ ____ __ _ __ __ ____ __
/ | / /___ ____/ /__ v4 / __ \___ ____/ / / | / /___ ____/ /__ v4 / __ \___ ____/ /
/ |/ / __ \/ __ / _ \ / /_/ / _ \/ __ / / |/ / __ \/ __ / _ \ / /_/ / _ \/ __ /
@ -52,168 +52,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ __ ____ __
/ __ \____ ___v4____ _____/ /___ _ / __ \____ ___v4____ _____/ /___ _
/ / / / __ __ \/ __ / __ / __ / / / / / __ __ \/ __ / __ / __ /
@ -52,177 +52,201 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \
"18.04" "Bionic" OFF \ "18.04" "Bionic" OFF \
"20.04" "Focal" ON \ "20.04" "Focal" ON \
"21.10" "Impish" OFF \ "21.10" "Impish" OFF \
"22.04" "Jammy" OFF \ "22.04" "Jammy" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
____ __ ___ ___ _ __ ____ ____ __ ___ ___ _ __ ____
/ __ \____v4___ ____ / |/ /__ ____/ (_)___ | | / /___ ___ __/ / /_ / __ \____v4___ ____ / |/ /__ ____/ (_)___ | | / /___ ___ __/ / /_
/ / / / __ \/ _ \/ __ \/ /|_/ / _ \/ __ / / __ `/ | / / __ `/ / / / / __/ / / / / __ \/ _ \/ __ \/ /|_/ / _ \/ __ / / __ `/ | / / __ `/ / / / / __/
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
__ _____ ____ __ _____ ____
____v4____ ___ ____ / / / / | / __ ) ____v4____ ___ ____ / / / / | / __ )
/ __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ | / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ |
@ -53,168 +53,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
____ __ ____ __
/ __ \____ _____ ___ _____/ /__v4__________ ____ ____ __ __ / __ \____ _____ ___ _____/ /__v4__________ ____ ____ __ __
/ /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/ / /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
____ __ ______ __________ ____ ____ _________ __ ___ ____ __ ______ __________ ____ ____ _________ __ ___
/ __ \/ / / / __ \/_ __/ __ \/ __ \/ __ \/ _/ ___// |/ / / __ \/ / / / __ \/_ __/ __ \/ __ \/ __ \/ _/ ___// |/ /
/ /_/ / /_/ / / / / / / / / / / /_/ / /_/ // / \__ \/ /|_/ / / /_/ / /_/ / / / / / / / / / / /_/ / /_/ // / \__ \/ /|_/ /
@ -52,168 +52,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
____ ____ __ ______ __ ______ ____ ____ __ ______ __ ______
/ __ \/ _/ / / / / __ \/ / / ____/ / __ \/ _/ / / / / __ \/ / / ____/
/ /_/ // /___/ /_/ / / / / / / __/ / /_/ // /___/ /_/ / / / / / / __/
@ -52,168 +52,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
____ __ ____ __
/ __ \/ /__ _ __ / __ \/ /__ _ __
/ /_/ / / _ \| |/_/ / /_/ / / _ \| |/_/
@ -52,177 +52,201 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \ var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \
"18.04" "Bionic" OFF \ "18.04" "Bionic" OFF \
"20.04" "Focal" ON \ "20.04" "Focal" ON \
"21.10" "Impish" OFF \ "21.10" "Impish" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" OFF \ "1" "Unprivileged" OFF \
"0" "Privileged" ON \ "0" "Privileged" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -241,7 +265,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: c 226:0 rwm lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm lxc.cgroup2.devices.allow: c 29:0 rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ __ ____ __
/ __ \____ ____/ /___ ___ ____ _____ / __ \____ ____/ /___ ___ ____ _____
v4 / /_/ / __ \/ __ / __ __ \/ __ / __ \ v4 / /_/ / __ \/ __ / __ __ \/ __ / __ \
@ -56,168 +56,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -236,7 +260,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
EOF EOF

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
____ __ _____ ____ __ ____ __ _____ ____ __
/ __ \____ _____/ /_____ _________ / ___// __ \ / / / __ \____ _____/ /_____ _________ / ___// __ \ / /
/ /_/ / __ \/ ___/ __/ __ / ___/ _ \\__ \/ / / / / / / /_/ / __ \/ ___/ __/ __ / ___/ _ \\__ \/ / / / / /
@ -53,168 +53,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
____ __ __ ____ __ __
/ __ \_________ ____ ___ ___ / /_/ /_ ___ __ _______ / __ \_________ ____ ___ ___ / /_/ /_ ___ __ _______
/ /_/ / ___/ __ \/ __ __ \/ _ \/ __/ __ \/ _ \/ / / / ___/ / /_/ / ___/ __ \/ __ __ \/ _ \/ __/ __ \/ _ \/ / / / ___/
@ -52,168 +52,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
_____ __ __ _ _____ __ __ _
/ ___/__ ______v4_____/ /_/ /_ (_)___ ____ _ / ___/__ ______v4_____/ /_/ /_ (_)___ ____ _
\__ \/ / / / __ \/ ___/ __/ __ \/ / __ \/ __ `/ \__ \/ / / / __ \/ ___/ __/ __ \/ / __ \/ __ `/
@ -54,168 +54,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
______ __ _ __ _ ____ _ _______ ______ __ _ __ _ ____ _ _______
/_ __/__ _____/ /_ ____ (_) /_(_)_ ______ ___ v4 / __ \/ | / / ___/ /_ __/__ _____/ /_ ____ (_) /_(_)_ ______ ___ v4 / __ \/ | / / ___/
/ / / _ \/ ___/ __ \/ __ \/ / __/ / / / / __ __ \ / / / / |/ /\__ \ / / / _ \/ ___/ __ \/ __ \/ / __/ / / / / __ __ \ / / / / |/ /\__ \
@ -52,168 +52,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
______ _ ___ ______ _ ___
/_ __/_v4_(_) (_)_ ______ ___ /_ __/_v4_(_) (_)_ ______ ___
/ / / ___/ / / / / / / __ `__ \ / / / ___/ / / / / / / __ `__ \
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
__ ____ __ __ ____ __
/ / / / /_v4__ ______ / /___ __ / / / / /_v4__ ______ / /___ __
/ / / / __ \/ / / / __ \/ __/ / / / / / / / __ \/ / / / __ \/ __/ / / /
@ -52,177 +52,201 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}"
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \
"18.04" "Bionic" OFF \ "18.04" "Bionic" OFF \
"20.04" "Focal" OFF \ "20.04" "Focal" OFF \
"21.10" "Impish" OFF \ "21.10" "Impish" OFF \
"22.04" "Jammy" ON \ "22.04" "Jammy" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}"; fi
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ __ __ __ __ __ __
/ / / /___ ___v4/ /_ ________ / / / / / /___ ___v4/ /_ ________ / /
/ / / / __ `__ \/ __ \/ ___/ _ \/ / / / / / __ `__ \/ __ \/ ___/ _ \/ /
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
EOF EOF

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
__ __ _ _____ __ __ _ _____
/ / / /_v4 (_) __(_) / / / /_v4 (_) __(_)
/ / / / __ \/ / /_/ / / / / / __ \/ / /_/ /
@ -52,168 +52,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${DGN} echo -e "${DGN}
__ __ __ _ __ __ __ __ __ _ __ __
/ / / /___ / /_(_)___ ___ ___ v4 / //_/_ ______ ___ ____ _ / / / /___ / /_(_)___ ___ ___ v4 / //_/_ ______ ___ ____ _
/ / / / __ \/ __/ / __ __ \/ _ \ / ,< / / / / __ __ \/ __ / / / / / __ \/ __/ / __ __ \/ _ \ / ,< / / / / __ __ \/ __ /
@ -53,168 +53,192 @@ echo -e "${DGN}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${CL} echo -e "${CL}
_ _____ __ ____ _______ _____ ____ ____ _______ __ _ _____ __ ____ _______ _____ ____ ____ _______ __
| | / / | / / / / / /_ __/ | / / | / __ \/ __ \/ ____/ | / / | | / / | / / / / / /_ __/ | / / | / __ \/ __ \/ ____/ | / /
| | / / /| |/ / / / / / / | | /| / / /| | / /_/ / / / / __/ / |/ / | | / / /| |/ / / / / / / | | /| / / /| | / /_/ / / / / __/ / |/ /
@ -52,168 +52,192 @@ echo -e "${CL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${GN} echo -e "${GN}
_ ____ ______ ____ ________ ______ _ ____ ______ ____ ________ ______
| | v4 / / / / / __ \/ __ \/ ____/ / / ____/ | | v4 / / / / / __ \/ __ \/ ____/ / / ____/
| | /| / / /_/ / / / / / / / / __/ / / __/ | | /| / / /_/ / / / / / / / / __/ / / __/
@ -52,168 +52,192 @@ echo -e "${GN}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
_ ___ __ _ _ _ ___ __ _ _
| | / (_) /__(_) (_)____ | | / (_) /__(_) (_)____
| | /| / / / //_/ / / / ___/ | | /| / / / //_/ / / / ___/
@ -53,168 +53,192 @@ echo -e "${BL}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
__ ___ _____ _ __ ___ _____ _
\ \ / (_) / ____| | | \ \ / (_) / ____| | |
\ \ /\ / / _ _ __ ___| | __ _ _ __ _ _ __ __| | \ \ /\ / / _ _ __ ___| | __ _ _ __ _ _ __ __| |
@ -54,168 +54,192 @@ echo -e "${RD}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
CT_TYPE="1" CT_TYPE="1"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" ON \ "1" "Unprivileged" ON \
"0" "Privileged" OFF \ "0" "Privileged" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
_____ _ __ ___ __ _______ ____________ _____ _ __ ___ __ _______ ____________
/__ / (_)___ _/ /_ ___ ___ |__ \ / |/ / __ \/_ __/_ __/ /__ / (_)___ _/ /_ ___ ___ |__ \ / |/ / __ \/_ __/_ __/
/ / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / / / / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / /
@ -53,168 +53,192 @@ echo -e "${YW}
${CL}" ${CL}"
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" OFF \ "1" "Unprivileged" OFF \
"0" "Privileged" ON \ "0" "Privileged" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm

View File

@ -10,13 +10,13 @@ NSAPP=$(echo ${APP,,} | tr -d ' ')
var_install="${NSAPP}-install" var_install="${NSAPP}-install"
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
INTEGER='^[0-9]+$' INTEGER='^[0-9]+$'
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -36,14 +36,14 @@ function error_exit() {
exit $EXIT exit $EXIT
} }
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
echo -e "⚠ User exited script \n" echo -e "⚠ User exited script \n"
exit exit
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
_____ _______ __ ______ _____ _______ __ ______
/__ /_ ______ __v4 _____ / / ___/ / / / / _/ /__ /_ ______ __v4 _____ / / ___/ / / / / _/
/ /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // / / /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // /
@ -53,168 +53,192 @@ cat << "EOF"
EOF EOF
} }
function msg_info() { 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 PVE_CHECK() { function PVE_CHECK() {
PVE=$(pveversion | grep "pve-manager/7" | wc -l) PVE=$(pveversion | grep "pve-manager/7" | wc -l)
if [[ $PVE != 1 ]]; then if [[ $PVE != 1 ]]; then
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function default_settings() { function default_settings() {
echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}"
CT_TYPE="0" CT_TYPE="0"
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
PW="" PW=""
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
CT_ID=$NEXTID CT_ID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
HN=$NSAPP HN=$NSAPP
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
DISK_SIZE="$var_disk" DISK_SIZE="$var_disk"
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
CORE_COUNT="$var_cpu" CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
RAM_SIZE="$var_ram" RAM_SIZE="$var_ram"
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
BRG="vmbr0" BRG="vmbr0"
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
NET=dhcp NET=dhcp
echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
GATE="" GATE=""
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
MAC="" MAC=""
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
VLAN="" VLAN=""
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
} }
function advanced_settings() { function advanced_settings() {
CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \ CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
"1" "Unprivileged" OFF \ "1" "Unprivileged" OFF \
"0" "Privileged" ON \ "0" "Privileged" ON \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
fi
PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
else
PW="-password $PW1"
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi fi
fi PW1=$(whiptail --inputbox "Set Root Password" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ $exitstatus = 0 ]; then
if [ -z $CT_ID ]; then CT_ID="$NEXTID"; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"; if [ -z $PW1 ]; then
else PW1="Automatic Login" PW=" "
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi; echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
fi else
CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) PW="-password $PW1"
exitstatus=$? echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
if [ -z $CT_NAME ]; then HN="$NSAPP"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi
else
if [ $exitstatus = 0 ]; then HN=$(echo ${CT_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
fi
DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"; advanced_settings; fi;
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}";
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 BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi;
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then NET="dhcp"; echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}";
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi;
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then GATE1="Default" GATE="";
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi fi
fi CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) exitstatus=$?
exitstatus=$? if [ -z $CT_ID ]; then
if [ $exitstatus = 0 ]; then CT_ID="$NEXTID"
if [ -z $MAC1 ]; then MAC1="Default" MAC=""; echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" else
else if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
MAC=",hwaddr=$MAC1"
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
fi fi
fi CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
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=$?
exitstatus=$? if [ -z $CT_NAME ]; then
if [ $exitstatus = 0 ]; then HN="$NSAPP"
if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" else
else if [ $exitstatus = 0 ]; then
VLAN=",tag=$VLAN1" HN=$(echo ${CT_NAME,,} | tr -d ' ')
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
fi
fi fi
fi DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then exitstatus=$?
if [ -z $DISK_SIZE ]; then
DISK_SIZE="$var_disk"
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
advanced_settings
fi
fi
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $CORE_COUNT ]; then
CORE_COUNT="$var_cpu"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
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 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $RAM_SIZE ]; then
RAM_SIZE="$var_ram"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
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
BRG="vmbr0"
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
fi
NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ -z $NET ]; then
NET="dhcp"
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
else
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
fi
GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $GATE1 ]; then
GATE1="Default" GATE=""
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
else
GATE=",gw=$GATE1"
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
fi
fi
MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ -z $MAC1 ]; then
MAC1="Default" MAC=""
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
else
MAC=",hwaddr=$MAC1"
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
if [ -z $VLAN1 ]; then
VLAN1="Default" VLAN=""
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
fi
fi
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
else else
clear clear
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
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}"
default_settings default_settings
else else
header_info header_info
echo -e "${RD}Using Advanced Settings${CL}" echo -e "${RD}Using Advanced Settings${CL}"
advanced_settings advanced_settings
fi fi
} }
clear clear
start_script start_script
if [ "$CT_TYPE" == "1" ]; then if [ "$CT_TYPE" == "1" ]; then
FEATURES="nesting=1,keyctl=1" FEATURES="nesting=1,keyctl=1"
else else
FEATURES="nesting=1" FEATURES="nesting=1"
fi fi
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
export CTID=$CT_ID export CTID=$CT_ID
@ -233,7 +257,7 @@ export PCT_OPTIONS="
" "
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG cat <<EOF >>$LXC_CONFIG
lxc.cgroup2.devices.allow: a lxc.cgroup2.devices.allow: a
lxc.cap.drop: lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm lxc.cgroup2.devices.allow: c 188:* rwm

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo -e "\e[1;33mThis script will add Tailscale to an existing LXC Container ONLY\e[0m" echo -e "\e[1;33mThis script will add Tailscale to an existing LXC Container ONLY\e[0m"
while true; do while true; do
read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
@ -32,7 +32,7 @@ function msg() {
CTID=$1 CTID=$1
CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $CTID_CONFIG_PATH cat <<EOF >>$CTID_CONFIG_PATH
lxc.cgroup2.devices.allow: c 10:200 rwm lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
EOF EOF

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
IP=$(hostname -I | awk '{print $1}') IP=$(hostname -I | awk '{print $1}')
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -21,25 +21,25 @@ alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR trap die ERR
function error_exit() { function error_exit() {
trap - ERR trap - ERR
local reason="Unknown failure occured." local reason="Unknown failure occured."
local msg="${1:-$reason}" local msg="${1:-$reason}"
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
echo -e "$flag $msg" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
while true; do while true; do
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
______ __ _____ ______ __ _____
/ ____/___ ____/ /__ / ___/___ ______ _____ _____ / ____/___ ____/ /__ / ___/___ ______ _____ _____
/ / / __ \/ __ / _ \ \__ \/ _ \/ ___/ | / / _ \/ ___/ / / / __ \/ __ / _ \ \__ \/ _ \/ ___/ | / / _ \/ ___/
@ -66,9 +66,9 @@ apt-get install -y sudo &>/dev/null
apt-get install -y git &>/dev/null apt-get install -y git &>/dev/null
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest \ VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 3, length($2)-4) }') \ awk '{print substr($2, 3, length($2)-4) }')
msg_info "Installing Code-Server v${VERSION}" msg_info "Installing Code-Server v${VERSION}"
curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb &>/dev/null curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb &>/dev/null
@ -76,7 +76,7 @@ sudo dpkg -i code-server_${VERSION}_amd64.deb &>/dev/null
rm -rf code-server_${VERSION}_amd64.deb rm -rf code-server_${VERSION}_amd64.deb
mkdir -p ~/.config/code-server/ mkdir -p ~/.config/code-server/
sudo systemctl enable --now code-server@$USER &>/dev/null sudo systemctl enable --now code-server@$USER &>/dev/null
cat <<EOF > ~/.config/code-server/config.yaml cat <<EOF >~/.config/code-server/config.yaml
bind-addr: 0.0.0.0:8680 bind-addr: 0.0.0.0:8680
auth: none auth: none
password: password:

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
clear clear
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -15,14 +15,14 @@ APP="Home Assistant Container"
while true; do while true; do
read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ ___ _ __ __ __ __ ___ _ __ __
/ / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_
/ /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/
@ -46,10 +46,12 @@ function msg_error() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
if [ -z "$(ls -A /var/lib/docker/volumes/hass_config/_data/backups/)" ]; then msg_error "No backups found! \n"; exit 1; fi if [ -z "$(ls -A /var/lib/docker/volumes/hass_config/_data/backups/)" ]; then
msg_error "No backups found! \n"
exit 1
fi
DIR=/var/lib/docker/volumes/hass_config/_data/restore DIR=/var/lib/docker/volumes/hass_config/_data/restore
if [ -d "$DIR" ]; if [ -d "$DIR" ]; then
then
msg_ok "Restore Directory Exists." msg_ok "Restore Directory Exists."
else else
mkdir -p /var/lib/docker/volumes/hass_config/_data/restore mkdir -p /var/lib/docker/volumes/hass_config/_data/restore
@ -58,7 +60,10 @@ fi
cd /var/lib/docker/volumes/hass_config/_data/backups/ cd /var/lib/docker/volumes/hass_config/_data/backups/
PS3="Please enter your choice: " PS3="Please enter your choice: "
files="$(ls -A .)" files="$(ls -A .)"
select filename in ${files}; do msg_ok "You selected ${BL}${filename}${CL}"; break; done select filename in ${files}; do
msg_ok "You selected ${BL}${filename}${CL}"
break
done
msg_info "Stopping Home Assistant" msg_info "Stopping Home Assistant"
docker stop homeassistant &>/dev/null docker stop homeassistant &>/dev/null
msg_ok "Stopped Home Assistant" msg_ok "Stopped Home Assistant"

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
clear clear
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -15,14 +15,14 @@ APP="Home Assistant Core"
while true; do while true; do
read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ ___ _ __ __ ______ __ __ ___ _ __ __ ______
/ / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___ ________ / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___ ________
/ /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \
@ -46,10 +46,12 @@ function msg_error() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then msg_error "No backups found! \n"; exit 1; fi if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then
msg_error "No backups found! \n"
exit 1
fi
DIR=/root/.homeassistant/restore DIR=/root/.homeassistant/restore
if [ -d "$DIR" ]; if [ -d "$DIR" ]; then
then
msg_ok "Restore Directory Exists." msg_ok "Restore Directory Exists."
else else
mkdir -p /root/.homeassistant/restore mkdir -p /root/.homeassistant/restore
@ -58,7 +60,10 @@ fi
cd /root/.homeassistant/backups/ cd /root/.homeassistant/backups/
PS3="Please enter your choice: " PS3="Please enter your choice: "
files="$(ls -A .)" files="$(ls -A .)"
select filename in ${files}; do msg_ok "You selected ${BL}${filename}${CL}"; break; done select filename in ${files}; do
msg_ok "You selected ${BL}${filename}${CL}"
break
done
msg_info "Stopping Home Assistant" msg_info "Stopping Home Assistant"
sudo service homeassistant stop sudo service homeassistant stop
msg_ok "Stopped Home Assistant" msg_ok "Stopped Home Assistant"

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -20,25 +20,25 @@ alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR trap die ERR
function error_exit() { function error_exit() {
trap - ERR trap - ERR
local reason="Unknown failure occured." local reason="Unknown failure occured."
local msg="${1:-$reason}" local msg="${1:-$reason}"
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
echo -e "$flag $msg" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
while true; do while true; do
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
_____ _ _____ _____ _ _____
/ ____| | |/ ____| / ____| | |/ ____|
| | _ __ _____ ____| | (___ ___ ___ | | _ __ _____ ____| | (___ ___ ___

View File

@ -1,23 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
clear clear
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
while true; do while true; do
read -p "This will Update Dashy LXC. Proceed(y/n)?" yn read -p "This will Update Dashy LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
_____ _ _____ _
| __ \ | | | __ \ | |
| | | | __ _ ___| |__ _ _ | | | | __ _ ___| |__ _ _

View File

@ -2,26 +2,26 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)"
set -e set -e
KERNEL_ON=$(uname -r) KERNEL_ON=$(uname -r)
PVE_KERNEL=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1) PVE_KERNEL=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1)
EDGE_KERNEL=$(dpkg --list| grep 'kernel-.*-edge' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1) EDGE_KERNEL=$(dpkg --list | grep 'kernel-.*-edge' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1)
clear clear
while true; do while true; do
read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
show_menu(){ show_menu() {
normal=`echo "\033[m"` normal=$(echo "\033[m")
safe=`echo "\033[32m"` safe=$(echo "\033[32m")
menu=`echo "\033[36m"` menu=$(echo "\033[36m")
number=`echo "\033[33m"` number=$(echo "\033[33m")
bgred=`echo "\033[41m"` bgred=$(echo "\033[41m")
fgred=`echo "\033[31m"` fgred=$(echo "\033[31m")
proxmox-boot-tool kernel list proxmox-boot-tool kernel list
echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}" echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}"
printf "\n${menu}*********************************************${normal}\n" printf "\n${menu}*********************************************${normal}\n"
@ -34,106 +34,113 @@ show_menu(){
printf "Please choose an option from the menu and enter or ${fgred}x${normal} to exit." printf "Please choose an option from the menu and enter or ${fgred}x${normal} to exit."
read opt read opt
} }
option_picked(){ option_picked() {
msgcolor=`echo "\033[01;31m"` msgcolor=$(echo "\033[01;31m")
normal=`echo "\033[00;00m"` normal=$(echo "\033[00;00m")
message=${@:-"${normal}Error: No message passed"} message=${@:-"${normal}Error: No message passed"}
printf "${msgcolor}${message}${normal}\n" printf "${msgcolor}${message}${normal}\n"
} }
clear clear
show_menu show_menu
while [ $opt != '' ] while [ $opt != '' ]; do
do
if [ $opt = '' ]; then if [ $opt = '' ]; then
exit; exit
else else
case $opt in case $opt in
1) while true; do 1)
read -p "Are you sure you want to Install Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn while true; do
case $yn in read -p "Are you sure you want to Install Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn
[Yy]* ) break;; case $yn in
[Nn]* ) exit;; [Yy]*) break ;;
* ) echo "Please answer yes or no.";; [Nn]*) exit ;;
esac *) echo "Please answer yes or no." ;;
done esac
clear; done
option_picked "Installing Proxmox Edge Kernel & Rebooting"; clear
option_picked "Installing Proxmox Edge Kernel & Rebooting"
apt-get install -y gnupg apt-get install -y gnupg
curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add - curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add -
echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" > /etc/apt/sources.list.d/pve-edge-kernel.list echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list
apt-get -y update apt-get -y update
apt-get -y install pve-kernel-5.19-edge apt-get -y install pve-kernel-5.19-edge
reboot reboot
break; break
;; ;;
2) while true; do 2)
read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn while true; do
case $yn in read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn
[Yy]* ) break;; case $yn in
[Nn]* ) exit;; [Yy]*) break ;;
* ) echo "Please answer yes or no.";; [Nn]*) exit ;;
esac *) echo "Please answer yes or no." ;;
done esac
clear; done
option_picked "Switching to Proxmox VE 7 Kernel & Rebooting"; clear
option_picked "Switching to Proxmox VE 7 Kernel & Rebooting"
proxmox-boot-tool kernel pin ${PVE_KERNEL} proxmox-boot-tool kernel pin ${PVE_KERNEL}
reboot reboot
break; break
;; ;;
3) while true; do 3)
read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn while true; do
case $yn in read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn
[Yy]* ) break;; case $yn in
[Nn]* ) exit;; [Yy]*) break ;;
* ) echo "Please answer yes or no.";; [Nn]*) exit ;;
esac *) echo "Please answer yes or no." ;;
done esac
clear; done
option_picked "Switching to Proxmox Edge Kernel & Rebooting"; clear
option_picked "Switching to Proxmox Edge Kernel & Rebooting"
proxmox-boot-tool kernel pin ${EDGE_KERNEL} proxmox-boot-tool kernel pin ${EDGE_KERNEL}
reboot reboot
break; break
;; ;;
4) while true; do 4)
read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn while true; do
case $yn in read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn
[Yy]* ) break;; case $yn in
[Nn]* ) exit;; [Yy]*) break ;;
* ) echo "Please answer yes or no.";; [Nn]*) exit ;;
esac *) echo "Please answer yes or no." ;;
done esac
clear; done
option_picked "Unpinning Current Kernel"; clear
option_picked "Unpinning Current Kernel"
proxmox-boot-tool kernel unpin proxmox-boot-tool kernel unpin
clear; clear
break; break
;; ;;
5) while true; do 5)
read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn while true; do
case $yn in read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn
[Yy]* ) break;; case $yn in
[Nn]* ) exit;; [Yy]*) break ;;
* ) echo "Please answer yes or no.";; [Nn]*) exit ;;
esac *) echo "Please answer yes or no." ;;
done esac
clear; done
option_picked "Removing Proxmox Edge Kernel & Rebooting"; clear
option_picked "Removing Proxmox Edge Kernel & Rebooting"
apt-get purge -y ${EDGE_KERNEL} apt-get purge -y ${EDGE_KERNEL}
rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list
proxmox-boot-tool kernel unpin proxmox-boot-tool kernel unpin
reboot reboot
break; break
;; ;;
x)exit; x)
;; exit
\n)exit; ;;
;; \n)
*)clear; exit
option_picked "Please choose an option from the menu"; ;;
show_menu; *)
;; clear
esac option_picked "Please choose an option from the menu"
show_menu
;;
esac
fi fi
done done
show_menu show_menu

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4) LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -14,14 +14,14 @@ APP="Emby"
while true; do while true; do
read -p "This will Update ${APP} to ${LATEST}. Proceed(y/n)?" yn read -p "This will Update ${APP} to ${LATEST}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
______ __ ______ __
/ ____/___ ___ / /_ __ __ / ____/___ ___ / /_ __ __
/ __/ / __ __ \/ __ \/ / / / / __/ / __ __ \/ __ \/ / / /

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
IP=$(hostname -I | awk '{print $1}') IP=$(hostname -I | awk '{print $1}')
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -21,25 +21,25 @@ alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR trap die ERR
function error_exit() { function error_exit() {
trap - ERR trap - ERR
local reason="Unknown failure occured." local reason="Unknown failure occured."
local msg="${1:-$reason}" local msg="${1:-$reason}"
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
echo -e "$flag $msg" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
while true; do while true; do
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${DGN} echo -e "${DGN}
______ _ _ ____ ______ _ _ ____
| ____(_) | | _ \ | ____(_) | | _ \
@ -81,7 +81,7 @@ WorkingDirectory=/root/
ExecStart=/usr/local/bin/filebrowser -r / ExecStart=/usr/local/bin/filebrowser -r /
[Install] [Install]
WantedBy=default.target" > $service_path WantedBy=default.target" >$service_path
systemctl enable --now filebrowser.service &>/dev/null systemctl enable --now filebrowser.service &>/dev/null
msg_ok "Created Service" msg_ok "Created Service"

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo -e "\e[1;33m This script will Prepare a LXC Container for Frigate \e[0m" echo -e "\e[1;33m This script will Prepare a LXC Container for Frigate \e[0m"
while true; do while true; do
read -p "Did you replace 106 with your LXC ID? Proceed (y/n)?" yn read -p "Did you replace 106 with your LXC ID? Proceed (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -48,7 +48,7 @@ for char_dev in ${CHAR_DEVS[@]}; do
CHAR_DEV_STRING+=" -regex \".*/${char_dev}\"" CHAR_DEV_STRING+=" -regex \".*/${char_dev}\""
done done
read -r -d '' HOOK_SCRIPT <<- EOF || true read -r -d '' HOOK_SCRIPT <<-EOF || true
for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do
dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)"; dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)";
mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev}); mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev});
@ -66,7 +66,7 @@ CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf
sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf
cat CTID.conf >$CTID_CONFIG_PATH cat CTID.conf >$CTID_CONFIG_PATH
cat <<EOF >> $CTID_CONFIG_PATH cat <<EOF >>$CTID_CONFIG_PATH
lxc.autodev: 1 lxc.autodev: 1
lxc.hook.autodev: bash -c '$HOOK_SCRIPT' lxc.hook.autodev: bash -c '$HOOK_SCRIPT'
EOF EOF

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data-podman.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data-podman.sh)"
while true; do while true; do
read -p "Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -58,28 +58,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA LXC would you like to copy FROM?\n" \ "\nWhich HA LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Podman LXC would you like to copy TO?\n" \ "\nWhich HA Podman LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.02.12" 13 50 || exit Version: 2022.02.12" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -90,13 +90,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/ DOCKER_PATH=/var/lib/docker/volumes/hass_config/
PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/ PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${PODMAN_PATH}" ] || \ [ -d "${CTID_TO_PATH}${PODMAN_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
rm -rf ${CTID_TO_PATH}${PODMAN_PATH} rm -rf ${CTID_TO_PATH}${PODMAN_PATH}

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data.sh)"
while true; do while true; do
read -p "Use to copy all data from one Home Assistant LXC to another. Proceed(y/n)?" yn read -p "Use to copy all data from one Home Assistant LXC to another. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -58,28 +58,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA LXC would you like to copy FROM?\n" \ "\nWhich HA LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA LXC would you like to copy TO?\n" \ "\nWhich HA LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.01.23" 13 50 || exit Version: 2022.01.23" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -89,13 +89,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
fi fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/ DOCKER_PATH=/var/lib/docker/volumes/hass_config/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
rm -rf ${CTID_TO_PATH}${DOCKER_PATH} rm -rf ${CTID_TO_PATH}${DOCKER_PATH}

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
while true; do while true; do
read -p "Use to copy all data from a Home Assistant Container LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Home Assistant Container LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -55,28 +55,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Container LXC would you like to copy FROM?\n" \ "\nWhich HA Container LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Core LXC would you like to copy TO?\n" \ "\nWhich HA Core LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.10.02" 13 50 || exit Version: 2022.10.02" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -87,13 +87,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data
CORE_PATH=/root/.homeassistant CORE_PATH=/root/.homeassistant
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${CORE_PATH}" ] || \ [ -d "${CTID_TO_PATH}${CORE_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
msg "Copying Data..." msg "Copying Data..."

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
while true; do while true; do
read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Container LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Container LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -55,28 +55,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Core LXC would you like to copy FROM?\n" \ "\nWhich HA Core LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Container LXC would you like to copy TO?\n" \ "\nWhich HA Container LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.10.02" 13 50 || exit Version: 2022.10.02" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -87,13 +87,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data
CORE_PATH=/root/.homeassistant CORE_PATH=/root/.homeassistant
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${CORE_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${CORE_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
msg "Copying Data..." msg "Copying Data..."

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
clear clear
while true; do while true; do
read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -51,28 +51,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Core LXC would you like to copy FROM?\n" \ "\nWhich HA Core LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Core LXC would you like to copy TO?\n" \ "\nWhich HA Core LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.10.03" 13 50 || exit Version: 2022.10.03" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -83,13 +83,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data
CORE_PATH=/root/.homeassistant CORE_PATH=/root/.homeassistant
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${CORE_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${CORE_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${CORE_PATH}" ] || \ [ -d "${CTID_TO_PATH}${CORE_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
msg "Copying Data..." msg "Copying Data..."

View File

@ -4,9 +4,9 @@ echo -e "\e[1;33m This script will install Home Assistant Community Store (HACS)
while true; do while true; do
read -p "Start the HACS Install Script (y/n)?" yn read -p "Start the HACS Install Script (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done

View File

@ -4,9 +4,9 @@ echo -e "\e[1;33m This script will install Home Assistant Community Store (HACS)
while true; do while true; do
read -p "Start the HACS Install Script (y/n)?" yn read -p "Start the HACS Install Script (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done

View File

@ -1,22 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
PP=`echo "\e[1;35m"` PP=$(echo "\e[1;35m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
while true; do while true; do
read -p "This will Update Heimdall Dashboard. Proceed(y/n)?" yn read -p "This will Update Heimdall Dashboard. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${PP} echo -e "${PP}
_ _ _ _ _ _ _____ _ _ _ _ _ _ _ _ _ _____ _ _ _
| | | | (_) | | | | | | __ \ | | | | | | | | | | (_) | | | | | | __ \ | | | | | |
| |__| | ___ _ _ __ ___ __| | __ _| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| | | |__| | ___ _ _ __ ___ __| | __ _| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| |
@ -39,13 +39,13 @@ echo -en "${GN} Backing up Data... "
if [ -d "/opt/Heimdall-2.4.6" ]; then if [ -d "/opt/Heimdall-2.4.6" ]; then
cp -R /opt/Heimdall-2.4.6/database database-backup cp -R /opt/Heimdall-2.4.6/database database-backup
cp -R /opt/Heimdall-2.4.6/public public-backup cp -R /opt/Heimdall-2.4.6/public public-backup
elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then
cp -R /opt/Heimdall-2.4.7b/database database-backup cp -R /opt/Heimdall-2.4.7b/database database-backup
cp -R /opt/Heimdall-2.4.7b/public public-backup cp -R /opt/Heimdall-2.4.7b/public public-backup
elif [[ -d "/opt/Heimdall-2.4.8" ]]; then elif [[ -d "/opt/Heimdall-2.4.8" ]]; then
cp -R /opt/Heimdall-2.4.8/database database-backup cp -R /opt/Heimdall-2.4.8/database database-backup
cp -R /opt/Heimdall-2.4.8/public public-backup cp -R /opt/Heimdall-2.4.8/public public-backup
else else
cp -R /opt/Heimdall/database database-backup cp -R /opt/Heimdall/database database-backup
cp -R /opt/Heimdall/public public-backup cp -R /opt/Heimdall/public public-backup
fi fi
@ -56,13 +56,13 @@ RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releas
echo -en "${GN} Updating Heimdall Dashboard to ${RELEASE}... " echo -en "${GN} Updating Heimdall Dashboard to ${RELEASE}... "
curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" &>/dev/null curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" &>/dev/null
tar xvzf ${RELEASE}.tar.gz &>/dev/null tar xvzf ${RELEASE}.tar.gz &>/dev/null
VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest \ VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 3, length($2)-4) }') awk '{print substr($2, 3, length($2)-4) }')
if [ ! -d "/opt/Heimdall" ]; then if [ ! -d "/opt/Heimdall" ]; then
mv Heimdall-${VER} /opt/Heimdall mv Heimdall-${VER} /opt/Heimdall
else else
cp -R Heimdall-${VER}/* /opt/Heimdall cp -R Heimdall-${VER}/* /opt/Heimdall
fi fi
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
@ -82,7 +82,7 @@ ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0
TimeoutStopSec=30 TimeoutStopSec=30
[Install] [Install]
WantedBy=multi-user.target" > $service_path WantedBy=multi-user.target" >$service_path
echo -en "${GN} Restoring Data... " echo -en "${GN} Restoring Data... "
cp -R database-backup/* /opt/Heimdall/database cp -R database-backup/* /opt/Heimdall/database
@ -94,10 +94,10 @@ echo -en "${GN} Cleanup... "
if [ -d "/opt/Heimdall-2.4.6" ]; then if [ -d "/opt/Heimdall-2.4.6" ]; then
rm -rf /opt/Heimdall-2.4.6 rm -rf /opt/Heimdall-2.4.6
rm -rf /opt/v2.4.6.tar.gz rm -rf /opt/v2.4.6.tar.gz
elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then
rm -rf /opt/Heimdall-2.4.7b rm -rf /opt/Heimdall-2.4.7b
rm -rf /opt/v2.4.7b.tar.gz rm -rf /opt/v2.4.7b.tar.gz
elif [[ -d "/opt/Heimdall-2.4.8" ]]; then elif [[ -d "/opt/Heimdall-2.4.8" ]]; then
rm -rf /opt/Heimdall-2.4.8 rm -rf /opt/Heimdall-2.4.8
rm -rf /opt/v2.4.8.tar.gz rm -rf /opt/v2.4.8.tar.gz
fi fi
@ -116,4 +116,3 @@ sleep 2
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
echo -en "${GN} Finished! ${CL}\n" echo -en "${GN} Finished! ${CL}\n"

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -19,25 +19,25 @@ alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR trap die ERR
function error_exit() { function error_exit() {
trap - ERR trap - ERR
local reason="Unknown failure occured." local reason="Unknown failure occured."
local msg="${1:-$reason}" local msg="${1:-$reason}"
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
echo -e "$flag $msg" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
while true; do while true; do
read -p "This will Update ${APP}. Proceed(y/n)?" yn read -p "This will Update ${APP}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
__ __ __ __
/ / / /___ ____ ___ ___ ____ ____ _____ ____ / / / /___ ____ ___ ___ ____ ____ _____ ____
/ /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \ / /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \
@ -61,7 +61,7 @@ function msg_ok() {
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
if ! command -v pnpm >/dev/null 2>&1; then if ! command -v pnpm >/dev/null 2>&1; then
npm install -g pnpm &>/dev/null npm install -g pnpm &>/dev/null
fi fi
cd /opt/homepage cd /opt/homepage
systemctl stop homepage systemctl stop homepage

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash -ex #!/usr/bin/env bash -ex
set -euo pipefail set -euo pipefail
shopt -s inherit_errexit nullglob shopt -s inherit_errexit nullglob
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -18,15 +18,15 @@ current_kernel=$(uname -r)
while true; do while true; do
read -p "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed(y/n)?" yn read -p "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo -e "${RD}Please answer y/n${CL}";; *) echo -e "${RD}Please answer y/n${CL}" ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
_ __ _ _____ _ _ __ _ _____ _
| |/ / | | / ____| | | |/ / | | / ____| |
| / ___ _ __ _ __ ___| | | | | | ___ __ _ _ __ | / ___ _ __ _ __ ___| | | | | | ___ __ _ _ __
@ -48,29 +48,29 @@ function msg_ok() {
} }
function check_root() { function check_root() {
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo -e "${CROSS}${RD}Error: This script must be ran as the root user.\n${CL}" echo -e "${CROSS}${RD}Error: This script must be ran as the root user.\n${CL}"
exit 1 exit 1
else else
header_info header_info
edge_kernel edge_kernel
kernel_info kernel_info
kernel_clean kernel_clean
fi fi
} }
function edge_kernel() { function edge_kernel() {
if [[ "$current_kernel" == *"edge"* ]]; then if [[ "$current_kernel" == *"edge"* ]]; then
echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active"
echo -e "\nAn Active PVE Kernel is required to use Kernel Clean\n" echo -e "\nAn Active PVE Kernel is required to use Kernel Clean\n"
exit 1 exit 1
fi fi
} }
function kernel_info() { function kernel_info() {
if [[ "$MODE" != "PBS" ]]; then if [[ "$MODE" != "PBS" ]]; then
echo -e "${YW}PVE Version: ${BL}$(pveversion)\n${CL}" echo -e "${YW}PVE Version: ${BL}$(pveversion)\n${CL}"
fi fi
if [[ "$current_kernel" == *"pve"* ]]; then if [[ "$current_kernel" == *"pve"* ]]; then
echo -e "${YW}Current Kernel: ${BL}$current_kernel\n${CL}" echo -e "${YW}Current Kernel: ${BL}$current_kernel\n${CL}"
else else
@ -80,50 +80,49 @@ function kernel_info() {
} }
function kernel_clean() { function kernel_clean() {
kernels=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print $2}' | sort -V) kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print $2}' | sort -V)
remove_kernels="" remove_kernels=""
for kernel in $kernels for kernel in $kernels; do
do
if [ "$(echo $kernel | grep $current_kernel)" ]; then if [ "$(echo $kernel | grep $current_kernel)" ]; then
break break
else else
echo -e "${BL}'$kernel' ${CL}${YW}has been added to the remove Kernel list\n${CL}" echo -e "${BL}'$kernel' ${CL}${YW}has been added to the remove Kernel list\n${CL}"
remove_kernels+=" $kernel" remove_kernels+=" $kernel"
fi fi
done done
msg_ok "Kernel Search Completed\n" msg_ok "Kernel Search Completed\n"
if [[ "$remove_kernels" != *"pve"* ]]; then if [[ "$remove_kernels" != *"pve"* ]]; then
echo -e "${PARTY} ${GN}It appears there are no old Kernels on your system. \n${CL}" echo -e "${PARTY} ${GN}It appears there are no old Kernels on your system. \n${CL}"
msg_info "Exiting" msg_info "Exiting"
sleep 2 sleep 2
msg_ok "Done" msg_ok "Done"
else else
read -p "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') selected Kernels listed above? [y/n]: " -n 1 -r read -p "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') selected Kernels listed above? [y/n]: " -n 1 -r
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}" msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}"
/usr/bin/apt purge -y $remove_kernels > /dev/null 2>&1 /usr/bin/apt purge -y $remove_kernels >/dev/null 2>&1
msg_ok "Successfully Removed Kernels" msg_ok "Successfully Removed Kernels"
msg_info "Updating GRUB" msg_info "Updating GRUB"
/usr/sbin/update-grub > /dev/null 2>&1 /usr/sbin/update-grub >/dev/null 2>&1
msg_ok "Successfully Updated GRUB" msg_ok "Successfully Updated GRUB"
msg_info "Exiting" msg_info "Exiting"
sleep 2 sleep 2
msg_ok "Done" msg_ok "Done"
else else
msg_info "Exiting" msg_info "Exiting"
sleep 2 sleep 2
msg_ok "Done" msg_ok "Done"
fi fi
fi fi
} }
if ! command -v pveversion >/dev/null 2>&1; then if ! command -v pveversion >/dev/null 2>&1; then
echo -e " Switching to PBS mode" echo -e " Switching to PBS mode"
MODE="PBS" MODE="PBS"
sleep 2 sleep 2
else else
MODE="PVE" MODE="PVE"
fi fi
check_root check_root

View File

@ -3,9 +3,9 @@
while true; do while true; do
read -p "This will create a New Update Menu for Home Assistant Container LXC. Proceed(y/n)?" yn read -p "This will create a New Update Menu for Home Assistant Container LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
@ -13,19 +13,19 @@ set -o errexit
rm -rf /root/update.sh update update-containers.sh rm -rf /root/update.sh update update-containers.sh
echo -e "\e[1;92m Creating New Update Menu Script... \e[0m" echo -e "\e[1;92m Creating New Update Menu Script... \e[0m"
if [ -f /usr/local/lib/python3.9/dist-packages/runlike/runlike.py ]; then if [ -f /usr/local/lib/python3.9/dist-packages/runlike/runlike.py ]; then
echo -e "\e[1;92m pip3/runlike Already Installed! \e[0m" echo -e "\e[1;92m pip3/runlike Already Installed! \e[0m"
else else
apt-get update &>/dev/null apt-get update &>/dev/null
echo -e "\e[1;92m Installing pip3... \e[0m" echo -e "\e[1;92m Installing pip3... \e[0m"
apt-get install -y python3-pip &>/dev/null apt-get install -y python3-pip &>/dev/null
echo -e "\e[1;92m Installing runlike... \e[0m" echo -e "\e[1;92m Installing runlike... \e[0m"
pip3 install runlike &>/dev/null pip3 install runlike &>/dev/null
fi fi
echo -e "\e[1;92m Creating Update Script... \e[0m" echo -e "\e[1;92m Creating Update Script... \e[0m"
if [ -d /root/hass_config ]; then if [ -d /root/hass_config ]; then
echo -e "\e[1;92m There's Already (hass_config) Folder! \e[0m" echo -e "\e[1;92m There's Already (hass_config) Folder! \e[0m"
else else
mkdir /root/hass_config mkdir /root/hass_config
fi fi
UPDATE_PATH='/root/update' UPDATE_PATH='/root/update'
UPDATE_CONTAINERS_PATH='/root/update-containers.sh' UPDATE_CONTAINERS_PATH='/root/update-containers.sh'

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest \ RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 3, length($2)-4) }') awk '{print substr($2, 3, length($2)-4) }')
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
function update_info { function update_info {
cat << "EOF" cat <<"EOF"
_ __ _ __ _ __ _ __
/ | / /___ __ __(_)___/ /________ ____ ___ ___ / | / /___ __ __(_)___/ /________ ____ ___ ___
/ |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \ / |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \
@ -23,9 +23,9 @@ update_info
while true; do while true; do
read -p "This will Update Navidrome to v$RELEASE. Proceed(y/n)?" yn read -p "This will Update Navidrome to v$RELEASE. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
sleep 2 sleep 2

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -19,25 +19,25 @@ alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR trap die ERR
function error_exit() { function error_exit() {
trap - ERR trap - ERR
local reason="Unknown failure occured." local reason="Unknown failure occured."
local msg="${1:-$reason}" local msg="${1:-$reason}"
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
echo -e "$flag $msg" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
while true; do while true; do
read -p "This will Update ${APP}. Proceed(y/n)?" yn read -p "This will Update ${APP}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${YW} echo -e "${YW}
_ _ _____ ____ _ _ _____ ____
| \ | | | __ \| _ \ | \ | | | __ \| _ \
| \| | ___ v3___ ___ | | | | |_) | | \| | ___ v3___ ___ | | | | |_) |
@ -68,18 +68,17 @@ msg_ok "Updated ${APP}"
read -p "${APP} LXC needs to reboot to apply the update. Reboot now? " -n 1 -r read -p "${APP} LXC needs to reboot to apply the update. Reboot now? " -n 1 -r
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] if [[ $REPLY =~ ^[Yy]$ ]]; then
then
reboot=yes reboot=yes
else else
reboot=no reboot=no
fi fi
if [ "$reboot" == "yes" ]; then if [ "$reboot" == "yes" ]; then
msg_info "Rebooting ${APP} LXC" msg_info "Rebooting ${APP} LXC"
reboot reboot
fi fi
if [ "$reboot" == "no" ]; then if [ "$reboot" == "no" ]; then
msg_ok "Finished Updating ${APP}. Reboot to apply the update." msg_ok "Finished Updating ${APP}. Reboot to apply the update."
fi fi

View File

@ -1,24 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/node-red-themes.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/node-red-themes.sh)"
set -o errexit set -o errexit
show_menu(){ show_menu() {
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
echo -e "${RD} Backup your Node-Red flows before running this script!!${CL} \n " echo -e "${RD} Backup your Node-Red flows before running this script!!${CL} \n "
while true; do while true; do
read -p "This will Install Node-Red Themes. Proceed(y/n)?" yn read -p "This will Install Node-Red Themes. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
echo -e "${RD} Backup your Node-Red flows before installing any theme!!${CL} \n " echo -e "${RD} Backup your Node-Red flows before installing any theme!!${CL} \n "
printf "\n${BL}*********************************************${CL}\n" printf "\n${BL}*********************************************${CL}\n"
printf "${BL}**${YW} 1)${GN} Default Theme ${CL}\n" printf "${BL}**${YW} 1)${GN} Default Theme ${CL}\n"
printf "${BL}**${YW} 2)${GN} Dark Theme ${CL}\n" printf "${BL}**${YW} 2)${GN} Dark Theme ${CL}\n"
@ -32,75 +32,84 @@ echo -e "${RD} Backup your Node-Red flows before installing any theme!!${CL} \n
read opt read opt
} }
option_picked(){ option_picked() {
msgcolor=`echo "\033[01;31m"` msgcolor=$(echo "\033[01;31m")
normal=`echo "\033[00;00m"` normal=$(echo "\033[00;00m")
message=${@:-"${CL}Error: No message passed"} message=${@:-"${CL}Error: No message passed"}
printf "${RD}${message}${CL}\n" printf "${RD}${message}${CL}\n"
} }
clear clear
show_menu show_menu
while [ "$opt" != " " ] while [ "$opt" != " " ]; do
do case $opt in
case $opt in 1)
1) clear; clear
option_picked "Installing Default Theme"; option_picked "Installing Default Theme"
THEME= THEME=
JS=// JS=//
break; break
;; ;;
2) clear; 2)
option_picked "Installing Dark Theme"; clear
THEME=dark option_picked "Installing Dark Theme"
break; THEME=dark
break
;; ;;
3) clear; 3)
option_picked "Installing Dracula Theme"; clear
THEME=dracula option_picked "Installing Dracula Theme"
break; THEME=dracula
break
;; ;;
4) clear; 4)
option_picked "Installing Midnight-Red Theme"; clear
THEME=midnight-red option_picked "Installing Midnight-Red Theme"
break; THEME=midnight-red
break
;; ;;
5) clear; 5)
option_picked "Installing Oled Theme"; clear
THEME=oled option_picked "Installing Oled Theme"
break; THEME=oled
break
;; ;;
6) clear; 6)
option_picked "Installing Solarized-Dark Theme"; clear
THEME=solarized-dark option_picked "Installing Solarized-Dark Theme"
break; THEME=solarized-dark
break
;; ;;
7) clear; 7)
option_picked "Installing Solarized-Light Theme"; clear
THEME=solarized-light option_picked "Installing Solarized-Light Theme"
break; THEME=solarized-light
break
;; ;;
x)exit; x)
exit
;; ;;
\n)exit; \n)
exit
;; ;;
*)clear; *)
option_picked "Please choose a theme from the menu"; clear
show_menu; option_picked "Please choose a theme from the menu"
show_menu
;; ;;
esac esac
done done
echo -en "${GN} Installing ${THEME} Theme... " echo -en "${GN} Installing ${THEME} Theme... "
cd /root/.node-red cd /root/.node-red
if [ "${THEME}" = "" ]; then if [ "${THEME}" = "" ]; then
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
else else
npm install @node-red-contrib-themes/${THEME} &>/dev/null npm install @node-red-contrib-themes/${THEME} &>/dev/null
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
fi fi
echo -en "${GN} Writing Settings... " echo -en "${GN} Writing Settings... "
cat <<EOF > /root/.node-red/settings.js cat <<EOF >/root/.node-red/settings.js
module.exports = { uiPort: process.env.PORT || 1880, module.exports = { uiPort: process.env.PORT || 1880,
mqttReconnectTime: 15000, mqttReconnectTime: 15000,
serialReconnectTime: 15000, serialReconnectTime: 15000,

View File

@ -1,16 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest \ RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 3, length($2)-4) }') \ awk '{print substr($2, 3, length($2)-4) }')
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
function update_info { function update_info {
echo -e "${RD} echo -e "${RD}
_ _ _____ __ __ _ _ _____ __ __
| \ | | | __ \ | \/ | | \ | | | __ \ | \/ |
| \| | | |__) | | \ / | | \| | | |__) | | \ / |
@ -24,12 +24,12 @@ ${CL}"
update_info update_info
while true; do while true; do
read -p "This will update Nginx Proxy Manager to v${RELEASE}. Proceed(y/n)?" yn read -p "This will update Nginx Proxy Manager to v${RELEASE}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
update_info update_info
@ -57,23 +57,23 @@ function msg() {
T="$(date +%M)" T="$(date +%M)"
if [ -f /lib/systemd/system/npm.service ]; then if [ -f /lib/systemd/system/npm.service ]; then
echo -en "${GN} Prep For Update... " echo -en "${GN} Prep For Update... "
sleep 2 sleep 2
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
echo -en "${GN} Stopping Services... " echo -en "${GN} Stopping Services... "
systemctl stop openresty systemctl stop openresty
systemctl stop npm systemctl stop npm
echo -e "${CM}${CL} \r"
echo -en "${GN} Cleaning Old Files... "
rm -rf /app \
/var/www/html \
/etc/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/cache/nginx &>/dev/null
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
else
echo -en "${GN} Cleaning Old Files... "
rm -rf /app \
/var/www/html \
/etc/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/cache/nginx &>/dev/null
echo -e "${CM}${CL} \r"
else
echo -en "${RD} No NPM to Update! ${CL}" echo -en "${RD} No NPM to Update! ${CL}"
exit exit
fi fi
@ -103,24 +103,24 @@ cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-prox
ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf
rm -f /etc/nginx/conf.d/dev.conf rm -f /etc/nginx/conf.d/dev.conf
mkdir -p /tmp/nginx/body \ mkdir -p /tmp/nginx/body \
/run/nginx \ /run/nginx \
/data/nginx \ /data/nginx \
/data/custom_ssl \ /data/custom_ssl \
/data/logs \ /data/logs \
/data/access \ /data/access \
/data/nginx/default_host \ /data/nginx/default_host \
/data/nginx/default_www \ /data/nginx/default_www \
/data/nginx/proxy_host \ /data/nginx/proxy_host \
/data/nginx/redirection_host \ /data/nginx/redirection_host \
/data/nginx/stream \ /data/nginx/stream \
/data/nginx/dead_host \ /data/nginx/dead_host \
/data/nginx/temp \ /data/nginx/temp \
/var/lib/nginx/cache/public \ /var/lib/nginx/cache/public \
/var/lib/nginx/cache/private \ /var/lib/nginx/cache/private \
/var/cache/nginx/proxy_temp /var/cache/nginx/proxy_temp
chmod -R 777 /var/cache/nginx chmod -R 777 /var/cache/nginx
chown root /tmp/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 echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then
@ -144,7 +144,7 @@ echo -e "${CM}${CL} \r"
echo -en "${GN} Initializing Backend... " echo -en "${GN} Initializing Backend... "
rm -rf /app/config/default.json &>/dev/null rm -rf /app/config/default.json &>/dev/null
if [ ! -f /app/config/production.json ]; then if [ ! -f /app/config/production.json ]; then
cat << 'EOF' > /app/config/production.json cat <<'EOF' >/app/config/production.json
{ {
"database": { "database": {
"engine": "knex-native", "engine": "knex-native",
@ -168,7 +168,7 @@ systemctl enable npm &>/dev/null
systemctl start openresty systemctl start openresty
systemctl start npm systemctl start npm
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
TS="$(($(date +%M)-T))" TS="$(($(date +%M) - T))"
IP=$(hostname -I | cut -f1 -d ' ') IP=$(hostname -I | cut -f1 -d ' ')
echo -e "${GN}Successfully Updated Nginx Proxy Manager to ${RD}${RELEASE}${CL} and it took ${RD}${TS} minutes.${CL} echo -e "${GN}Successfully Updated Nginx Proxy Manager to ${RD}${RELEASE}${CL} and it took ${RD}${TS} minutes.${CL}

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
clear clear
RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
RETRY_NUM=10 RETRY_NUM=10
RETRY_EVERY=3 RETRY_EVERY=3
NUM=$RETRY_NUM NUM=$RETRY_NUM
@ -30,7 +30,7 @@ function msg_error() {
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
cat << "EOF" cat <<"EOF"
____ __ ____ __
/ __ \____ _____ ___ _____/ /__ __________ ____ ____ __ __ / __ \____ _____ ___ _____/ /__ __________ ____ ____ __ __
/ /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/ / /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/
@ -42,9 +42,9 @@ EOF
while true; do while true; do
read -p "This will Update Paperless-ngx to $RELEASE. Proceed(y/n)?" yn read -p "This will Update Paperless-ngx to $RELEASE. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
sleep 2 sleep 2

View File

@ -1,28 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
RELEASE=$(curl -s https://api.github.com/repos/photoprism/photoprism/releases/latest \ RELEASE=$(curl -s https://api.github.com/repos/photoprism/photoprism/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 2, length($2)-4) }') \ awk '{print substr($2, 2, length($2)-4) }')
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
PP=`echo "\e[1;35m"` PP=$(echo "\e[1;35m")
while true; do while true; do
read -p "Update PhotoPrism LXC. Proceed(y/n)?" yn read -p "Update PhotoPrism LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${PP} echo -e "${PP}
_____ _ _ _____ _ _____ _ _ _____ _
| __ \| | | | | __ \ (_) | __ \| | | | | __ \ (_)
| |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___ | |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___
@ -34,7 +34,7 @@ ${CL}"
} }
header_info header_info
show_menu(){ show_menu() {
printf " ${YW} 1)${GN} Release Branch ${CL}\n" printf " ${YW} 1)${GN} Release Branch ${CL}\n"
printf " ${YW} 2)${YW} Develop Branch ${CL}\n" printf " ${YW} 2)${YW} Develop Branch ${CL}\n"
@ -42,37 +42,41 @@ show_menu(){
read opt read opt
} }
option_picked(){ option_picked() {
message1=${@:-"${CL}Error: No message passed"} message1=${@:-"${CL}Error: No message passed"}
printf " ${YW}${message1}${CL}\n" printf " ${YW}${message1}${CL}\n"
} }
show_menu show_menu
while [ "$opt" != " " ] while [ "$opt" != " " ]; do
do case $opt in
case $opt in 1)
1) clear; clear
header_info; header_info
option_picked "Using Release Branch"; option_picked "Using Release Branch"
BR="release" BR="release"
break; break
;; ;;
2) clear; 2)
header_info; clear
option_picked "Using Develop Branch"; header_info
BR="develop" option_picked "Using Develop Branch"
break; BR="develop"
break
;; ;;
x)exit; x)
exit
;; ;;
\n)exit; \n)
exit
;; ;;
*)clear; *)
option_picked "Please choose a Install Branch from the menu"; clear
show_menu; option_picked "Please choose a Install Branch from the menu"
show_menu
;; ;;
esac esac
done done
echo -en "${GN} Stopping PhotoPrism... " echo -en "${GN} Stopping PhotoPrism... "
sudo systemctl stop photoprism sudo systemctl stop photoprism
@ -100,5 +104,3 @@ sudo systemctl start photoprism
echo -e "${CM}${CL} \n" echo -e "${CM}${CL} \n"
echo -e "${GN} Finished ${CL} \n " echo -e "${GN} Finished ${CL} \n "

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/pms-copy-data.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/pms-copy-data.sh)"
while true; do while true; do
read -p "Use to copy all data from one Plex Media Server LXC to another. Proceed(y/n)?" yn read -p "Use to copy all data from one Plex Media Server LXC to another. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -58,28 +58,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Plex Media Server LXC would you like to copy FROM?\n" \ "\nWhich Plex Media Server LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Plex Media Server LXC would you like to copy TO?\n" \ "\nWhich Plex Media Server LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.01.24" 13 50 || exit Version: 2022.01.24" 13 50 || exit
info "Plex Media Server Data from '$CTID_FROM' to '$CTID_TO'" info "Plex Media Server Data from '$CTID_FROM' to '$CTID_TO'"
@ -89,13 +89,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
fi fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DATA_PATH=/var/lib/plexmediaserver/Library/ DATA_PATH=/var/lib/plexmediaserver/Library/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DATA_PATH}" ] ||
die "Plex Media Server directories in '$CTID_FROM' not found." die "Plex Media Server directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \ [ -d "${CTID_TO_PATH}${DATA_PATH}" ] ||
die "Plex Media Server directories in '$CTID_TO' not found." die "Plex Media Server directories in '$CTID_TO' not found."
#rm -rf ${CTID_TO_PATH}${DATA_PATH} #rm -rf ${CTID_TO_PATH}${DATA_PATH}

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/podman-copy-data-docker.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/podman-copy-data-docker.sh)"
while true; do while true; do
read -p "Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -58,28 +58,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA Podman LXC would you like to copy FROM?\n" \ "\nWhich HA Podman LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich HA LXC would you like to copy TO?\n" \ "\nWhich HA LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.03.31" 13 50 || exit Version: 2022.03.31" 13 50 || exit
info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'"
@ -90,13 +90,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DOCKER_PATH=/var/lib/docker/volumes/hass_config/ DOCKER_PATH=/var/lib/docker/volumes/hass_config/
PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/ PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${PODMAN_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${PODMAN_PATH}" ] ||
die "Home Assistant directories in '$CTID_FROM' not found." die "Home Assistant directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || \ [ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] ||
die "Home Assistant directories in '$CTID_TO' not found." die "Home Assistant directories in '$CTID_TO' not found."
rm -rf ${CTID_TO_PATH}${DOCKER_PATH} rm -rf ${CTID_TO_PATH}${DOCKER_PATH}

View File

@ -4,9 +4,9 @@ echo -e "\e[1;33m This script will install Home Assistant Community Store (HACS)
while true; do while true; do
read -p "Start the HACS Install Script (y/n)?" yn read -p "Start the HACS Install Script (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash -ex #!/usr/bin/env bash -ex
set -euo pipefail set -euo pipefail
shopt -s inherit_errexit nullglob shopt -s inherit_errexit nullglob
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -17,19 +17,19 @@ echo -e "${BL}This script will Perform Post Install Routines.${CL}"
while true; do while true; do
read -p "Start the PBS Post Install Script (y/n)?" yn read -p "Start the PBS Post Install Script (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
if command -v pveversion >/dev/null 2>&1; then if command -v pveversion >/dev/null 2>&1; then
echo -e "\n🛑 PVE Detected, Wrong Script!\n" echo -e "\n🛑 PVE Detected, Wrong Script!\n"
exit 1 exit 1
fi fi
function header_info { function header_info {
cat << "EOF" cat <<"EOF"
____ ____ _____ ____ __ ____ __ ____ ____ ____ _____ ____ __ ____ __ ____
/ __ \/ __ ) ___/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / / / __ \/ __ ) ___/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
/ /_/ / __ \__ \ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / / / /_/ / __ \__ \ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
@ -52,74 +52,67 @@ function msg_ok() {
clear clear
header_info header_info
read -r -p "Disable Enterprise Repository? <y/N> " prompt read -r -p "Disable Enterprise Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Disabling Enterprise Repository"
msg_info "Disabling Enterprise Repository" sleep 2
sleep 2 sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pbs-enterprise.list
sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pbs-enterprise.list msg_ok "Disabled Enterprise Repository"
msg_ok "Disabled Enterprise Repository"
fi fi
read -r -p "Add/Correct PBS Sources (sources.list)? <y/N> " prompt read -r -p "Add/Correct PBS Sources (sources.list)? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Adding or Correcting PBS Sources"
msg_info "Adding or Correcting PBS Sources" cat <<EOF >/etc/apt/sources.list
cat <<EOF > /etc/apt/sources.list
deb http://ftp.debian.org/debian bullseye main contrib deb http://ftp.debian.org/debian bullseye main contrib
deb http://ftp.debian.org/debian bullseye-updates main contrib deb http://ftp.debian.org/debian bullseye-updates main contrib
deb http://security.debian.org/debian-security bullseye-security main contrib deb http://security.debian.org/debian-security bullseye-security main contrib
EOF EOF
sleep 2 sleep 2
msg_ok "Added or Corrected PBS Sources" msg_ok "Added or Corrected PBS Sources"
fi fi
read -r -p "Enable No-Subscription Repository? <y/N> " prompt read -r -p "Enable No-Subscription Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Enabling No-Subscription Repository"
msg_info "Enabling No-Subscription Repository" cat <<EOF >>/etc/apt/sources.list
cat <<EOF >> /etc/apt/sources.list
deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription
EOF EOF
sleep 2 sleep 2
msg_ok "Enabled No-Subscription Repository" msg_ok "Enabled No-Subscription Repository"
fi fi
read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Adding Beta/Test Repository and set disabled"
msg_info "Adding Beta/Test Repository and set disabled" cat <<EOF >>/etc/apt/sources.list
cat <<EOF >> /etc/apt/sources.list
# deb http://download.proxmox.com/debian/pbs bullseye pbstest # deb http://download.proxmox.com/debian/pbs bullseye pbstest
EOF EOF
sleep 2 sleep 2
msg_ok "Added Beta/Test Repository" msg_ok "Added Beta/Test Repository"
fi fi
read -r -p "Disable Subscription Nag? <y/N> " prompt read -r -p "Disable Subscription Nag? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Disabling Subscription Nag"
msg_info "Disabling Subscription Nag" echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" > /etc/apt/apt.conf.d/no-nag-script apt --reinstall install proxmox-widget-toolkit &>/dev/null
apt --reinstall install proxmox-widget-toolkit &>/dev/null msg_ok "Disabled Subscription Nag"
msg_ok "Disabled Subscription Nag"
fi fi
read -r -p "Update Proxmox Backup Server now? <y/N> " prompt read -r -p "Update Proxmox Backup Server now? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Updating Proxmox Backup Server (Patience)"
msg_info "Updating Proxmox Backup Server (Patience)" apt-get update &>/dev/null
apt-get update &>/dev/null apt-get -y dist-upgrade &>/dev/null
apt-get -y dist-upgrade &>/dev/null msg_ok "Updated Proxmox Backup Server (⚠ Reboot Recommended)"
msg_ok "Updated Proxmox Backup Server (⚠ Reboot Recommended)"
fi fi
read -r -p "Reboot Proxmox Backup Server now? <y/N> " prompt read -r -p "Reboot Proxmox Backup Server now? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Rebooting Proxmox Backup Server"
msg_info "Rebooting Proxmox Backup Server" sleep 2
sleep 2 msg_ok "Completed Post Install Routines"
msg_ok "Completed Post Install Routines" reboot
reboot
fi fi
sleep 2 sleep 2

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash -ex #!/usr/bin/env bash -ex
set -euo pipefail set -euo pipefail
shopt -s inherit_errexit nullglob shopt -s inherit_errexit nullglob
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -17,26 +17,26 @@ echo -e "${BL}This script will Perform Post Install Routines.${CL}"
while true; do while true; do
read -p "Start the PVE7 Post Install Script (y/n)?" yn read -p "Start the PVE7 Post Install Script (y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
if ! command -v pveversion >/dev/null 2>&1; then if ! command -v pveversion >/dev/null 2>&1; then
echo -e "\n🛑 No PVE Detected, Wrong Script!\n" echo -e "\n🛑 No PVE Detected, Wrong Script!\n"
exit 1 exit 1
fi fi
if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then if [ $(pveversion | grep "pve-manager/7" | wc -l) -ne 1 ]; then
echo -e "\n${RD}⚠ This version of Proxmox Virtual Environment is not supported" echo -e "\n${RD}⚠ This version of Proxmox Virtual Environment is not supported"
echo -e "Requires PVE Version: 7.XX${CL}" echo -e "Requires PVE Version: 7.XX${CL}"
echo -e "\nExiting..." echo -e "\nExiting..."
sleep 3 sleep 3
exit exit
fi fi
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
____ _ _____________ ____ __ ____ __ ____ ____ _ _____________ ____ __ ____ __ ____
/ __ \ | / / ____/__ / / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / / / __ \ | / / ____/__ / / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
/ /_/ / | / / __/ / / / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ / / / / /_/ / | / / __/ / / / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ / / /
@ -58,74 +58,67 @@ function msg_ok() {
clear clear
header_info header_info
read -r -p "Disable Enterprise Repository? <y/N> " prompt read -r -p "Disable Enterprise Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Disabling Enterprise Repository"
msg_info "Disabling Enterprise Repository" sleep 2
sleep 2 sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list
sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list msg_ok "Disabled Enterprise Repository"
msg_ok "Disabled Enterprise Repository"
fi fi
read -r -p "Add/Correct PVE7 Sources (sources.list)? <y/N> " prompt read -r -p "Add/Correct PVE7 Sources (sources.list)? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Adding or Correcting PVE7 Sources"
msg_info "Adding or Correcting PVE7 Sources" cat <<EOF >/etc/apt/sources.list
cat <<EOF > /etc/apt/sources.list
deb http://ftp.debian.org/debian bullseye main contrib deb http://ftp.debian.org/debian bullseye main contrib
deb http://ftp.debian.org/debian bullseye-updates main contrib deb http://ftp.debian.org/debian bullseye-updates main contrib
deb http://security.debian.org/debian-security bullseye-security main contrib deb http://security.debian.org/debian-security bullseye-security main contrib
EOF EOF
sleep 2 sleep 2
msg_ok "Added or Corrected PVE7 Sources" msg_ok "Added or Corrected PVE7 Sources"
fi fi
read -r -p "Enable No-Subscription Repository? <y/N> " prompt read -r -p "Enable No-Subscription Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Enabling No-Subscription Repository"
msg_info "Enabling No-Subscription Repository" cat <<EOF >>/etc/apt/sources.list
cat <<EOF >> /etc/apt/sources.list
deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
EOF EOF
sleep 2 sleep 2
msg_ok "Enabled No-Subscription Repository" msg_ok "Enabled No-Subscription Repository"
fi fi
read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Adding Beta/Test Repository and set disabled"
msg_info "Adding Beta/Test Repository and set disabled" cat <<EOF >>/etc/apt/sources.list
cat <<EOF >> /etc/apt/sources.list
# deb http://download.proxmox.com/debian/pve bullseye pvetest # deb http://download.proxmox.com/debian/pve bullseye pvetest
EOF EOF
sleep 2 sleep 2
msg_ok "Added Beta/Test Repository" msg_ok "Added Beta/Test Repository"
fi fi
read -r -p "Disable Subscription Nag? <y/N> " prompt read -r -p "Disable Subscription Nag? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Disabling Subscription Nag"
msg_info "Disabling Subscription Nag" echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" > /etc/apt/apt.conf.d/no-nag-script apt --reinstall install proxmox-widget-toolkit &>/dev/null
apt --reinstall install proxmox-widget-toolkit &>/dev/null msg_ok "Disabled Subscription Nag (Delete browser cache)"
msg_ok "Disabled Subscription Nag (Delete browser cache)"
fi fi
read -r -p "Update Proxmox VE 7 now? <y/N> " prompt read -r -p "Update Proxmox VE 7 now? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Updating Proxmox VE 7 (Patience)"
msg_info "Updating Proxmox VE 7 (Patience)" apt-get update &>/dev/null
apt-get update &>/dev/null apt-get -y dist-upgrade &>/dev/null
apt-get -y dist-upgrade &>/dev/null msg_ok "Updated Proxmox VE 7 (⚠ Reboot Recommended)"
msg_ok "Updated Proxmox VE 7 (⚠ Reboot Recommended)"
fi fi
read -r -p "Reboot Proxmox VE 7 now? <y/N> " prompt read -r -p "Reboot Proxmox VE 7 now? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
then msg_info "Rebooting Proxmox VE 7"
msg_info "Rebooting Proxmox VE 7" sleep 2
sleep 2 msg_ok "Completed Post Install Routines"
msg_ok "Completed Post Install Routines" reboot
reboot
fi fi
sleep 2 sleep 2

View File

@ -4,14 +4,14 @@ set -e
while true; do while true; do
read -p "View CPU Scaling Governors. Proceed(y/n)?" yn read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e " echo -e "
_____ _____ _ _ _____ _____ _ _
/ ____| __ \| | | | / ____| __ \| | | |
| | | |__) | | | | | | | |__) | | | |
@ -21,16 +21,16 @@ echo -e "
Scaling Governors Scaling Governors
" "
} }
show_menu(){ show_menu() {
CL=`echo "\033[m"` CL=$(echo "\033[m")
GN=`echo "\033[32m"` GN=$(echo "\033[32m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
fgred=`echo "\033[31m"` fgred=$(echo "\033[31m")
header_info header_info
CK=$(uname -r) CK=$(uname -r)
IP=$(hostname -I) IP=$(hostname -I)
# MAC=$(cat /sys/class/net/eno1/address) # MAC=$(cat /sys/class/net/eno1/address)
ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors) ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
echo -e "${YW}Proxmox IP ${BL}${IP}${CL}" echo -e "${YW}Proxmox IP ${BL}${IP}${CL}"
@ -57,43 +57,51 @@ header_info
} }
clear clear
show_menu show_menu
while [ $opt != '' ] while [ $opt != '' ]; do
do
if [ $opt = '' ]; then if [ $opt = '' ]; then
exit; exit
else else
case $opt in case $opt in
1) echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 1)
echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
2) echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2)
echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
3) echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 3)
echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
4) echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 4)
echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
5) echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 5)
echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
6) echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 6)
echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear clear
show_menu show_menu
;; ;;
x)exit; x)
;; exit
\n)exit; ;;
;; \n)
*)clear; exit
show_menu; ;;
;; *)
esac clear
show_menu
;;
esac
fi fi
done done

View File

@ -7,59 +7,50 @@ dnsUrl="https://download.technitium.com/dns/DnsServerPortable.tar.gz"
mkdir -p $dnsDir mkdir -p $dnsDir
installLog="$dnsDir/install.log" installLog="$dnsDir/install.log"
echo "" > $installLog echo "" >$installLog
echo "" echo ""
echo "===============================" echo "==============================="
echo "Technitium DNS Server Update" echo "Technitium DNS Server Update"
echo "===============================" echo "==============================="
if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.NETCore.App 6.0."; if dotnet --list-runtimes 2>/dev/null | grep -q "Microsoft.NETCore.App 6.0."; then
then
dotnetFound="yes" dotnetFound="yes"
else else
dotnetFound="no" dotnetFound="no"
fi fi
if [ -d $dotnetDir ] if [ -d $dotnetDir ]; then
then dotnetUpdate="yes"
dotnetUpdate="yes" echo "Updating .NET 6 Runtime..."
echo "Updating .NET 6 Runtime..." fi
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 6.0 --runtime dotnet --no-path --install-dir $dotnetDir --verbose >>$installLog 2>&1
if [ ! -f "/usr/bin/dotnet" ]; then
ln -s $dotnetDir/dotnet /usr/bin >>$installLog 2>&1
fi
if dotnet --list-runtimes 2>/dev/null | grep -q "Microsoft.NETCore.App 6.0."; then
if [ "$dotnetUpdate" = "yes" ]; then
echo ".NET 6 Runtime was updated successfully!"
fi fi
else
echo "Failed to update .NET 6 Runtime. Please try again."
exit 1
fi
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 6.0 --runtime dotnet --no-path --install-dir $dotnetDir --verbose >> $installLog 2>&1 if curl -o $dnsTar --fail $dnsUrl >>$installLog 2>&1; then
if [ -d $dnsDir ]; then
if [ ! -f "/usr/bin/dotnet" ]
then
ln -s $dotnetDir/dotnet /usr/bin >> $installLog 2>&1
fi
if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.NETCore.App 6.0.";
then
if [ "$dotnetUpdate" = "yes" ]
then
echo ".NET 6 Runtime was updated successfully!"
fi
else
echo "Failed to update .NET 6 Runtime. Please try again."
exit 1
fi
if curl -o $dnsTar --fail $dnsUrl >> $installLog 2>&1
then
if [ -d $dnsDir ]
then
echo "Updating Technitium DNS Server..." echo "Updating Technitium DNS Server..."
fi fi
tar -zxf $dnsTar -C $dnsDir >> $installLog 2>&1 tar -zxf $dnsTar -C $dnsDir >>$installLog 2>&1
if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ] if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ]; then
then if [ -f "/etc/systemd/system/dns.service" ]; then
if [ -f "/etc/systemd/system/dns.service" ]
then
echo "Restarting systemd service..." echo "Restarting systemd service..."
systemctl restart dns.service >> $installLog 2>&1 systemctl restart dns.service >>$installLog 2>&1
fi fi
echo "" echo ""

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest \ RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 3, length($2)-4) }') awk '{print substr($2, 3, length($2)-4) }')
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
function update_info { function update_info {
cat << "EOF" cat <<"EOF"
______ _ ___ ______ _ ___
/_ __/____(_) (_)_ ______ ___ /_ __/____(_) (_)_ ______ ___
/ / / ___/ / / / / / / __ `__ \ / / / ___/ / / / / / / __ `__ \
@ -23,9 +23,9 @@ update_info
while true; do while true; do
read -p "This will Update Trilium to v$RELEASE. Proceed(y/n)?" yn read -p "This will Update Trilium to v$RELEASE. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
sleep 2 sleep 2

View File

@ -1,22 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
APP="UniFi Update" APP="UniFi Update"
while true; do while true; do
read -p "This will run ${APP}. Proceed(y/n)?" yn read -p "This will run ${APP}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${RD} echo -e "${RD}
_ _ _ ______ _ _ _ _ ______ _
| | | | (_) ____(_) | | | | (_) ____(_)
| | | |_ __ _| |__ _ | | | |_ __ _| |__ _
@ -30,4 +30,3 @@ ${CL}"
header_info header_info
sleep 3 sleep 3
wget -qL https://get.glennr.nl/unifi/update/unifi-update.sh && bash unifi-update.sh wget -qL https://get.glennr.nl/unifi/update/unifi-update.sh && bash unifi-update.sh

View File

@ -1,22 +1,22 @@
#!/bin/bash #!/bin/bash
set -e set -e
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
while true; do while true; do
read -p "This Will Update All LXC Containers. Proceed(y/n)?" yn read -p "This Will Update All LXC Containers. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${BL} echo -e "${BL}
_ _ _____ _____ _______ ______ _ _ _____ _____ _______ ______
| | | | __ \| __ \ /\|__ __| ____| | | | | __ \| __ \ /\|__ __| ____|
| | | | |__) | | | | / \ | | | |__ | | | | |__) | | | | / \ | | | |__
@ -39,34 +39,33 @@ function update_container() {
} }
read -p "Skip stopped containers? " -n 1 -r read -p "Skip stopped containers? " -n 1 -r
echo echo
if [[ ! $REPLY =~ ^[Yy]$ ]] if [[ ! $REPLY =~ ^[Yy]$ ]]; then
then skip=no
skip=no
else else
skip=yes skip=yes
fi fi
for container in $containers for container in $containers; do
do status=$(pct status $container)
status=`pct status $container` if [ "$skip" == "no" ]; then
if [ "$skip" == "no" ]; then if [ "$status" == "status: stopped" ]; then
if [ "$status" == "status: stopped" ]; then echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" pct start $container
pct start $container echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" sleep 5
sleep 5 update_container $container
update_container $container echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" pct shutdown $container &
pct shutdown $container & elif [ "$status" == "status: running" ]; then
elif [ "$status" == "status: running" ]; then update_container $container
update_container $container fi
fi fi
fi if [ "$skip" == "yes" ]; then
if [ "$skip" == "yes" ]; then if [ "$status" == "status: running" ]; then
if [ "$status" == "status: running" ]; then update_container $container
update_container $container fi
fi fi
fi done
done; wait wait
echo -e "${GN} Finished, All Containers Updated. ${CL} \n" echo -e "${GN} Finished, All Containers Updated. ${CL} \n"

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash -ex #!/usr/bin/env bash -ex
LATEST=$(curl -sL https://api.github.com/repos/louislam/uptime-kuma/releases/latest | grep '"tag_name":' | cut -d'"' -f4) LATEST=$(curl -sL https://api.github.com/repos/louislam/uptime-kuma/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BGN=`echo "\033[4;92m"` BGN=$(echo "\033[4;92m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
DGN=`echo "\033[32m"` DGN=$(echo "\033[32m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" HOLD="-"
CM="${GN}${CL}" CM="${GN}${CL}"
@ -14,14 +14,14 @@ APP="Uptime Kuma"
while true; do while true; do
read -p "This will Update ${APP} to ${LATEST}. Proceed(y/n)?" yn read -p "This will Update ${APP} to ${LATEST}. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
function header_info { function header_info {
echo -e "${DGN} echo -e "${DGN}
_ _ _ _ _ __ _ _ _ _ _ __
| | | | | | (_) | |/ / | | | | | | (_) | |/ /
| | | |_v3_ | |_ _ _ __ ___ ___ | ' /_ _ _ __ ___ __ _ | | | |_v3_ | |_ _ _ __ ___ ___ | ' /_ _ _ __ ___ __ _
@ -45,7 +45,10 @@ function msg_ok() {
echo -e "${BFR} ${CM} ${GN}${msg}${CL}" echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
} }
if [ ! -d "/opt/uptime-kuma" ]; then echo -e "No Uptime Kuma Directory Found."; exit; fi if [ ! -d "/opt/uptime-kuma" ]; then
echo -e "No Uptime Kuma Directory Found."
exit
fi
msg_info "Stopping ${APP}" msg_info "Stopping ${APP}"
sudo systemctl stop uptime-kuma &>/dev/null sudo systemctl stop uptime-kuma &>/dev/null

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo -e "\e[1;33m This script will allow USB passthrough to a PRIVILEGED LXC Container ONLY\e[0m" echo -e "\e[1;33m This script will allow USB passthrough to a PRIVILEGED LXC Container ONLY\e[0m"
while true; do while true; do
read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
@ -45,7 +45,7 @@ for char_dev in ${CHAR_DEVS[@]}; do
CHAR_DEV_STRING+=" -regex \".*/${char_dev}\"" CHAR_DEV_STRING+=" -regex \".*/${char_dev}\""
done done
read -r -d '' HOOK_SCRIPT <<- EOF || true read -r -d '' HOOK_SCRIPT <<-EOF || true
for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do
dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)"; dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)";
mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev}); mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev});
@ -63,7 +63,7 @@ CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf
sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf
cat CTID.conf >$CTID_CONFIG_PATH cat CTID.conf >$CTID_CONFIG_PATH
cat <<EOF >> $CTID_CONFIG_PATH cat <<EOF >>$CTID_CONFIG_PATH
lxc.autodev: 1 lxc.autodev: 1
lxc.hook.autodev: bash -c '$HOOK_SCRIPT' lxc.hook.autodev: bash -c '$HOOK_SCRIPT'
EOF EOF

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \ VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 2, length($2)-3) }') awk '{print substr($2, 2, length($2)-3) }')
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
function update_info { function update_info {
echo -e "${BL} echo -e "${BL}
__ __ _ _ _ __ __ _ _ _
\ \ / / | | | | | \ \ / / | | | | |
\ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __ \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __
@ -24,9 +24,9 @@ update_info
while true; do while true; do
read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
sleep 2 sleep 2

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VWRELEASE=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest \ VWRELEASE=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest |
| grep "tag_name" \ grep "tag_name" |
| awk '{print substr($2, 2, length($2)-3) }') awk '{print substr($2, 2, length($2)-3) }')
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
function update_info { function update_info {
echo -e "${BL} echo -e "${BL}
__ __ _ _ _ __ __ _ _ _
\ \ / / | | | | | \ \ / / | | | | |
\ \ /\ / /__| |__ ________ ____ _ _ _| | |_ \ \ /\ / /__| |__ ________ ____ _ _ _| | |_
@ -23,9 +23,9 @@ update_info
while true; do while true; do
read -p "This will Update Web-Vault to $VWRELEASE. Proceed(y/n)?" yn read -p "This will Update Web-Vault to $VWRELEASE. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
sleep 2 sleep 2
@ -36,9 +36,9 @@ sleep 1
echo -e "${GN} Updating to ${VWRELEASE}... ${CL}" echo -e "${GN} Updating to ${VWRELEASE}... ${CL}"
curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$VWRELEASE/bw_web_$VWRELEASE.tar.gz &>/dev/null curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$VWRELEASE/bw_web_$VWRELEASE.tar.gz &>/dev/null
if [ -d "/var/lib/vaultwarden" ]; then if [ -d "/var/lib/vaultwarden" ]; then
tar -xzf bw_web_$VWRELEASE.tar.gz -C /var/lib/vaultwarden/ &>/dev/null tar -xzf bw_web_$VWRELEASE.tar.gz -C /var/lib/vaultwarden/ &>/dev/null
else else
tar -zxf bw_web_$VWRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null tar -zxf bw_web_$VWRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null
fi fi
echo -e "${GN} Cleaning up... ${CL}" echo -e "${GN} Cleaning up... ${CL}"

View File

@ -1,17 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
CM='\xE2\x9C\x94\033' CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
while true; do while true; do
read -p "This will Install Webmin, Proceed(y/n)?" yn read -p "This will Install Webmin, Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
@ -34,7 +34,6 @@ echo -en "${GN} Setting Default Webmin usermame & password to root... "
rm -rf /root/webmin_2.000_all.deb rm -rf /root/webmin_2.000_all.deb
echo -e "${CM}${CL} \r" echo -e "${CM}${CL} \r"
IP=$(hostname -I | cut -f1 -d ' ') IP=$(hostname -I | cut -f1 -d ' ')
echo -e "Successfully Installed!! Webmin should be reachable by going to https://${IP}:10000" echo -e "Successfully Installed!! Webmin should be reachable by going to https://${IP}:10000"
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/webmin.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/webmin.sh)"

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/z2m-copy-data.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/z2m-copy-data.sh)"
while true; do while true; do
read -p "Use to copy all data from one Zigbee2MQTT LXC to another. Proceed(y/n)?" yn read -p "Use to copy all data from one Zigbee2MQTT LXC to another. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
set -o errexit set -o errexit
set -o errtrace set -o errtrace
@ -58,28 +58,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Zigbee2MQTT LXC would you like to copy FROM?\n" \ "\nWhich Zigbee2MQTT LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Zigbee2MQTT LXC would you like to copy TO?\n" \ "\nWhich Zigbee2MQTT LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.01.23" 13 50 || exit Version: 2022.01.23" 13 50 || exit
info "Zigbee2MQTT Data from '$CTID_FROM' to '$CTID_TO'" info "Zigbee2MQTT Data from '$CTID_FROM' to '$CTID_TO'"
@ -89,13 +89,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then
fi fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DATA_PATH=/opt/zigbee2mqtt/data/ DATA_PATH=/opt/zigbee2mqtt/data/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DATA_PATH}" ] ||
die "Zigbee2igbee2MQTT directories in '$CTID_FROM' not found." die "Zigbee2igbee2MQTT directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \ [ -d "${CTID_TO_PATH}${DATA_PATH}" ] ||
die "Zigbee2MQTT directories in '$CTID_TO' not found." die "Zigbee2MQTT directories in '$CTID_TO' not found."
#rm -rf ${CTID_TO_PATH}${DATA_PATH} #rm -rf ${CTID_TO_PATH}${DATA_PATH}

View File

@ -3,12 +3,12 @@
# run from the Proxmox Shell # run from the Proxmox Shell
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/zwave-copy-data.sh)" # bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/zwave-copy-data.sh)"
while true; do while true; do
read -p "Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC. Proceed(y/n)?" yn read -p "Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
clear clear
set -o errexit set -o errexit
@ -59,28 +59,28 @@ while read -r line; do
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi fi
CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1') done < <(pct list | awk 'NR>1')
while [ -z "${CTID_FROM:+x}" ]; do while [ -z "${CTID_FROM:+x}" ]; do
CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ CTID_FROM=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Zwavejs2MQTT LXC would you like to copy FROM?\n" \ "\nWhich Zwavejs2MQTT LXC would you like to copy FROM?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
while [ -z "${CTID_TO:+x}" ]; do while [ -z "${CTID_TO:+x}" ]; do
CTID_TO=$(whiptail --title "$TITLE" --radiolist \ CTID_TO=$(whiptail --title "$TITLE" --radiolist \
"\nWhich Z-wave JS UI LXC would you like to copy TO?\n" \ "\nWhich Z-wave JS UI LXC would you like to copy TO?\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done done
for i in ${!CTID_MENU[@]}; do for i in ${!CTID_MENU[@]}; do
[ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] &&
CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
[ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ [ "${CTID_MENU[$i]}" == "$CTID_TO" ] &&
CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]})
done done
whiptail --defaultno --title "$TITLE" --yesno \ whiptail --defaultno --title "$TITLE" --yesno \
"Are you sure you want to copy data between the following LXCs? "Are you sure you want to copy data between the following LXCs?
$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME})
Version: 2022.09.21" 13 50 || exit Version: 2022.09.21" 13 50 || exit
info "Zwavejs2MQTT Data from '$CTID_FROM' to '$CTID_TO'" info "Zwavejs2MQTT Data from '$CTID_FROM' to '$CTID_TO'"
@ -91,13 +91,13 @@ fi
msg "Mounting Container Disks..." msg "Mounting Container Disks..."
DATA_PATH=/opt/zwavejs2mqtt/store/ DATA_PATH=/opt/zwavejs2mqtt/store/
DATA_PATH_NEW=/opt/zwave-js-ui/store/ DATA_PATH_NEW=/opt/zwave-js-ui/store/
CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." die "There was a problem mounting the root disk of LXC '${CTID_FROM}'."
[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ [ -d "${CTID_FROM_PATH}${DATA_PATH}" ] ||
die "Zwavejs2MQTT directories in '$CTID_FROM' not found." die "Zwavejs2MQTT directories in '$CTID_FROM' not found."
CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") ||
die "There was a problem mounting the root disk of LXC '${CTID_TO}'." die "There was a problem mounting the root disk of LXC '${CTID_TO}'."
[ -d "${CTID_TO_PATH}${DATA_PATH_NEW}" ] || \ [ -d "${CTID_TO_PATH}${DATA_PATH_NEW}" ] ||
die "Zwavejs2MQTT directories in '$CTID_TO' not found." die "Zwavejs2MQTT directories in '$CTID_TO' not found."
#rm -rf ${CTID_TO_PATH}${DATA_PATH} #rm -rf ${CTID_TO_PATH}${DATA_PATH}
@ -117,4 +117,3 @@ rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DATA_PATH} ${CTID_TO_PATH}${DATA_PA
echo -en "\e[1A\e[0K\e[1A\e[0K" echo -en "\e[1A\e[0K\e[1A\e[0K"
info "Successfully Transferred Data." info "Successfully Transferred Data."

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
set -e set -e
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
CM="${GN}${CL}" CM="${GN}${CL}"
CROSS="${RD}${CL}" CROSS="${RD}${CL}"
BFR="\\r\\033[K" BFR="\\r\\033[K"
@ -25,7 +25,7 @@ function msg_error() {
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
clear clear
cat << "EOF" cat <<"EOF"
_____ _______ __ ______ _____ _______ __ ______
/__ /_ ______ __ _____ / / ___/ / / / / _/ /__ /_ ______ __ _____ / / ___/ / / / / _/
/ /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // / / /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // /
@ -38,12 +38,15 @@ EOF
while true; do while true; do
read -p "This will update ZWave JS UI to $RELEASE. Proceed(y/n)?" yn read -p "This will update ZWave JS UI to $RELEASE. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]*) break ;;
[Nn]* ) exit;; [Nn]*) exit ;;
* ) echo "Please answer yes or no.";; *) echo "Please answer yes or no." ;;
esac esac
done done
if [ ! -d /opt/zwave-js-ui ]; then msg_error "No Zwave JS UI Install Detected!"; exit; fi if [ ! -d /opt/zwave-js-ui ]; then
msg_error "No Zwave JS UI Install Detected!"
exit
fi
msg_info "Stopping Z-wave JS UI" msg_info "Stopping Z-wave JS UI"
systemctl stop zwave-js-ui.service systemctl stop zwave-js-ui.service
@ -56,7 +59,7 @@ unzip zwave-js-ui-${RELEASE}-linux.zip &>/dev/null
msg_ok "Updated Z-wave JS UI" msg_ok "Updated Z-wave JS UI"
msg_info "Updating Z-wave JS UI service file" msg_info "Updating Z-wave JS UI service file"
cat << EOF > /etc/systemd/system/zwave-js-ui.service cat <<EOF >/etc/systemd/system/zwave-js-ui.service
[Unit] [Unit]
Description=zwave-js-ui Description=zwave-js-ui
Wants=network-online.target Wants=network-online.target

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YW=`echo "\033[33m"` YW=$(echo "\033[33m")
RD=`echo "\033[01;31m"` RD=$(echo "\033[01;31m")
BL=`echo "\033[36m"` BL=$(echo "\033[36m")
GN=`echo "\033[1;92m"` GN=$(echo "\033[1;92m")
CL=`echo "\033[m"` CL=$(echo "\033[m")
RETRY_NUM=10 RETRY_NUM=10
RETRY_EVERY=3 RETRY_EVERY=3
NUM=$RETRY_NUM NUM=$RETRY_NUM
@ -29,30 +29,29 @@ function error_exit() {
} }
function msg_info() { 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}"
} }
msg_info "Setting up Container OS " msg_info "Setting up Container OS "
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
locale-gen >/dev/null locale-gen >/dev/null
while [ "$(hostname -I)" = "" ]; do while [ "$(hostname -I)" = "" ]; do
1>&2 echo -en "${CROSS}${RD} No Network! " echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY sleep $RETRY_EVERY
((NUM--)) ((NUM--))
if [ $NUM -eq 0 ] if [ $NUM -eq 0 ]; then
then echo 1>&2 -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
exit 1 exit 1
fi fi
done done
@ -61,9 +60,12 @@ msg_ok "Network Connected: ${BL}$(hostname -I)"
set +e set +e
alias die='' alias die=''
if nc -zw1 8.8.8.8 443; then msg_ok "Internet Connected"; else msg_error "Internet NOT Connected"; exit 1; fi; if nc -zw1 8.8.8.8 443; then msg_ok "Internet Connected"; else
msg_error "Internet NOT Connected"
exit 1
fi
RESOLVEDIP=$(nslookup "github.com" | awk -F':' '/^Address: / { matched = 1 } matched { print $2}' | xargs) RESOLVEDIP=$(nslookup "github.com" | awk -F':' '/^Address: / { matched = 1 } matched { print $2}' | xargs)
if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to $RESOLVEDIP"; fi; if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to $RESOLVEDIP"; fi
alias die='EXIT=$? LINE=$LINENO error_exit' alias die='EXIT=$? LINE=$LINENO error_exit'
set -e set -e
@ -81,23 +83,23 @@ msg_info "Installing AdGuard Home"
curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh &>/dev/null curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh &>/dev/null
msg_ok "Installed AdGuard Home" msg_ok "Installed AdGuard Home"
PASS=$(grep -w "root" /etc/shadow | cut -b6); PASS=$(grep -w "root" /etc/shadow | cut -b6)
if [[ $PASS != $ ]]; then if [[ $PASS != $ ]]; then
msg_info "Customizing Container" msg_info "Customizing Container"
rm /etc/motd rm /etc/motd
rm /etc/update-motd.d/10-uname rm /etc/update-motd.d/10-uname
touch ~/.hushlogin touch ~/.hushlogin
GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf"
mkdir -p $(dirname $GETTY_OVERRIDE) mkdir -p $(dirname $GETTY_OVERRIDE)
cat << EOF > $GETTY_OVERRIDE cat <<EOF >$GETTY_OVERRIDE
[Service] [Service]
ExecStart= ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM
EOF EOF
systemctl daemon-reload systemctl daemon-reload
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
msg_ok "Customized Container" msg_ok "Customized Container"
fi fi
msg_info "Cleaning up" msg_info "Cleaning up"
apt-get autoremove >/dev/null apt-get autoremove >/dev/null

Some files were not shown because too many files have changed in this diff Show More