Update build.func
This commit is contained in:
parent
668d711af2
commit
c0b109c1fe
@ -12,11 +12,10 @@ variables() {
|
|||||||
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
||||||
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
||||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable.
|
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable.
|
||||||
CT_TYPE="${CT_TYPE:-$var_unprivileged}" # Set an global environment variable for the container type.
|
CT_TYPE="${CT_TYPE:-$var_unprivileged}" # Set an environment variable for the container type.
|
||||||
#ENABLE_FUSE="${ENABLE_FUSE:-no}" # Set an global environment variable for enabling FUSE.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
||||||
|
|
||||||
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||||
color() {
|
color() {
|
||||||
@ -61,27 +60,29 @@ color() {
|
|||||||
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||||
CREATING="${TAB}🚀${TAB}${CL}"
|
CREATING="${TAB}🚀${TAB}${CL}"
|
||||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||||
#FUSE="${TAB}🔧${TAB}${CL}"
|
CIFS="${TAB}🔌${TAB}${CL}"
|
||||||
|
FUSE="${TAB}🔧${TAB}${CL}"
|
||||||
|
NFS="${TAB}📂${TAB}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
||||||
#catch_errors() {
|
catch_errors() {
|
||||||
# set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
# trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
#}
|
}
|
||||||
|
|
||||||
# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message.
|
# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message.
|
||||||
error_handler() {
|
error_handler() {
|
||||||
#source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
||||||
printf "\e[?25h"
|
printf "\e[?25h"
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
#local line_number="$1"
|
local line_number="$1"
|
||||||
#local command="$2"
|
local command="$2"
|
||||||
#local error_description="$(get_error_description "$exit_code")"
|
local error_description="$(get_error_description "$exit_code")"
|
||||||
#local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL} (${YW}$error_description${CL}): while executing command ${YW}$command${CL}"
|
local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL} (${YW}$error_description${CL}): while executing command ${YW}$command${CL}"
|
||||||
#post_update_to_api "failed" "$exit_code" "$error_description"
|
post_update_to_api "failed" "$exit_code" "$error_description"
|
||||||
#echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays an informational message with logging support.
|
# This function displays an informational message with logging support.
|
||||||
@ -337,8 +338,8 @@ base_settings() {
|
|||||||
HN=$NSAPP
|
HN=$NSAPP
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
NET="dhcp"
|
NET="dhcp"
|
||||||
#IPv6="dhcp"
|
IPv6="dhcp"
|
||||||
#IPv6GW=""
|
IPv6GW=""
|
||||||
GATE=""
|
GATE=""
|
||||||
APT_CACHER=""
|
APT_CACHER=""
|
||||||
APT_CACHER_IP=""
|
APT_CACHER_IP=""
|
||||||
@ -351,7 +352,9 @@ base_settings() {
|
|||||||
SSH="no"
|
SSH="no"
|
||||||
SSH_AUTHORIZED_KEY=""
|
SSH_AUTHORIZED_KEY=""
|
||||||
TAGS="community-script-dev;"
|
TAGS="community-script-dev;"
|
||||||
#ENABLE_FUSE="no"
|
ENABLE_NFS="no"
|
||||||
|
ENABLE_CIFS="no"
|
||||||
|
ENABLE_FUSE="no"
|
||||||
|
|
||||||
# Override default settings with variables from ct script
|
# Override default settings with variables from ct script
|
||||||
CT_TYPE=${var_unprivileged:-$CT_TYPE}
|
CT_TYPE=${var_unprivileged:-$CT_TYPE}
|
||||||
@ -360,7 +363,7 @@ base_settings() {
|
|||||||
RAM_SIZE=${var_ram:-$RAM_SIZE}
|
RAM_SIZE=${var_ram:-$RAM_SIZE}
|
||||||
VERB=${var_verbose:-$VERBOSE}
|
VERB=${var_verbose:-$VERBOSE}
|
||||||
TAGS="${TAGS}${var_tags:-}"
|
TAGS="${TAGS}${var_tags:-}"
|
||||||
#ENABLE_FUSE="${var_fuse:-${ENABLE_FUSE:-no}}"
|
ENABLE_FUSE=${var_fuse:-$ENABLE_FUSE}
|
||||||
|
|
||||||
# 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
|
# 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
|
if [ -z "$var_os" ]; then
|
||||||
@ -1355,18 +1358,18 @@ check_container_storage() {
|
|||||||
start() {
|
start() {
|
||||||
LOGDIR="/usr/local/community-scripts/logs"
|
LOGDIR="/usr/local/community-scripts/logs"
|
||||||
mkdir -p "$LOGDIR"
|
mkdir -p "$LOGDIR"
|
||||||
|
if [ -f /etc/alpine-release ]; then
|
||||||
|
echo "Running on Alpine Linux – minimal update process."
|
||||||
|
update_script
|
||||||
|
fi
|
||||||
if command -v pveversion >/dev/null 2>&1; then
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
if ! (whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
|
if ! (whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
|
||||||
clear
|
clear
|
||||||
exit_script
|
exit_script
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
SPINNER_PID=""
|
|
||||||
install_script
|
install_script
|
||||||
fi
|
else
|
||||||
|
|
||||||
if ! command -v pveversion >/dev/null 2>&1; then
|
|
||||||
CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \
|
CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \
|
||||||
"Support/Update functions for ${APP} LXC. Choose an option:" \
|
"Support/Update functions for ${APP} LXC. Choose an option:" \
|
||||||
12 60 3 \
|
12 60 3 \
|
||||||
@ -1408,15 +1411,15 @@ build_container() {
|
|||||||
FEATURES="nesting=1"
|
FEATURES="nesting=1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#if [ "$ENABLE_FUSE" == "yes" ]; then
|
if [ "$ENABLE_FUSE" == "yes" ]; then
|
||||||
# FEATURES+=",fuse=1"
|
FEATURES+=",fuse=1"
|
||||||
#fi
|
fi
|
||||||
|
|
||||||
#if [[ $DIAGNOSTICS == "yes" ]]; then
|
if [[ $DIAGNOSTICS == "yes" ]]; then
|
||||||
# post_to_api
|
post_to_api
|
||||||
#fi
|
fi
|
||||||
|
|
||||||
#FEATURES="${FEATURES#,}"
|
FEATURES="${FEATURES#,}"
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if [ "$var_os" == "alpine" ]; then
|
if [ "$var_os" == "alpine" ]; then
|
||||||
@ -1440,6 +1443,7 @@ build_container() {
|
|||||||
export PCT_OSTYPE="$var_os"
|
export PCT_OSTYPE="$var_os"
|
||||||
export PCT_OSVERSION="$var_version"
|
export PCT_OSVERSION="$var_version"
|
||||||
export PCT_DISK_SIZE="$DISK_SIZE"
|
export PCT_DISK_SIZE="$DISK_SIZE"
|
||||||
|
export IPv6="$IPv6"
|
||||||
export PCT_OPTIONS="
|
export PCT_OPTIONS="
|
||||||
-features $FEATURES
|
-features $FEATURES
|
||||||
-hostname $HN
|
-hostname $HN
|
||||||
@ -1517,7 +1521,7 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
|
|||||||
EOF'
|
EOF'
|
||||||
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
||||||
fi
|
fi
|
||||||
lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || exit $?
|
lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || exit $?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1564,7 +1568,7 @@ EOF
|
|||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_std_mode() {
|
set_std_mode() {
|
||||||
@ -1586,11 +1590,10 @@ silent() {
|
|||||||
|
|
||||||
exit_script() {
|
exit_script() {
|
||||||
exit_code=$? # Capture exit status
|
exit_code=$? # Capture exit status
|
||||||
#post_update_to_api "failed" "$exit_code"
|
post_update_to_api "failed" "$exit_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
trap 'exit_script' EXIT
|
trap 'exit_script' EXIT
|
||||||
#trap 'post_update_to_api "failed" "2"' ERR
|
trap 'post_update_to_api "failed" "2"' ERR
|
||||||
#trap 'post_update_to_api "failed" "130"' SIGINT
|
trap 'post_update_to_api "failed" "130"' SIGINT
|
||||||
#trap 'post_update_to_api "failed" "143"' SIGTERM
|
trap 'post_update_to_api "failed" "143"' SIGTERM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user