Replace init_error_traps with catch_errors in scripts

Replaces all occurrences of the 'init_error_traps' function with 'catch_errors' across container and install scripts for consistency in error handling. Also adjusts indentation and formatting in some scripts for improved readability.
This commit is contained in:
CanbiZ
2025-09-19 08:53:49 +02:00
parent fe3de07157
commit b840a8aa32
107 changed files with 497 additions and 498 deletions

View File

@@ -8,14 +8,14 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Caddy"
$STD apk add --no-cache caddy caddy-openrc
cat<<EOF >/etc/caddy/Caddyfile
cat <<EOF >/etc/caddy/Caddyfile
:80 {
# Set this path to your site's directory.
root * /var/www/html
@@ -31,7 +31,7 @@ cat<<EOF >/etc/caddy/Caddyfile
}
EOF
mkdir -p /var/www/html
cat<<EOF >/var/www/html/index.html
cat <<EOF >/var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
@@ -47,15 +47,15 @@ msg_ok "Installed Caddy"
read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
msg_info "Setup xCaddy"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz"
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
rm -rf /opt/xcaddy*
$STD xcaddy build
msg_ok "Setup xCaddy"
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
msg_info "Setup xCaddy"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz"
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
rm -rf /opt/xcaddy*
$STD xcaddy build
msg_ok "Setup xCaddy"
fi
msg_info "Enabling Caddy Service"

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -10,7 +10,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@ source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -7,7 +7,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -7,7 +7,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -12,7 +12,7 @@ INSTALL_PATH="/opt/sng_freepbx_debian_install.sh"
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -7,7 +7,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -7,7 +7,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -9,7 +9,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os
@@ -16,18 +16,18 @@ update_os
msg_info "Setting Up Hardware Acceleration"
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
if [[ "$CTTYPE" == "0" ]]; then
chgrp video /dev/dri
chmod 755 /dev/dri
chmod 660 /dev/dri/*
$STD adduser $(id -u -n) video
$STD adduser $(id -u -n) render
chgrp video /dev/dri
chmod 755 /dev/dri
chmod 660 /dev/dri/*
$STD adduser $(id -u -n) video
$STD adduser $(id -u -n) render
fi
msg_ok "Set Up Hardware Acceleration"
read -r -p "${TAB3}Do you need the intel-media-va-driver-non-free driver for HW encoding (Debian 12 only)? <y/N> " prompt
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
msg_info "Installing Intel Hardware Acceleration (non-free)"
cat <<EOF >/etc/apt/sources.list.d/non-free.list
msg_info "Installing Intel Hardware Acceleration (non-free)"
cat <<EOF >/etc/apt/sources.list.d/non-free.list
deb http://deb.debian.org/debian bookworm non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm non-free non-free-firmware
@@ -38,11 +38,11 @@ deb-src http://deb.debian.org/debian-security bookworm-security non-free non-fre
deb http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
EOF
$STD apt-get update
$STD apt-get -y install {intel-media-va-driver-non-free,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
$STD apt-get update
$STD apt-get -y install {intel-media-va-driver-non-free,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
else
msg_info "Installing Intel Hardware Acceleration"
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
msg_info "Installing Intel Hardware Acceleration"
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
fi
msg_ok "Installed and Set Up Intel Hardware Acceleration"

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -7,7 +7,7 @@
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os

View File

@@ -8,7 +8,7 @@
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
init_error_traps
catch_errors
setting_up_container
network_check
update_os
@@ -16,8 +16,7 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
apt-transport-https \
ca-certificates\
nginx
ca-certificates nginx
msg_ok "Installed Dependencies"
PYTHON_VERSION="3.11" setup_uv
@@ -37,12 +36,12 @@ $STD sudo -u postgres psql -d "$DB_NAME" -c "GRANT USAGE ON SCHEMA public TO $DB
$STD sudo -u postgres psql -d "$DB_NAME" -c "GRANT CREATE ON SCHEMA public TO $DB_USER;"
$STD sudo -u postgres psql -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO $DB_USER;"
{
echo "Application Credentials"
echo "DB_NAME: $DB_NAME"
echo "DB_USER: $DB_USER"
echo "DB_PASS: $DB_PASS"
echo "DB_ADMIN_USER: $DB_ADMIN_USER"
echo "DB_ADMIN_PASS: $DB_ADMIN_PASS"
echo "Application Credentials"
echo "DB_NAME: $DB_NAME"
echo "DB_USER: $DB_USER"
echo "DB_PASS: $DB_PASS"
echo "DB_ADMIN_USER: $DB_ADMIN_USER"
echo "DB_ADMIN_PASS: $DB_ADMIN_PASS"
} >>~/warracker.creds
msg_ok "Installed PostgreSQL"
@@ -55,17 +54,17 @@ $STD source .venv/bin/activate
$STD uv pip install -r requirements.txt
mv /opt/warracker/env.example /opt/warracker/.env
sed -i \
-e "s/your_secure_database_password/$DB_PASS/" \
-e "s/your_secure_admin_password/$DB_ADMIN_PASS/" \
-e "s|^# DB_PORT=5432$|DB_HOST=127.0.0.1|" \
/opt/warracker/.env
-e "s/your_secure_database_password/$DB_PASS/" \
-e "s/your_secure_admin_password/$DB_ADMIN_PASS/" \
-e "s|^# DB_PORT=5432$|DB_HOST=127.0.0.1|" \
/opt/warracker/.env
mv /opt/warracker/nginx.conf /etc/nginx/sites-available/warracker.conf
sed -i \
-e "s|alias /var/www/html/locales/;|alias /opt/warracker/locales/;|" \
-e "s|/var/www/html|/opt/warracker/frontend|g" \
-e "s/client_max_body_size __NGINX_MAX_BODY_SIZE_CONFIG_VALUE__/client_max_body_size 32M/" \
/etc/nginx/sites-available/warracker.conf
-e "s|alias /var/www/html/locales/;|alias /opt/warracker/locales/;|" \
-e "s|/var/www/html|/opt/warracker/frontend|g" \
-e "s/client_max_body_size __NGINX_MAX_BODY_SIZE_CONFIG_VALUE__/client_max_body_size 32M/" \
/etc/nginx/sites-available/warracker.conf
ln -s /etc/nginx/sites-available/warracker.conf /etc/nginx/sites-enabled/warracker.conf
rm /etc/nginx/sites-enabled/default
systemctl restart nginx