mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-06-29 02:27:37 +00:00
Massive Update: build.func | install.func | create_lxc.sh (Part 1) (#643)
* Big Update: Build.func Install.Func Create_LXC * Change Author Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Fix indentation / naming / echos * Fix some Parts * Add alpine-install.func * update alpine to 3.20 * fix spaces * Update build.func * Merge Create_LXC from DEV * Merge from DEV * Merge from DEV --------- Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com>
This commit is contained in:
359
misc/build.func
359
misc/build.func
@ -1,3 +1,9 @@
|
||||
# Copyright (c) 2021-2024 tteck
|
||||
# Author: tteck (tteckster)
|
||||
# Co-Author: MickLesk
|
||||
# License: MIT
|
||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
|
||||
variables() {
|
||||
NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
|
||||
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
||||
@ -6,6 +12,7 @@ variables() {
|
||||
|
||||
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||
color() {
|
||||
# Colors
|
||||
YW=$(echo "\033[33m")
|
||||
YWB=$(echo "\033[93m")
|
||||
BL=$(echo "\033[36m")
|
||||
@ -13,11 +20,39 @@ color() {
|
||||
BGN=$(echo "\033[4;92m")
|
||||
GN=$(echo "\033[1;92m")
|
||||
DGN=$(echo "\033[32m")
|
||||
|
||||
# Formatting
|
||||
CL=$(echo "\033[m")
|
||||
CM="${GN}✓${CL}"
|
||||
CROSS="${RD}✗${CL}"
|
||||
UL=$(echo "\033[4m")
|
||||
BOLD=$(echo "\033[1m")
|
||||
BFR="\\r\\033[K"
|
||||
HOLD=" "
|
||||
TAB=" "
|
||||
|
||||
# Icons
|
||||
CM="${TAB}✔️${TAB}${CL}"
|
||||
CROSS="${TAB}✖️${TAB}${CL}"
|
||||
INFO="${TAB}💡${TAB}${CL}"
|
||||
OS="${TAB}🖥️${TAB}${CL}"
|
||||
OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||
CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
||||
DISKSIZE="${TAB}💾${TAB}${CL}"
|
||||
CPUCORE="${TAB}🧠${TAB}${CL}"
|
||||
RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
||||
SEARCH="${TAB}🔍${TAB}${CL}"
|
||||
VERIFYPW="${TAB}🔐${TAB}${CL}"
|
||||
CONTAINERID="${TAB}🆔${TAB}${CL}"
|
||||
HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||
BRIDGE="${TAB}🌉${TAB}${CL}"
|
||||
NETWORK="${TAB}📡${TAB}${CL}"
|
||||
GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||
CREATING="${TAB}🚀${TAB}${CL}"
|
||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||
}
|
||||
|
||||
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
||||
@ -39,19 +74,24 @@ error_handler() {
|
||||
|
||||
# This function displays a spinner.
|
||||
spinner() {
|
||||
local chars="/-\|"
|
||||
local spin_i=0
|
||||
printf "\e[?25l"
|
||||
while true; do
|
||||
printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}"
|
||||
sleep 0.1
|
||||
done
|
||||
local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
|
||||
local spin_i=0
|
||||
local interval=0.1
|
||||
printf "\e[?25l"
|
||||
|
||||
local color="${YWB}"
|
||||
|
||||
while true; do
|
||||
printf "\r ${color}%s${CL}" "${frames[spin_i]}"
|
||||
spin_i=$(( (spin_i + 1) % ${#frames[@]} ))
|
||||
sleep "$interval"
|
||||
done
|
||||
}
|
||||
|
||||
# This function displays an informational message with a yellow color.
|
||||
msg_info() {
|
||||
local msg="$1"
|
||||
echo -ne " ${HOLD} ${YW}${msg} "
|
||||
echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
|
||||
spinner &
|
||||
SPINNER_PID=$!
|
||||
}
|
||||
@ -61,7 +101,7 @@ msg_ok() {
|
||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
|
||||
printf "\e[?25h"
|
||||
local msg="$1"
|
||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||
echo -e "${BFR}${CM}${GN}${msg}${CL}"
|
||||
}
|
||||
|
||||
# This function displays a error message with a red color.
|
||||
@ -69,7 +109,7 @@ msg_error() {
|
||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
|
||||
printf "\e[?25h"
|
||||
local msg="$1"
|
||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||
echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
|
||||
}
|
||||
|
||||
# Check if the shell is using bash
|
||||
@ -97,7 +137,7 @@ root_check() {
|
||||
# This function checks the version of Proxmox Virtual Environment (PVE) and exits if the version is not supported.
|
||||
pve_check() {
|
||||
if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then
|
||||
msg_error "This version of Proxmox Virtual Environment is not supported"
|
||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
||||
echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
|
||||
echo -e "Exiting..."
|
||||
sleep 2
|
||||
@ -108,17 +148,27 @@ fi
|
||||
# This function checks the system architecture and exits if it's not "amd64".
|
||||
arch_check() {
|
||||
if [ "$(dpkg --print-architecture)" != "amd64" ]; then
|
||||
echo -e "\n ${CROSS} This script will not work with PiMox! \n"
|
||||
echo -e "\n Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n"
|
||||
echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n"
|
||||
echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n"
|
||||
echo -e "Exiting..."
|
||||
sleep 2
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
|
||||
header_info() {
|
||||
apt-get install -y figlet &> /dev/null
|
||||
ascii_art=$(figlet -f slant "$APP")
|
||||
clear
|
||||
cat <<EOF
|
||||
$ascii_art
|
||||
EOF
|
||||
}
|
||||
|
||||
# This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit.
|
||||
ssh_check() {
|
||||
if command -v pveversion >/dev/null 2>&1 && [ -n "${SSH_CLIENT:+x}" ]; then
|
||||
if [ -n "${SSH_CLIENT:+x}" ]; then
|
||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's advisable to utilize the Proxmox shell rather than SSH, as there may be potential complications with variable retrieval. Proceed using SSH?" 10 72; then
|
||||
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Proceed using SSH" "You've chosen to proceed using SSH. If any issues arise, please run the script in the Proxmox shell before creating a repository issue." 10 72
|
||||
else
|
||||
@ -129,36 +179,74 @@ ssh_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
base_settings() {
|
||||
# Default Settings
|
||||
CT_TYPE="1"
|
||||
DISK_SIZE="4"
|
||||
CORE_COUNT="1"
|
||||
RAM_SIZE="1024"
|
||||
VERBOSE="${1:-no}"
|
||||
PW=""
|
||||
CT_ID=$NEXTID
|
||||
HN=$NSAPP
|
||||
BRG="vmbr0"
|
||||
NET="dhcp"
|
||||
GATE=""
|
||||
APT_CACHER=""
|
||||
APT_CACHER_IP=""
|
||||
DISABLEIP6="no"
|
||||
MTU=""
|
||||
SD=""
|
||||
NS=""
|
||||
MAC=""
|
||||
VLAN=""
|
||||
SSH="no"
|
||||
TAGS="community-script;"
|
||||
|
||||
# Override default settings with variables from ct script
|
||||
CT_TYPE=${var_privileged:-$CT_TYPE}
|
||||
DISK_SIZE=${var_disk:-$DISK_SIZE}
|
||||
CORE_COUNT=${var_cpu:-$CORE_COUNT}
|
||||
RAM_SIZE=${var_ram:-$RAM_SIZE}
|
||||
VERB=${var_verbose:-$VERBOSE}
|
||||
TAGS="${TAGS}${var_tags:-}"
|
||||
|
||||
# Since these 2 are only defined outside of default_settings function, we add a temporary fallback. TODO: To align everything, we should add these as constant variables (e.g. OSTYPE and OSVERSION), but that would currently require updating the default_settings function for all existing scripts
|
||||
if [ -z "$var_os" ]; then
|
||||
var_os="debian"
|
||||
fi
|
||||
if [ -z "$var_version" ]; then
|
||||
var_version="12"
|
||||
fi
|
||||
}
|
||||
|
||||
# This function displays the default values for various settings.
|
||||
echo_default() {
|
||||
echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}"
|
||||
echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
|
||||
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
|
||||
echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
|
||||
echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
|
||||
echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
|
||||
echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
||||
echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
|
||||
echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
|
||||
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
|
||||
echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
|
||||
echo -e "${DGN}Using Gateway IP Address: ${BGN}Default${CL}"
|
||||
echo -e "${DGN}Using Apt-Cacher IP Address: ${BGN}Default${CL}"
|
||||
echo -e "${DGN}Disable IPv6: ${BGN}No${CL}"
|
||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
|
||||
echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}"
|
||||
echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}"
|
||||
echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
|
||||
echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
|
||||
echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}"
|
||||
echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
|
||||
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
|
||||
# Convert CT_TYPE to description
|
||||
CT_TYPE_DESC="Unprivileged"
|
||||
if [ "$CT_TYPE" -eq 0 ]; then
|
||||
CT_TYPE_DESC="Privileged"
|
||||
fi
|
||||
|
||||
# Output the selected values with icons
|
||||
echo -e "${OS}${BOLD}${DGN}Operating System: ${BGN}$var_os${CL}"
|
||||
echo -e "${OSVERSION}${BOLD}${DGN}Version: ${BGN}$var_version${CL}"
|
||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Container Type: ${BGN}$CT_TYPE_DESC${CL}"
|
||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}GB${CL}"
|
||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}"
|
||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE}MB${CL}"
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}${CT_ID}${CL}"
|
||||
if [ "$VERB" == "yes" ]; then
|
||||
echo -e "${SEARCH}${BOLD}${DGN}Verbose Mode: ${BGN}Enabled${CL}"
|
||||
fi
|
||||
echo -e "${CREATING}${BOLD}${BL}Creating a ${APP} LXC using the above default settings${CL}"
|
||||
echo -e " "
|
||||
}
|
||||
|
||||
# This function is called when the user decides to exit the script. It clears the screen and displays an exit message.
|
||||
exit-script() {
|
||||
exit_script() {
|
||||
clear
|
||||
echo -e "⚠ User exited script \n"
|
||||
echo -e "\n${CROSS}${RD}User exited script${CL}\n"
|
||||
exit
|
||||
}
|
||||
|
||||
@ -174,10 +262,10 @@ advanced_settings() {
|
||||
"ubuntu" "" OFF \
|
||||
3>&1 1>&2 2>&3); then
|
||||
if [ -n "$var_os" ]; then
|
||||
echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}"
|
||||
echo -e "${OS}${BOLD}${DGN}Operating System: ${BGN}$var_os${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -190,10 +278,10 @@ advanced_settings() {
|
||||
"12" "Bookworm" OFF \
|
||||
3>&1 1>&2 2>&3); then
|
||||
if [ -n "$var_version" ]; then
|
||||
echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
|
||||
echo -e "${OSVERSION}${BOLD}${DGN}Version: ${BGN}$var_version${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -201,20 +289,24 @@ advanced_settings() {
|
||||
if [ "$var_os" == "ubuntu" ]; then
|
||||
var_version=""
|
||||
while [ -z "$var_version" ]; do
|
||||
if var_version=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \
|
||||
if var_version=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \
|
||||
"20.04" "Focal" OFF \
|
||||
"22.04" "Jammy" OFF \
|
||||
"24.04" "Noble" OFF \
|
||||
3>&1 1>&2 2>&3); then
|
||||
"24.10" "Oracular" OFF \
|
||||
3>&1 1>&2 2>&3); then
|
||||
if [ -n "$var_version" ]; then
|
||||
echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
|
||||
echo -e "${OSVERSION}${BOLD}${DGN}Version: ${BGN}$var_version${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Setting Default Tag for Advanced Settings
|
||||
TAGS="community-script;"
|
||||
|
||||
CT_TYPE=""
|
||||
while [ -z "$CT_TYPE" ]; do
|
||||
if CT_TYPE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \
|
||||
@ -222,10 +314,14 @@ advanced_settings() {
|
||||
"0" "Privileged" OFF \
|
||||
3>&1 1>&2 2>&3); then
|
||||
if [ -n "$CT_TYPE" ]; then
|
||||
echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
|
||||
CT_TYPE_DESC="Unprivileged"
|
||||
if [ "$CT_TYPE" -eq 0 ]; then
|
||||
CT_TYPE_DESC="Privileged"
|
||||
fi
|
||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Container Type: ${BGN}$CT_TYPE_DESC${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
|
||||
@ -240,23 +336,23 @@ advanced_settings() {
|
||||
if PW2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "\nVerify Root Password" 9 58 --title "PASSWORD VERIFICATION" 3>&1 1>&2 2>&3); then
|
||||
if [[ "$PW1" == "$PW2" ]]; then
|
||||
PW="-password $PW1"
|
||||
echo -e "${DGN}Using Root Password: ${BGN}********${CL}"
|
||||
echo -e "${VERIFYPW}${BOLD}${DGN}Root Password: ${BGN}********${CL}"
|
||||
break
|
||||
else
|
||||
whiptail --msgbox "Passwords do not match. Please try again." 8 58
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
fi
|
||||
else
|
||||
PW1="Automatic Login"
|
||||
PW=""
|
||||
echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
|
||||
echo -e "${VERIFYPW}${BOLD}${DGN}Root Password: ${BGN}$PW1${CL}"
|
||||
break
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
|
||||
@ -264,9 +360,9 @@ advanced_settings() {
|
||||
if CT_ID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$CT_ID" ]; then
|
||||
CT_ID="$NEXTID"
|
||||
echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
else
|
||||
echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
fi
|
||||
else
|
||||
exit
|
||||
@ -278,57 +374,57 @@ advanced_settings() {
|
||||
else
|
||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
||||
fi
|
||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if DISK_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$DISK_SIZE" ]; then
|
||||
DISK_SIZE="$var_disk"
|
||||
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
|
||||
echo -e "${DISKSIZE}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}"
|
||||
else
|
||||
if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
|
||||
echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}"
|
||||
echo -e "{INFO}${HOLD}${RD} DISK SIZE MUST BE AN INTEGER NUMBER!${CL}"
|
||||
advanced_settings
|
||||
fi
|
||||
echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
|
||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$CORE_COUNT" ]; then
|
||||
CORE_COUNT="$var_cpu"
|
||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
||||
else
|
||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$RAM_SIZE" ]; then
|
||||
RAM_SIZE="$var_ram"
|
||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
||||
else
|
||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$BRG" ]; then
|
||||
BRG="vmbr0"
|
||||
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
||||
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
||||
else
|
||||
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
||||
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
while true; do
|
||||
@ -336,18 +432,18 @@ advanced_settings() {
|
||||
exit_status=$?
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
if [ "$NET" = "dhcp" ]; then
|
||||
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
|
||||
echo -e "${NETWORK}${BOLD}${DGN}IP Address: ${BGN}$NET${CL}"
|
||||
break
|
||||
else
|
||||
if [[ "$NET" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/([0-9]|[1-2][0-9]|3[0-2])$ ]]; then
|
||||
echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
|
||||
echo -e "${NETWORK}${BOLD}${DGN}IP Address: ${BGN}$NET${CL}"
|
||||
break
|
||||
else
|
||||
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "$NET is an invalid IPv4 CIDR address. Please enter a valid IPv4 CIDR address or 'dhcp'" 8 58
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
|
||||
@ -360,13 +456,13 @@ advanced_settings() {
|
||||
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "Invalid IP address format" 8 58
|
||||
else
|
||||
GATE=",gw=$GATE1"
|
||||
echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
|
||||
echo -e "${GATEWAY}${BOLD}${DGN}Gateway IP Address: ${BGN}$GATE1${CL}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
GATE=""
|
||||
echo -e "${DGN}Using Gateway IP Address: ${BGN}Default${CL}"
|
||||
echo -e "${GATEWAY}${BOLD}${DGN}Gateway IP Address: ${BGN}Default${CL}"
|
||||
fi
|
||||
|
||||
if [ "$var_os" == "alpine" ]; then
|
||||
@ -375,9 +471,9 @@ advanced_settings() {
|
||||
else
|
||||
if APT_CACHER_IP=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set APT-Cacher IP (leave blank for default)" 8 58 --title "APT-Cacher IP" 3>&1 1>&2 2>&3); then
|
||||
APT_CACHER="${APT_CACHER_IP:+yes}"
|
||||
echo -e "${DGN}Using APT-Cacher IP Address: ${BGN}${APT_CACHER_IP:-Default}${CL}"
|
||||
echo -e "${NETWORK}${BOLD}${DGN}APT-Cacher IP Address: ${BGN}${APT_CACHER_IP:-Default}${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -386,7 +482,7 @@ advanced_settings() {
|
||||
else
|
||||
DISABLEIP6="no"
|
||||
fi
|
||||
echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}"
|
||||
echo -e "${DISABLEIPV6}${BOLD}${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}"
|
||||
|
||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then
|
||||
if [ -z $MTU1 ]; then
|
||||
@ -395,9 +491,9 @@ advanced_settings() {
|
||||
else
|
||||
MTU=",mtu=$MTU1"
|
||||
fi
|
||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if SD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then
|
||||
@ -408,9 +504,9 @@ advanced_settings() {
|
||||
SX=$SD
|
||||
SD="-searchdomain=$SD"
|
||||
fi
|
||||
echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}"
|
||||
echo -e "${SEARCH}${BOLD}${DGN}DNS Search Domain: ${BGN}$SX${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if NX=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then
|
||||
@ -420,9 +516,9 @@ advanced_settings() {
|
||||
else
|
||||
NS="-nameserver=$NX"
|
||||
fi
|
||||
echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}"
|
||||
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}$NX${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
|
||||
@ -431,10 +527,10 @@ advanced_settings() {
|
||||
MAC=""
|
||||
else
|
||||
MAC=",hwaddr=$MAC1"
|
||||
echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
|
||||
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC1${CL}"
|
||||
fi
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then
|
||||
@ -444,9 +540,9 @@ advanced_settings() {
|
||||
else
|
||||
VLAN=",tag=$VLAN1"
|
||||
fi
|
||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}$VLAN1${CL}"
|
||||
else
|
||||
exit-script
|
||||
exit_script
|
||||
fi
|
||||
|
||||
if [[ "$PW" == -password* ]]; then
|
||||
@ -455,10 +551,10 @@ advanced_settings() {
|
||||
else
|
||||
SSH="no"
|
||||
fi
|
||||
echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}"
|
||||
echo -e "${ROOTSSH}${BOLD}${DGN}Root SSH Access: ${BGN}$SSH${CL}"
|
||||
else
|
||||
SSH="no"
|
||||
echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}"
|
||||
echo -e "${ROOTSSH}${BOLD}${DGN}Root SSH Access: ${BGN}$SSH${CL}"
|
||||
fi
|
||||
|
||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
|
||||
@ -466,14 +562,14 @@ advanced_settings() {
|
||||
else
|
||||
VERB="no"
|
||||
fi
|
||||
echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}"
|
||||
echo -e "${SEARCH}${BOLD}${DGN}Verbose Mode: ${BGN}$VERB${CL}"
|
||||
|
||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then
|
||||
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
||||
echo -e "${CREATING}${BOLD}${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
||||
else
|
||||
clear
|
||||
header_info
|
||||
echo -e "${RD}Using Advanced Settings${CL}"
|
||||
echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}"
|
||||
advanced_settings
|
||||
fi
|
||||
}
|
||||
@ -491,15 +587,51 @@ install_script() {
|
||||
NEXTID=$(pvesh get /cluster/nextid)
|
||||
timezone=$(cat /etc/timezone)
|
||||
header_info
|
||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
||||
header_info
|
||||
echo -e "${BL}Using Default Settings${CL}"
|
||||
default_settings
|
||||
else
|
||||
header_info
|
||||
echo -e "${RD}Using Advanced Settings${CL}"
|
||||
advanced_settings
|
||||
fi
|
||||
while true; do
|
||||
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --menu "Choose an option:" \
|
||||
12 50 4 \
|
||||
"1" "Default Settings" \
|
||||
"2" "Default Settings (with verbose)" \
|
||||
"3" "Advanced Settings" \
|
||||
"4" "Exit" --nocancel --default-item "1" 3>&1 1>&2 2>&3)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${CROSS}${RD} Menu canceled. Exiting.${CL}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case $CHOICE in
|
||||
1)
|
||||
header_info
|
||||
echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings${CL}"
|
||||
VERB="no"
|
||||
base_settings "$VERB"
|
||||
echo_default
|
||||
break
|
||||
;;
|
||||
2)
|
||||
header_info
|
||||
echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings (${SEARCH} Verbose)${CL}"
|
||||
VERB="yes"
|
||||
base_settings "$VERB"
|
||||
echo_default
|
||||
break
|
||||
;;
|
||||
3)
|
||||
header_info
|
||||
echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}"
|
||||
advanced_settings
|
||||
break
|
||||
;;
|
||||
4)
|
||||
echo -e "${CROSS}${RD}Exiting.${CL}"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${CROSS}${RD}Invalid option, please try again.${CL}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
check_container_resources() {
|
||||
@ -509,9 +641,14 @@ check_container_resources() {
|
||||
|
||||
# Check whether the current RAM is less than the required RAM or the CPU cores are less than required
|
||||
if [[ "$current_ram" -lt "$var_ram" ]] || [[ "$current_cpu" -lt "$var_cpu" ]]; then
|
||||
echo -e "\n⚠️${HOLD} ${GN}Required: ${var_cpu} CPU, ${var_ram}MB RAM ${CL}| ${RD}Current: ${current_cpu} CPU, ${current_ram}MB RAM${CL}"
|
||||
echo -e "\n${INFO}${HOLD} ${GN}Required: ${var_cpu} CPU, ${var_ram}MB RAM ${CL}| ${RD}Current: ${current_cpu} CPU, ${current_ram}MB RAM${CL}"
|
||||
echo -e "${YWB}Please ensure that the ${APP} LXC is configured with at least ${var_cpu} vCPU and ${var_ram} MB RAM for the build process.${CL}\n"
|
||||
exit 1
|
||||
read -r -p "${INFO}${HOLD} May cause data loss! ${INFO} Continue update with under-provisioned LXC? <yes/No> " prompt
|
||||
# Check if the input is 'yes', otherwise exit with status 1
|
||||
if [[ ! ${prompt,,} =~ ^(yes)$ ]]; then
|
||||
echo -e "${CROSS}${HOLD} ${YWB}Exiting based on user input.${CL}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e ""
|
||||
fi
|
||||
@ -524,11 +661,11 @@ check_container_storage() {
|
||||
usage=$(( 100 * used_size / total_size ))
|
||||
if (( usage > 80 )); then
|
||||
# Prompt the user for confirmation to continue
|
||||
echo -e "⚠️${HOLD} ${YWB}Warning: Storage is dangerously low (${usage}%).${CL}"
|
||||
echo -e "${INFO}${HOLD} ${YWB}Warning: Storage is dangerously low (${usage}%).${CL}"
|
||||
read -r -p "Continue anyway? <y/N> " prompt
|
||||
# Check if the input is 'y' or 'yes', otherwise exit with status 1
|
||||
if [[ ! ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||
echo -e "❌${HOLD} ${YWB}Exiting based on user input.${CL}"
|
||||
echo -e "${CROSS}${HOLD}${YWB}Exiting based on user input.${CL}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@ -538,7 +675,7 @@ start() {
|
||||
if command -v pveversion >/dev/null 2>&1; then
|
||||
if ! (whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
|
||||
clear
|
||||
echo -e "⚠ User exited script \n"
|
||||
exit_script
|
||||
exit
|
||||
fi
|
||||
SPINNER_PID=""
|
||||
@ -548,7 +685,7 @@ start() {
|
||||
if ! command -v pveversion >/dev/null 2>&1; then
|
||||
if ! (whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC UPDATE" --yesno "Support/Update functions for ${APP} LXC. Proceed?" 10 58); then
|
||||
clear
|
||||
echo -e "⚠ User exited script \n"
|
||||
exit_script
|
||||
exit
|
||||
fi
|
||||
SPINNER_PID=""
|
||||
@ -591,7 +728,7 @@ build_container() {
|
||||
export PCT_OPTIONS="
|
||||
-features $FEATURES
|
||||
-hostname $HN
|
||||
-tags proxmox-helper-scripts
|
||||
-tags $TAGS
|
||||
$SD
|
||||
$NS
|
||||
-net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU
|
||||
@ -661,8 +798,6 @@ EOF
|
||||
pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories
|
||||
http://dl-cdn.alpinelinux.org/alpine/latest-stable/main
|
||||
http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
|
||||
#http://dl-cdn.alpinelinux.org/alpine/v3.19/main
|
||||
#http://dl-cdn.alpinelinux.org/alpine/v3.19/community
|
||||
EOF'
|
||||
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user