core: standardize exit codes and add mappings (#12467)

* Standardize exit codes and add mappings

Replace generic exit 1 usages with specific numeric exit codes and add corresponding explanations to the error lookup. This commit updates multiple misc/* scripts to return distinct codes for validation, Proxmox/LXC, networking, download and curl errors (e.g. 103-123, 64, 107-120, 206, 0 for explicit user cancels). It also updates curl error handling to propagate the original curl exit code and adds new entries in explain_exit_code and the error handler to improve diagnostics.

* Set exit code 115 for update_os errors

Change exit status from 6 to 115 in misc/alpine-install.func's update_os() error handlers when failing to download tools.func or when the expected functions are missing. This gives a distinct exit code for these specific failure cases.

* Add tools/addon exit codes and use them

Introduce exit codes 232-238 for Tools & Addon scripts in misc/api.func and misc/error_handler.func. Update addon scripts (tools/addon/adguardhome-sync.sh, tools/addon/copyparty.sh, tools/addon/cronmaster.sh) to return specific codes instead of generic exit 1: 238 for unsupported OS and 233 when the application is not installed/upgrade prerequisites are missing. This makes failures more descriptive and aligns scripts with the central error explanations.

* Standardize exit codes in exporter addons

Unify exit codes across exporter addon scripts: return 238 for unsupported OS detections and 233 when an update is requested but the exporter is not installed. Applied to nextcloud-exporter.sh, pihole-exporter.sh, prometheus-paperless-ngx-exporter.sh, and qbittorrent-exporter.sh to make failure modes distinguishable for callers/automation.

* Use specific exit codes in addon scripts

Replace generic exit 1 with distinct exit codes across multiple addon scripts to enable finer-grained error handling in automation. Exit codes introduced: 10 for Docker/Compose missing or user-declined Docker install, 233 for "nothing to update" cases, and 238 for unsupported OS cases. Affected files: tools/addon/arcane.sh, coolify.sh, dockge.sh, dokploy.sh, filebrowser-quantum.sh, filebrowser.sh, immich-public-proxy.sh, jellystat.sh, runtipi.sh.

* Use specific exit codes in addon scripts

Replace generic exit 1 with specific exit codes across multiple addon scripts to improve error signaling and handling. Files updated: tools/addon/add-netbird-lxc.sh (exit 238 on unsupported distro), tools/addon/add-tailscale-lxc.sh (treat user cancel as exit 0), tools/addon/glances.sh (exit 233 when not installed), tools/addon/komodo.sh (distinct exits for missing compose, legacy DB, backup/download failures, docker checks), tools/addon/netdata.sh (distinct exits for unsupported PVE versions, OS/codename detection, repo lookups), and tools/addon/phpmyadmin.sh (distinct exits for unsupported OS, network/download issues, package install/start failures, and invalid input). These changes make failures easier to identify and automate recovery or reporting.

* Use specific exit codes in PVE scripts

Replace generic exit 1 with distinct exit codes across tools/pve scripts to provide clearer failure signals for callers. post-pve-install.sh now returns 105 for unsupported Proxmox versions; pve-privilege-converter.sh uses 104 for non-root, 234 when no containers, and 235 for backup/conversion failures; update-apps.sh maps backup failures to 235, missing containers/selections to 234 (and UI cancellations to 0), missing backup storage to 119, and returns the actual container update exit code on failure. These changes improve diagnostics and allow external tooling to react to specific error conditions.

* Standardize exit codes and behaviors

Adjust exit codes and abort handling across multiple PVE helper scripts to provide clearer outcomes for automation and interactive flows. Changes include:

- container-restore-from-backup.sh, core-restore-from-backup.sh: return 235 when no backups found (was 1).
- fstrim.sh: treat user cancellation of non-ext4 warning as non-error (exit 0 instead of 1).
- kernel-clean.sh: treat no selection or user abort as non-error (exit 0 instead of 1).
- lxc-delete.sh: return 234 when no containers are present; treat no selection as non-error (exit 0).
- nic-offloading-fix.sh: use specific non-zero codes for root check and tool install failures (exit 104, 237) and 236 when no matching interfaces (was 1).
- pbs_microcode.sh, post-pmg-install.sh, post-pbs-install.sh: use distinct exit codes (232 and 105) for detected VM/PVE/unsupported distro conditions instead of generic 1.

These modifications make scripts return distinct codes for different failure modes and ensure user-initiated aborts or benign conditions exit with 0 where appropriate.

* Use exit 105 for unsupported PVE versions

Standardize error handling by replacing generic exit 1 with exit 105 in pve_check() across multiple VM template scripts to indicate unsupported Proxmox VE versions. Also add API exit code 226 message for "Proxmox: VM disk import or post-creation setup failed" in misc/api.func. Affected files include misc/api.func and various vm/*-vm.sh scripts.

* Use specific exit codes in VM scripts

Replace generic exit 1 with distinct exit codes across vm/*.sh to make failures more actionable for callers. Changes include: use 226 for missing imported-disk references, 237 for pv installation failures, 115 for download/extract/ISO-related failures, 214 for insufficient disk space during FreeBSD decompression, and 119 for missing storage detection. Updated scripts: archlinux-vm.sh, docker-vm.sh, haos-vm.sh, openwrt-vm.sh, opnsense-vm.sh, truenas-vm.sh, umbrel-os-vm.sh.
This commit is contained in:
CanbiZ (MickLesk)
2026-03-02 10:55:20 +01:00
committed by GitHub
parent 9f15ca6242
commit 5dc244a8c1
58 changed files with 266 additions and 198 deletions

View File

@@ -73,7 +73,7 @@ fi
DISTRO=$(pct exec "$CTID" -- cat /etc/os-release | grep -w "ID" | cut -d'=' -f2 | tr -d '"')
if [[ "$DISTRO" != "debian" && "$DISTRO" != "ubuntu" ]]; then
msg "\e[1;31m Error: This script only supports Debian or Ubuntu LXC containers. Detected: $DISTRO. Aborting...\e[0m"
exit 1
exit 238
fi
CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf

View File

@@ -32,7 +32,7 @@ header_info
if ! command -v pveversion &>/dev/null; then
msg_error "This script must be run on the Proxmox VE host (not inside an LXC container)"
exit 1
exit 232
fi
while true; do
@@ -64,7 +64,7 @@ while [[ -z "${CTID}" ]]; do
CTID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --radiolist \
"\nSelect a container to add Tailscale to:\n" \
16 $((MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit 1
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit 0
done
CTID_CONFIG_PATH="/etc/pve/lxc/${CTID}.conf"

View File

@@ -69,7 +69,7 @@ elif [[ -f "/etc/debian_version" ]]; then
SERVICE_PATH="/etc/systemd/system/adguardhome-sync.service"
else
msg_error "Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -312,7 +312,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -87,11 +87,11 @@ function update() {
function check_docker() {
if ! command -v docker &>/dev/null; then
msg_error "Docker is not installed. This script requires an existing Docker LXC. Exiting."
exit 1
exit 10
fi
if ! docker compose version &>/dev/null; then
msg_error "Docker Compose plugin is not available. Please install it before running this script. Exiting."
exit 1
exit 10
fi
msg_ok "Docker $(docker --version | cut -d' ' -f3 | tr -d ',') and Docker Compose are available"
}
@@ -171,7 +171,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -93,7 +93,7 @@ function check_or_install_docker() {
msg_ok "Docker Compose is available"
else
msg_error "Docker Compose plugin is not available. Please install it."
exit 1
exit 10
fi
return
fi
@@ -103,7 +103,7 @@ function check_or_install_docker() {
read -r install_docker_prompt
if [[ ! "${install_docker_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_error "Docker is required for ${APP}. Exiting."
exit 1
exit 10
fi
msg_info "Installing Docker"
@@ -165,7 +165,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -49,7 +49,7 @@ elif grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
SERVICE_PATH="/etc/systemd/system/copyparty.service"
else
msg_error "Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -318,7 +318,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -51,7 +51,7 @@ EOF
# ==============================================================================
if ! grep -qE 'ID=debian|ID=ubuntu' /etc/os-release 2>/dev/null; then
echo -e "${CROSS} Unsupported OS detected. This script only supports Debian and Ubuntu."
exit 1
exit 238
fi
# ==============================================================================
@@ -183,7 +183,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -99,7 +99,7 @@ function check_or_install_docker() {
msg_ok "Docker Compose is available"
else
msg_error "Docker Compose plugin is not available. Please install it."
exit 1
exit 10
fi
return
fi
@@ -109,7 +109,7 @@ function check_or_install_docker() {
read -r install_docker_prompt
if [[ ! "${install_docker_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_error "Docker is required for ${APP}. Exiting."
exit 1
exit 10
fi
msg_info "Installing Docker"
@@ -160,7 +160,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -92,7 +92,7 @@ function check_or_install_docker() {
msg_ok "Docker Compose is available"
else
msg_error "Docker Compose plugin is not available. Please install it."
exit 1
exit 10
fi
return
fi
@@ -102,7 +102,7 @@ function check_or_install_docker() {
read -r install_docker_prompt
if [[ ! "${install_docker_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_error "Docker is required for ${APP}. Exiting."
exit 1
exit 10
fi
msg_info "Installing Docker"
@@ -163,7 +163,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -54,7 +54,7 @@ elif [[ -f "/etc/debian_version" ]]; then
PKG_MANAGER="apt-get install -y"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
header_info

View File

@@ -52,7 +52,7 @@ elif [[ -f "/etc/debian_version" ]]; then
PKG_MANAGER="apt-get install -y"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
header_info

View File

@@ -93,7 +93,7 @@ EOF
update_glances_debian() {
if [[ ! -d /opt/glances/.venv ]]; then
msg_error "$APP is not installed"
exit 1
exit 233
fi
msg_info "Updating $APP"
cd /opt/glances
@@ -160,7 +160,7 @@ EOF
update_glances_alpine() {
if [[ ! -d /opt/glances/.venv ]]; then
msg_error "$APP is not installed"
exit 1
exit 233
fi
msg_info "Updating $APP"
cd /opt/glances

View File

@@ -52,13 +52,13 @@ EOF
# ==============================================================================
if [[ -f "/etc/alpine-release" ]]; then
msg_error "Alpine is not supported for ${APP}. Use Debian."
exit 1
exit 238
elif [[ -f "/etc/debian_version" ]]; then
OS="Debian"
SERVICE_PATH="/etc/systemd/system/immich-proxy.service"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -231,7 +231,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -52,13 +52,13 @@ EOF
# ==============================================================================
if [[ -f "/etc/alpine-release" ]]; then
msg_error "Alpine is not supported for ${APP}. Use Debian/Ubuntu."
exit 1
exit 238
elif [[ -f "/etc/debian_version" ]]; then
OS="Debian"
SERVICE_PATH="/etc/systemd/system/jellystat.service"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -326,7 +326,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -37,7 +37,7 @@ function find_compose_file() {
COMPOSE_FILE=$(find "$INSTALL_PATH" -maxdepth 1 -type f -name '*.compose.yaml' ! -name 'compose.env' | head -n1)
if [[ -z "${COMPOSE_FILE:-}" ]]; then
msg_error "No valid compose file found in ${INSTALL_PATH}!"
exit 1
exit 233
fi
COMPOSE_BASENAME=$(basename "$COMPOSE_FILE")
}
@@ -48,7 +48,7 @@ function check_legacy_db() {
echo -e "${YW}This configuration is no longer supported since Komodo v1.18.0.${CL}"
echo -e "${YW}Please follow the migration guide:${CL}"
echo -e "${BGN}https://github.com/community-scripts/ProxmoxVE/discussions/5689${CL}\n"
exit 1
exit 238
fi
}
@@ -79,14 +79,14 @@ function update() {
BACKUP_FILE="${INSTALL_PATH}/${COMPOSE_BASENAME}.bak_$(date +%Y%m%d_%H%M%S)"
cp "$COMPOSE_FILE" "$BACKUP_FILE" || {
msg_error "Failed to create backup of ${COMPOSE_BASENAME}!"
exit 1
exit 235
}
GITHUB_URL="https://raw.githubusercontent.com/moghtech/komodo/main/compose/${COMPOSE_BASENAME}"
if ! curl -fsSL "$GITHUB_URL" -o "$COMPOSE_FILE"; then
msg_error "Failed to download ${COMPOSE_BASENAME} from GitHub!"
mv "$BACKUP_FILE" "$COMPOSE_FILE"
exit 1
exit 115
fi
if ! grep -qxF 'COMPOSE_KOMODO_BACKUPS_PATH=/etc/komodo/backups' "$COMPOSE_ENV"; then
@@ -129,7 +129,7 @@ function check_or_install_docker() {
msg_ok "Docker Compose is available"
else
msg_error "Docker Compose plugin is not available. Please install it."
exit 1
exit 10
fi
return
fi
@@ -139,7 +139,7 @@ function check_or_install_docker() {
read -r install_docker_prompt
if [[ ! "${install_docker_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_error "Docker is required for ${APP}. Exiting."
exit 1
exit 10
fi
msg_info "Installing Docker"
@@ -239,7 +239,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -58,7 +58,7 @@ pve_check() {
if ((MINOR < 0 || MINOR > 9)); then
msg_error "This version of Proxmox VE is not supported."
msg_error "Supported: Proxmox VE version 8.0 8.9"
exit 1
exit 105
fi
return 0
fi
@@ -69,7 +69,7 @@ pve_check() {
if ((MINOR < 0 || MINOR > 1)); then
msg_error "This version of Proxmox VE is not yet supported."
msg_error "Supported: Proxmox VE version 9.09.1.x"
exit 1
exit 105
fi
return 0
fi
@@ -77,19 +77,19 @@ pve_check() {
# All other unsupported versions
msg_error "This version of Proxmox VE is not supported."
msg_error "Supported versions: Proxmox VE 8.0 8.9 or 9.09.1.x"
exit 1
exit 105
}
detect_codename() {
source /etc/os-release
if [[ "$ID" != "debian" ]]; then
msg_error "Unsupported base OS: $ID (only Proxmox VE / Debian supported)."
exit 1
exit 238
fi
CODENAME="${VERSION_CODENAME:-}"
if [[ -z "$CODENAME" ]]; then
msg_error "Could not detect Debian codename."
exit 1
exit 71
fi
echo "$CODENAME"
}
@@ -124,7 +124,7 @@ install() {
PKG=$(get_latest_repo_pkg "$REPO_URL")
if [[ -z "$PKG" ]]; then
msg_error "Could not find netdata-repo package for Debian $CODENAME"
exit 1
exit 237
fi
curl -fsSL "${REPO_URL}${PKG}" -o "$PKG"
$STD dpkg -i "$PKG"

View File

@@ -36,7 +36,7 @@ SERVICE_PATH="/etc/systemd/system/nextcloud-exporter.service"
# ==============================================================================
if ! grep -qE 'ID=debian|ID=ubuntu' /etc/os-release 2>/dev/null; then
echo -e "${CROSS} Unsupported OS detected. This script only supports Debian and Ubuntu."
exit 1
exit 238
fi
# ==============================================================================
@@ -170,7 +170,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "Nextcloud-Exporter is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -52,7 +52,7 @@ elif [[ -f "/etc/debian_version" ]]; then
INSTALL_DIR="$INSTALL_DIR_DEBIAN"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
header_info
@@ -72,7 +72,7 @@ function check_internet() {
msg_ok "Internet connectivity OK"
else
msg_error "Internet connectivity or GitHub unreachable (Status $HTTP_CODE). Exiting."
exit 1
exit 115
fi
}
@@ -105,7 +105,7 @@ function install_php_and_modules() {
msg_info "Installing missing PHP packages: ${MISSING_PACKAGES[*]}"
if ! apt-get update &>/dev/null || ! apt-get install -y "${MISSING_PACKAGES[@]}" &>/dev/null; then
msg_error "Failed to install required PHP modules. Exiting."
exit 1
exit 237
fi
msg_ok "Installed missing PHP packages"
else
@@ -132,7 +132,7 @@ function install_phpmyadmin() {
msg_info "Downloading ${TARBALL_URL}"
if ! curl -fsSL "$TARBALL_URL" -o /tmp/phpmyadmin.tar.gz; then
msg_error "Download failed: $TARBALL_URL"
exit 1
exit 115
fi
mkdir -p "$INSTALL_DIR"
@@ -188,7 +188,7 @@ EOF
msg_ok "Started PHP-FPM service: $PHP_FPM_SERVICE"
else
msg_error "Failed to start PHP-FPM service: $PHP_FPM_SERVICE"
exit 1
exit 150
fi
$STD rc-service lighttpd start
@@ -237,7 +237,7 @@ function update_phpmyadmin() {
if ! curl -fsSL "$TARBALL_URL" -o /tmp/phpmyadmin.tar.gz; then
msg_error "Download failed: $TARBALL_URL"
exit 1
exit 115
fi
BACKUP_DIR="/tmp/phpmyadmin-backup-$(date +%Y%m%d-%H%M%S)"
@@ -280,7 +280,7 @@ if is_phpmyadmin_installed; then
;;
*)
echo -e "${YW}⚠️ Invalid input. Exiting.${CL}"
exit 1
exit 112
;;
esac
else

View File

@@ -41,7 +41,7 @@ elif grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
SERVICE_PATH="/etc/systemd/system/pihole-exporter.service"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -207,7 +207,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "Pihole-Exporter is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -32,7 +32,7 @@ AUTH_TOKEN_FILE="/etc/prometheus-paperless-ngx-exporter/paperless_auth_token_fil
# ==============================================================================
if ! grep -qE 'ID=debian|ID=ubuntu' /etc/os-release 2>/dev/null; then
echo -e "${CROSS} Unsupported OS detected. This script only supports Debian and Ubuntu."
exit 1
exit 238
fi
# ==============================================================================
@@ -144,7 +144,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "Prometheus-Paperless-NGX-Exporter is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -41,7 +41,7 @@ elif grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
SERVICE_PATH="/etc/systemd/system/qbittorrent-exporter.service"
else
echo -e "${CROSS} Unsupported OS detected. Exiting."
exit 1
exit 238
fi
# ==============================================================================
@@ -200,7 +200,7 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "qBittorrent-Exporter is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi

View File

@@ -62,7 +62,7 @@ function check_or_install_docker() {
msg_ok "Docker Compose is available"
else
msg_error "Docker Compose plugin is not available. Please install it."
exit 1
exit 10
fi
return
fi
@@ -72,7 +72,7 @@ function check_or_install_docker() {
read -r install_docker_prompt
if [[ ! "${install_docker_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_error "Docker is required for ${APP}. Exiting."
exit 1
exit 10
fi
msg_info "Installing Docker"
@@ -168,14 +168,14 @@ if [[ "${type:-}" == "update" ]]; then
update
else
msg_error "${APP} is not installed. Nothing to update."
exit 1
exit 233
fi
exit 0
fi
if [[ -f /etc/alpine-release ]]; then
msg_error "${APP} does not support Alpine Linux. Please use a Debian or Ubuntu based LXC."
exit 1
exit 238
fi
header_info

View File

@@ -62,7 +62,7 @@ function msg_error() {
}
if [ -z "$(ls -A /var/lib/docker/volumes/hass_config/_data/backups/)" ]; then
msg_error "No backups found! \n"
exit 1
exit 235
fi
DIR=/var/lib/docker/volumes/hass_config/_data/restore
if [ -d "$DIR" ]; then

View File

@@ -62,7 +62,7 @@ function msg_error() {
}
if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then
msg_error "No backups found! \n"
exit 1
exit 235
fi
DIR=/root/.homeassistant/restore
if [ -d "$DIR" ]; then

View File

@@ -39,7 +39,7 @@ ROOT_FS=$(df -Th "/" | awk 'NR==2 {print $2}')
if [ "$ROOT_FS" != "ext4" ]; then
whiptail --backtitle "Proxmox VE Helper Scripts" \
--title "Warning" \
--yesno "Root filesystem is not ext4 ($ROOT_FS).\nContinue anyway?" 12 80 || exit 1
--yesno "Root filesystem is not ext4 ($ROOT_FS).\nContinue anyway?" 12 80 || exit 0
fi
NODE=$(hostname)

View File

@@ -57,7 +57,7 @@ done
if [ ${#kernels_to_remove[@]} -eq 0 ]; then
echo -e "${RD}No valid selection made. Exiting.${CL}"
exit 1
exit 0
fi
# Confirm removal
@@ -66,7 +66,7 @@ printf "%s\n" "${kernels_to_remove[@]}"
read -rp "Proceed with removal? (y/n): " confirm
if [[ "$confirm" != "y" ]]; then
echo -e "${RD}Aborted.${CL}"
exit 1
exit 0
fi
# Remove kernels

View File

@@ -51,7 +51,7 @@ containers=$(pct list | tail -n +2 | awk '{print $0 " " $4}')
if [ -z "$containers" ]; then
whiptail --title "LXC Container Delete" --msgbox "No LXC containers available!" 10 60
exit 1
exit 234
fi
menu_items=("ALL" "Delete ALL containers" "OFF") # Add as first option
@@ -72,7 +72,7 @@ CHOICES=$(whiptail --title "LXC Container Delete" \
if [ -z "$CHOICES" ]; then
whiptail --title "LXC Container Delete" \
--msgbox "No containers selected!" 10 60
exit 1
exit 0
fi
read -p "Delete containers manually or automatically? (Default: manual) m/a: " DELETE_MODE

View File

@@ -47,7 +47,7 @@ function msg_warn() { echo -e "${WARN} ${YWB}${1}"; }
# Check for root privileges
if [ "$(id -u)" -ne 0 ]; then
msg_error "Error: This script must be run as root."
exit 1
exit 104
fi
if ! command -v ethtool >/dev/null 2>&1; then
@@ -55,7 +55,7 @@ if ! command -v ethtool >/dev/null 2>&1; then
apt-get update &>/dev/null
apt-get install -y ethtool &>/dev/null || {
msg_error "Failed to install ethtool. Exiting."
exit 1
exit 237
}
msg_ok "ethtool installed successfully"
fi
@@ -86,7 +86,7 @@ done
if [ ${#INTERFACES[@]} -eq 0 ]; then
whiptail --title "Error" --msgbox "No Intel e1000e or e1000 network interfaces found!" 10 60
msg_error "No Intel e1000e or e1000 network interfaces found! Exiting."
exit 1
exit 236
fi
msg_ok "Found ${BL}$COUNT${GN} Intel e1000e/e1000 interfaces"

View File

@@ -41,7 +41,7 @@ header_info
virt=$(systemd-detect-virt)
if [ "$virt" != "none" ]; then
msg_error "This script must be run on bare metal. Detected virtual environment: $virt"
exit 1
exit 232
fi
# Attempt to obtain the current loaded microcode revision

View File

@@ -83,7 +83,7 @@ main() {
if command -v pveversion >/dev/null 2>&1; then
echo -e "\n🛑 PVE Detected, Wrong Script!\n"
exit 1
exit 232
fi
local CODENAME
@@ -95,7 +95,7 @@ main() {
*)
msg_error "Unsupported Debian codename: $CODENAME"
echo -e "Supported: bookworm (PBS 3.x) and trixie (PBS 4.x)"
exit 1
exit 105
;;
esac
}

View File

@@ -49,7 +49,7 @@ declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "post-pmg-inst
if ! grep -q "Proxmox Mail Gateway" /etc/issue 2>/dev/null; then
msg_error "This script is only intended for Proxmox Mail Gateway"
exit 1
exit 232
fi
repo_state() {

View File

@@ -88,19 +88,19 @@ main() {
if [[ "$PVE_MAJOR" == "8" ]]; then
if ((PVE_MINOR < 0 || PVE_MINOR > 9)); then
msg_error "Unsupported Proxmox 8 version"
exit 1
exit 105
fi
start_routines_8
elif [[ "$PVE_MAJOR" == "9" ]]; then
if ((PVE_MINOR < 0 || PVE_MINOR > 1)); then
msg_error "Only Proxmox 9.0-9.1.x is currently supported"
exit 1
exit 105
fi
start_routines_9
else
msg_error "Unsupported Proxmox VE major version: $PVE_MAJOR"
echo -e "Supported: 8.08.9.x and 9.09.1.x"
exit 1
exit 105
fi
}

View File

@@ -25,7 +25,7 @@ header_info "$APP"
check_root() {
if [[ $EUID -ne 0 ]]; then
msg_error "Script must be run as root"
exit 1
exit 104
fi
}
@@ -63,7 +63,7 @@ select_container() {
if [[ ${#lxc_list[@]} -eq 0 ]]; then
msg_error "No containers found"
exit 1
exit 234
fi
PS3="Enter number of container to convert: "
@@ -101,7 +101,7 @@ backup_container() {
if [ -z "$BACKUP_PATH" ] || ! grep -q "Backup job finished successfully" "$vzdump_output"; then
rm "$vzdump_output"
msg_error "Backup failed"
exit 1
exit 235
fi
rm "$vzdump_output"
msg_ok "Backup complete: $BACKUP_PATH"
@@ -126,7 +126,7 @@ perform_conversion() {
msg_ok "Conversion successful"
else
msg_error "Conversion failed"
exit 1
exit 235
fi
}

View File

@@ -140,7 +140,7 @@ function backup_container() {
msg_ok "Backup created"
else
msg_error "Backup failed for container $1"
exit 1
exit 235
fi
}
@@ -183,7 +183,7 @@ containers=$(pct list | tail -n +2 | awk '{print $0 " " $4}')
if [ -z "$containers" ]; then
whiptail --title "LXC Container Update" --msgbox "No LXC containers available!" 10 60
exit 1
exit 234
fi
menu_items=()
@@ -242,7 +242,7 @@ if [[ -n "$var_container" ]]; then
if [[ -z "$CHOICE" ]]; then
msg_error "No containers matched the selection criteria: $var_container ${var_tags:-community-script|proxmox-helper-scripts}"
exit 1
exit 234
fi
msg_ok "Selected containers: $CHOICE"
else
@@ -253,7 +253,7 @@ else
if [ -z "$CHOICE" ]; then
whiptail --title "LXC Container Update" \
--msgbox "No containers selected!" 10 60
exit 1
exit 0
fi
fi
@@ -284,7 +284,7 @@ if [ "$BACKUP_CHOICE" == "yes" ]; then
if [ -z "$STORAGES" ]; then
msg_error "No storage with 'backup' support found!"
exit 1
exit 119
fi
# Determine storage based on var_backup_storage
@@ -296,7 +296,7 @@ if [ "$BACKUP_CHOICE" == "yes" ]; then
else
msg_error "Specified backup storage '$var_backup_storage' not found or doesn't support backups!"
msg_info "Available storages: $(echo $STORAGES | tr '\n' ' ')"
exit 1
exit 119
fi
else
MENU_ITEMS=()
@@ -308,7 +308,7 @@ if [ "$BACKUP_CHOICE" == "yes" ]; then
if [ -z "$STORAGE_CHOICE" ]; then
msg_error "No storage selected!"
exit 1
exit 0
fi
fi
fi
@@ -436,11 +436,11 @@ for container in $CHOICE; do
msg_ok "Restored LXC from backup"
else
msg_error "Restored LXC from backup failed"
exit 1
exit 235
fi
else
msg_error "Update failed for container $container. Exiting"
exit 1
exit "$exit_code"
fi
done