From c0b109c1fe6eda037dc21b899e87688d7c7b7e23 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 26 Mar 2025 10:20:52 +0100 Subject: [PATCH] Update build.func --- misc/build.func | 79 +++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/misc/build.func b/misc/build.func index 9c2216c..3f0839a 100644 --- a/misc/build.func +++ b/misc/build.func @@ -12,11 +12,10 @@ variables() { 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. 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. - #ENABLE_FUSE="${ENABLE_FUSE:-no}" # Set an global environment variable for enabling FUSE. + CT_TYPE="${CT_TYPE:-$var_unprivileged}" # Set an environment variable for the container type. } -#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. color() { @@ -61,27 +60,29 @@ color() { ROOTSSH="${TAB}🔑${TAB}${CL}" CREATING="${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. -#catch_errors() { -# set -Eeuo pipefail -# trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -#} +catch_errors() { + set -Eeuo pipefail + 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. 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 printf "\e[?25h" local exit_code="$?" - #local line_number="$1" - #local command="$2" - #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}" - #post_update_to_api "failed" "$exit_code" "$error_description" - #echo -e "\n$error_message\n" + local line_number="$1" + local command="$2" + 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}" + post_update_to_api "failed" "$exit_code" "$error_description" + echo -e "\n$error_message\n" } # This function displays an informational message with logging support. @@ -337,8 +338,8 @@ base_settings() { HN=$NSAPP BRG="vmbr0" NET="dhcp" - #IPv6="dhcp" - #IPv6GW="" + IPv6="dhcp" + IPv6GW="" GATE="" APT_CACHER="" APT_CACHER_IP="" @@ -351,7 +352,9 @@ base_settings() { SSH="no" SSH_AUTHORIZED_KEY="" TAGS="community-script-dev;" - #ENABLE_FUSE="no" + ENABLE_NFS="no" + ENABLE_CIFS="no" + ENABLE_FUSE="no" # Override default settings with variables from ct script CT_TYPE=${var_unprivileged:-$CT_TYPE} @@ -360,7 +363,7 @@ base_settings() { RAM_SIZE=${var_ram:-$RAM_SIZE} VERB=${var_verbose:-$VERBOSE} 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 if [ -z "$var_os" ]; then @@ -1355,18 +1358,18 @@ check_container_storage() { start() { LOGDIR="/usr/local/community-scripts/logs" 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 ! (whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then clear exit_script exit fi - SPINNER_PID="" install_script - fi - - if ! command -v pveversion >/dev/null 2>&1; then + else CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \ "Support/Update functions for ${APP} LXC. Choose an option:" \ 12 60 3 \ @@ -1408,15 +1411,15 @@ build_container() { FEATURES="nesting=1" fi - #if [ "$ENABLE_FUSE" == "yes" ]; then - # FEATURES+=",fuse=1" - #fi + if [ "$ENABLE_FUSE" == "yes" ]; then + FEATURES+=",fuse=1" + fi - #if [[ $DIAGNOSTICS == "yes" ]]; then - # post_to_api - #fi + if [[ $DIAGNOSTICS == "yes" ]]; then + post_to_api + fi - #FEATURES="${FEATURES#,}" + FEATURES="${FEATURES#,}" TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null if [ "$var_os" == "alpine" ]; then @@ -1440,6 +1443,7 @@ build_container() { export PCT_OSTYPE="$var_os" export PCT_OSVERSION="$var_version" export PCT_DISK_SIZE="$DISK_SIZE" + export IPv6="$IPv6" export PCT_OPTIONS=" -features $FEATURES -hostname $HN @@ -1517,7 +1521,7 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community EOF' pct exec "$CTID" -- ash -c "apk add bash >/dev/null" 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 fi - #post_update_to_api "done" "none" + post_update_to_api "done" "none" } set_std_mode() { @@ -1586,11 +1590,10 @@ silent() { exit_script() { exit_code=$? # Capture exit status - #post_update_to_api "failed" "$exit_code" + post_update_to_api "failed" "$exit_code" } -# trap 'exit_script' EXIT -#trap 'post_update_to_api "failed" "2"' ERR -#trap 'post_update_to_api "failed" "130"' SIGINT -#trap 'post_update_to_api "failed" "143"' SIGTERM +trap 'post_update_to_api "failed" "2"' ERR +trap 'post_update_to_api "failed" "130"' SIGINT +trap 'post_update_to_api "failed" "143"' SIGTERM