From b840a8aa325250f3c3e4208eec74c294fff582cc Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 19 Sep 2025 08:53:49 +0200 Subject: [PATCH] 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. --- ct/alpine-caddy.sh | 30 +-- ct/alpine.sh | 2 +- ct/debian.sh | 2 +- ct/deferred/alpine-homarr.sh | 2 +- ct/deferred/ampache.sh | 2 +- ct/deferred/ghostfolio.sh | 2 +- ct/deferred/hoodik.sh | 2 +- ct/deferred/jumpserver.sh | 2 +- ct/deferred/kasm.sh | 2 +- ct/deferred/koel.sh | 2 +- ct/deferred/librespeed.sh | 2 +- ct/deferred/netbootxyz.sh | 2 +- ct/deferred/nginxproxymanager.sh | 2 +- ct/deferred/ocis.sh | 2 +- ct/deferred/openwebui.sh | 2 +- ct/deferred/pixelfed.sh | 2 +- ct/deferred/polaris.sh | 2 +- ct/deferred/roundcubemail.sh | 2 +- ct/deferred/squirrelserversmanager.sh | 2 +- ct/deferred/vikunja.sh | 2 +- ct/dispatcharr.sh | 2 +- ct/docspell.sh | 2 +- ct/ente.sh | 2 +- ct/freepbx.sh | 2 +- ct/frigate.sh | 2 +- ct/garmin-grafana.sh | 2 +- ct/ghostfolio.sh | 2 +- ct/globaleaks.sh | 24 +- ct/hanko.sh | 2 +- ct/joplin-server.sh | 2 +- ct/kanba.sh | 2 +- ct/leantime.sh | 2 +- ct/librenms.sh | 2 +- ct/livebook.sh | 2 +- ct/manyfold.sh | 2 +- ct/maxun.sh | 2 +- ct/notesnook.sh | 2 +- ct/npmplus.sh | 2 +- ct/opencloud.sh | 2 +- ct/postiz.sh | 2 +- ct/proxmox-datacenter-manager.sh | 2 +- ct/romm.sh | 2 +- ct/rybbit.sh | 2 +- ct/scraparr.sh | 2 +- ct/signoz.sh | 2 +- ct/tunarr.sh | 2 +- ct/ubuntu.sh | 2 +- ct/viseron.sh | 2 +- ct/wallabag.sh | 2 +- ct/warracker.sh | 2 +- install/alpine-caddy-install.sh | 24 +- install/alpine-garage-install.sh | 2 +- install/alpine-install.sh | 2 +- install/debian-install.sh | 2 +- install/deferred/ampache-install.sh | 2 +- install/deferred/freepbx-install_backup.sh | 2 +- install/deferred/funkwhale-install.sh | 2 +- install/deferred/ghostfolio-install.sh | 2 +- install/deferred/hoodik-install.sh | 2 +- install/deferred/jumpserver-install.sh | 2 +- install/deferred/kasm-install.sh | 2 +- install/deferred/koel-install.sh | 2 +- install/deferred/netbootxyz-install.sh | 2 +- install/deferred/nginxproxymanager-install.sh | 2 +- install/deferred/nimbus-install.sh | 2 +- install/deferred/ocis-install.sh | 2 +- install/deferred/openwebui-install.sh | 2 +- install/deferred/pixelfed-install.sh | 2 +- install/deferred/polaris-install.sh | 2 +- install/deferred/roundcubemail-install.sh | 2 +- .../squirrelserversmanager-install.sh | 2 +- install/deferred/timescaledb-install.sh | 2 +- install/deferred/vikunja-install.sh | 2 +- install/dispatcharr-install.sh | 2 +- install/docspell-install.sh | 2 +- install/ente-install.sh | 2 +- install/freepbx-install.sh | 2 +- install/frigate-install.sh | 2 +- install/garmin-grafana-install.sh | 2 +- install/ghostfolio-install.sh | 2 +- install/globaleaks-install.sh | 2 +- install/hanko-install.sh | 2 +- install/joplin-server-install.sh | 2 +- install/kanba-install.sh | 2 +- install/leantime-install.sh | 2 +- install/librenms-install.sh | 2 +- install/livebook-install.sh | 2 +- install/manyfold-install.sh | 2 +- install/maxun-install.sh | 2 +- install/notesnook-install.sh | 2 +- install/npmplus-install.sh | 2 +- install/opencloud-install.sh | 2 +- install/postiz-install.sh | 2 +- install/proxmox-datacenter-manager-install.sh | 2 +- install/romm-install.sh | 2 +- install/rybbit-install.sh | 2 +- install/scraparr-install.sh | 2 +- install/signoz-install.sh | 2 +- install/tunarr-install.sh | 24 +- install/ubuntu-install.sh | 2 +- install/viseron-install.sh | 2 +- install/wallabag-install.sh | 2 +- install/warracker-install.sh | 33 ++- misc/alpine-install.func | 204 +++++++------- misc/build.func | 4 +- misc/error_handler.func | 208 +++++++-------- misc/install.func | 248 +++++++++--------- 107 files changed, 497 insertions(+), 498 deletions(-) diff --git a/ct/alpine-caddy.sh b/ct/alpine-caddy.sh index 75cfe636..89fe099d 100644 --- a/ct/alpine-caddy.sh +++ b/ct/alpine-caddy.sh @@ -17,24 +17,24 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /etc/caddy ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - msg_info "Updating $APP LXC" - $STD apk -U upgrade - msg_ok "Updated $APP LXC" + header_info + check_container_storage + check_container_resources + if [[ ! -d /etc/caddy ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apk -U upgrade + msg_ok "Updated $APP LXC" - msg_info "Restarting Caddy" - rc-service caddy restart - msg_ok "Restarted Caddy" - exit + msg_info "Restarting Caddy" + rc-service caddy restart + msg_ok "Restarted Caddy" + exit } start diff --git a/ct/alpine.sh b/ct/alpine.sh index 4940d6fc..ea946a60 100644 --- a/ct/alpine.sh +++ b/ct/alpine.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/debian.sh b/ct/debian.sh index dad59683..a7ed93b3 100644 --- a/ct/debian.sh +++ b/ct/debian.sh @@ -19,7 +19,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/alpine-homarr.sh b/ct/deferred/alpine-homarr.sh index def7cca2..c78398d6 100644 --- a/ct/deferred/alpine-homarr.sh +++ b/ct/deferred/alpine-homarr.sh @@ -18,7 +18,7 @@ header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/ampache.sh b/ct/deferred/ampache.sh index ccf300e2..ada18f09 100644 --- a/ct/deferred/ampache.sh +++ b/ct/deferred/ampache.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/ghostfolio.sh b/ct/deferred/ghostfolio.sh index 36039092..56002d40 100644 --- a/ct/deferred/ghostfolio.sh +++ b/ct/deferred/ghostfolio.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/hoodik.sh b/ct/deferred/hoodik.sh index 1fee14b1..0e7597b1 100644 --- a/ct/deferred/hoodik.sh +++ b/ct/deferred/hoodik.sh @@ -18,7 +18,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/jumpserver.sh b/ct/deferred/jumpserver.sh index 1658a368..f512024c 100644 --- a/ct/deferred/jumpserver.sh +++ b/ct/deferred/jumpserver.sh @@ -17,7 +17,7 @@ var_unprivileged="1" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/kasm.sh b/ct/deferred/kasm.sh index ba78e8d5..565c71fb 100644 --- a/ct/deferred/kasm.sh +++ b/ct/deferred/kasm.sh @@ -19,7 +19,7 @@ var_tun="${var_tun:-yes}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/koel.sh b/ct/deferred/koel.sh index b0c12d86..a4b6ea7e 100644 --- a/ct/deferred/koel.sh +++ b/ct/deferred/koel.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/librespeed.sh b/ct/deferred/librespeed.sh index 4861a568..95650828 100644 --- a/ct/deferred/librespeed.sh +++ b/ct/deferred/librespeed.sh @@ -17,7 +17,7 @@ var_unprivileged="1" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/netbootxyz.sh b/ct/deferred/netbootxyz.sh index 60832ff4..201073af 100644 --- a/ct/deferred/netbootxyz.sh +++ b/ct/deferred/netbootxyz.sh @@ -26,7 +26,7 @@ var_os="${var_os:-debian}" var_version="${var_version:-12}" variables color -init_error_traps +catch_errors function default_settings() { CT_TYPE="1" diff --git a/ct/deferred/nginxproxymanager.sh b/ct/deferred/nginxproxymanager.sh index 41f1aecd..b1ff024d 100644 --- a/ct/deferred/nginxproxymanager.sh +++ b/ct/deferred/nginxproxymanager.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/ocis.sh b/ct/deferred/ocis.sh index 44f5f1ae..167b4593 100644 --- a/ct/deferred/ocis.sh +++ b/ct/deferred/ocis.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/openwebui.sh b/ct/deferred/openwebui.sh index 47a9e74a..85341bd9 100644 --- a/ct/deferred/openwebui.sh +++ b/ct/deferred/openwebui.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/pixelfed.sh b/ct/deferred/pixelfed.sh index 44ac53b3..8ddab519 100644 --- a/ct/deferred/pixelfed.sh +++ b/ct/deferred/pixelfed.sh @@ -16,7 +16,7 @@ var_version="${var_version:-12}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/polaris.sh b/ct/deferred/polaris.sh index c43b57de..c290d770 100644 --- a/ct/deferred/polaris.sh +++ b/ct/deferred/polaris.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/roundcubemail.sh b/ct/deferred/roundcubemail.sh index 6f65e527..75d0e3bc 100644 --- a/ct/deferred/roundcubemail.sh +++ b/ct/deferred/roundcubemail.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/squirrelserversmanager.sh b/ct/deferred/squirrelserversmanager.sh index 751a6026..4403ab5f 100644 --- a/ct/deferred/squirrelserversmanager.sh +++ b/ct/deferred/squirrelserversmanager.sh @@ -16,7 +16,7 @@ var_unprivileged="${var_unprivileged:-1}" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/deferred/vikunja.sh b/ct/deferred/vikunja.sh index 687d4700..fd248351 100644 --- a/ct/deferred/vikunja.sh +++ b/ct/deferred/vikunja.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/dispatcharr.sh b/ct/dispatcharr.sh index 979cd3d0..e2a2971e 100644 --- a/ct/dispatcharr.sh +++ b/ct/dispatcharr.sh @@ -18,7 +18,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/docspell.sh b/ct/docspell.sh index a9667cea..93eb6806 100644 --- a/ct/docspell.sh +++ b/ct/docspell.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/ente.sh b/ct/ente.sh index 7f8b3132..5733886c 100644 --- a/ct/ente.sh +++ b/ct/ente.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/freepbx.sh b/ct/freepbx.sh index 96f8dd02..0552674b 100644 --- a/ct/freepbx.sh +++ b/ct/freepbx.sh @@ -18,7 +18,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/frigate.sh b/ct/frigate.sh index 2cc5d113..479c6b98 100644 --- a/ct/frigate.sh +++ b/ct/frigate.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-0}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/garmin-grafana.sh b/ct/garmin-grafana.sh index f34fec36..f0742dd8 100644 --- a/ct/garmin-grafana.sh +++ b/ct/garmin-grafana.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors # this only updates garmin-grafana, not influxdb or grafana, which are upgraded with apt function update_script() { diff --git a/ct/ghostfolio.sh b/ct/ghostfolio.sh index d74aead6..5acd7f6a 100644 --- a/ct/ghostfolio.sh +++ b/ct/ghostfolio.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/globaleaks.sh b/ct/globaleaks.sh index 3e1abc89..03bc2f08 100644 --- a/ct/globaleaks.sh +++ b/ct/globaleaks.sh @@ -16,21 +16,21 @@ var_version="${var_version:-13}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -f /usr/sbin/globaleaks ]]; then - msg_error "No ${APP} installation found!" - exit - fi + header_info + check_container_storage + check_container_resources + if [[ ! -f /usr/sbin/globaleaks ]]; then + msg_error "No ${APP} installation found!" + exit + fi - msg_info "Updating $APP LXC" - $STD apt update - $STD apt -y upgrade - msg_ok "Updated $APP LXC" + msg_info "Updating $APP LXC" + $STD apt update + $STD apt -y upgrade + msg_ok "Updated $APP LXC" } start diff --git a/ct/hanko.sh b/ct/hanko.sh index 53e295d2..de3079c2 100644 --- a/ct/hanko.sh +++ b/ct/hanko.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/joplin-server.sh b/ct/joplin-server.sh index 02983e10..9f4896fc 100644 --- a/ct/joplin-server.sh +++ b/ct/joplin-server.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/kanba.sh b/ct/kanba.sh index 04f85ace..270f5e00 100644 --- a/ct/kanba.sh +++ b/ct/kanba.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/leantime.sh b/ct/leantime.sh index e6fe9864..13b96061 100644 --- a/ct/leantime.sh +++ b/ct/leantime.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/librenms.sh b/ct/librenms.sh index 3acd3812..aaa71a1a 100644 --- a/ct/librenms.sh +++ b/ct/librenms.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/livebook.sh b/ct/livebook.sh index 7c8f3276..5f801ac7 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/manyfold.sh b/ct/manyfold.sh index d5b46484..2d782d55 100644 --- a/ct/manyfold.sh +++ b/ct/manyfold.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/maxun.sh b/ct/maxun.sh index 78a865fa..a5561dc5 100644 --- a/ct/maxun.sh +++ b/ct/maxun.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/notesnook.sh b/ct/notesnook.sh index ddb87f82..3d1fbb3c 100644 --- a/ct/notesnook.sh +++ b/ct/notesnook.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/npmplus.sh b/ct/npmplus.sh index e6bb0b98..c3b1755a 100644 --- a/ct/npmplus.sh +++ b/ct/npmplus.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE MODE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 14 60 2 \ diff --git a/ct/opencloud.sh b/ct/opencloud.sh index e97c3af3..2c428f93 100644 --- a/ct/opencloud.sh +++ b/ct/opencloud.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/postiz.sh b/ct/postiz.sh index 32ec0ac3..e5355367 100644 --- a/ct/postiz.sh +++ b/ct/postiz.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/proxmox-datacenter-manager.sh b/ct/proxmox-datacenter-manager.sh index 57796383..dfcb1120 100644 --- a/ct/proxmox-datacenter-manager.sh +++ b/ct/proxmox-datacenter-manager.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/romm.sh b/ct/romm.sh index 771aed1d..129da9a3 100644 --- a/ct/romm.sh +++ b/ct/romm.sh @@ -18,7 +18,7 @@ var_fuse="${var_fuse:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/rybbit.sh b/ct/rybbit.sh index 6e3caddd..e523bde2 100644 --- a/ct/rybbit.sh +++ b/ct/rybbit.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/scraparr.sh b/ct/scraparr.sh index bca478df..efe595dd 100644 --- a/ct/scraparr.sh +++ b/ct/scraparr.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/signoz.sh b/ct/signoz.sh index 3e7d5bcc..6efeec71 100644 --- a/ct/signoz.sh +++ b/ct/signoz.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/tunarr.sh b/ct/tunarr.sh index 9af3bebc..f8d69769 100644 --- a/ct/tunarr.sh +++ b/ct/tunarr.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info check_container_storage diff --git a/ct/ubuntu.sh b/ct/ubuntu.sh index 5bae645b..f208d7d0 100644 --- a/ct/ubuntu.sh +++ b/ct/ubuntu.sh @@ -19,7 +19,7 @@ var_unprivileged="${var_unprivileged:-0}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/viseron.sh b/ct/viseron.sh index 6534ff2e..f65e15de 100644 --- a/ct/viseron.sh +++ b/ct/viseron.sh @@ -14,7 +14,7 @@ header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/wallabag.sh b/ct/wallabag.sh index 910948ff..9325189a 100644 --- a/ct/wallabag.sh +++ b/ct/wallabag.sh @@ -22,7 +22,7 @@ base_settings # Core variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/ct/warracker.sh b/ct/warracker.sh index d4707ac7..8e090b84 100644 --- a/ct/warracker.sh +++ b/ct/warracker.sh @@ -17,7 +17,7 @@ var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables color -init_error_traps +catch_errors function update_script() { header_info diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 882e2e61..43380844 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -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</etc/caddy/Caddyfile +cat </etc/caddy/Caddyfile :80 { # Set this path to your site's directory. root * /var/www/html @@ -31,7 +31,7 @@ cat</etc/caddy/Caddyfile } EOF mkdir -p /var/www/html -cat</var/www/html/index.html +cat </var/www/html/index.html @@ -47,15 +47,15 @@ msg_ok "Installed Caddy" read -r -p "${TAB3}Would you like to install xCaddy Addon? " 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" diff --git a/install/alpine-garage-install.sh b/install/alpine-garage-install.sh index c9ca62e5..5138656a 100644 --- a/install/alpine-garage-install.sh +++ b/install/alpine-garage-install.sh @@ -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 diff --git a/install/alpine-install.sh b/install/alpine-install.sh index 61acecea..4922f164 100644 --- a/install/alpine-install.sh +++ b/install/alpine-install.sh @@ -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 diff --git a/install/debian-install.sh b/install/debian-install.sh index b4e0bf32..e6259184 100644 --- a/install/debian-install.sh +++ b/install/debian-install.sh @@ -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 diff --git a/install/deferred/ampache-install.sh b/install/deferred/ampache-install.sh index 868c7f9a..35dfe143 100644 --- a/install/deferred/ampache-install.sh +++ b/install/deferred/ampache-install.sh @@ -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 diff --git a/install/deferred/freepbx-install_backup.sh b/install/deferred/freepbx-install_backup.sh index 5b42cc0e..a5d41953 100644 --- a/install/deferred/freepbx-install_backup.sh +++ b/install/deferred/freepbx-install_backup.sh @@ -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 diff --git a/install/deferred/funkwhale-install.sh b/install/deferred/funkwhale-install.sh index baf8f8e8..573abe1e 100644 --- a/install/deferred/funkwhale-install.sh +++ b/install/deferred/funkwhale-install.sh @@ -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 diff --git a/install/deferred/ghostfolio-install.sh b/install/deferred/ghostfolio-install.sh index 91e27db2..9a5d30e4 100644 --- a/install/deferred/ghostfolio-install.sh +++ b/install/deferred/ghostfolio-install.sh @@ -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 diff --git a/install/deferred/hoodik-install.sh b/install/deferred/hoodik-install.sh index 51ed398f..d6505fd4 100644 --- a/install/deferred/hoodik-install.sh +++ b/install/deferred/hoodik-install.sh @@ -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 diff --git a/install/deferred/jumpserver-install.sh b/install/deferred/jumpserver-install.sh index 23203327..4ccfb09e 100644 --- a/install/deferred/jumpserver-install.sh +++ b/install/deferred/jumpserver-install.sh @@ -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 diff --git a/install/deferred/kasm-install.sh b/install/deferred/kasm-install.sh index e55cd17c..236d15ba 100644 --- a/install/deferred/kasm-install.sh +++ b/install/deferred/kasm-install.sh @@ -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 diff --git a/install/deferred/koel-install.sh b/install/deferred/koel-install.sh index 4f033651..38c14d5f 100644 --- a/install/deferred/koel-install.sh +++ b/install/deferred/koel-install.sh @@ -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 diff --git a/install/deferred/netbootxyz-install.sh b/install/deferred/netbootxyz-install.sh index e3877293..1a7f71f7 100644 --- a/install/deferred/netbootxyz-install.sh +++ b/install/deferred/netbootxyz-install.sh @@ -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 diff --git a/install/deferred/nginxproxymanager-install.sh b/install/deferred/nginxproxymanager-install.sh index 3fd21279..34db0d6a 100644 --- a/install/deferred/nginxproxymanager-install.sh +++ b/install/deferred/nginxproxymanager-install.sh @@ -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 diff --git a/install/deferred/nimbus-install.sh b/install/deferred/nimbus-install.sh index 5940020c..c4943048 100644 --- a/install/deferred/nimbus-install.sh +++ b/install/deferred/nimbus-install.sh @@ -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 diff --git a/install/deferred/ocis-install.sh b/install/deferred/ocis-install.sh index 98be246e..987b0397 100644 --- a/install/deferred/ocis-install.sh +++ b/install/deferred/ocis-install.sh @@ -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 diff --git a/install/deferred/openwebui-install.sh b/install/deferred/openwebui-install.sh index 9eb6c3c0..0e9384d8 100644 --- a/install/deferred/openwebui-install.sh +++ b/install/deferred/openwebui-install.sh @@ -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 diff --git a/install/deferred/pixelfed-install.sh b/install/deferred/pixelfed-install.sh index 526922a4..0996ec33 100644 --- a/install/deferred/pixelfed-install.sh +++ b/install/deferred/pixelfed-install.sh @@ -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 diff --git a/install/deferred/polaris-install.sh b/install/deferred/polaris-install.sh index f9f70c6e..4f4e7727 100644 --- a/install/deferred/polaris-install.sh +++ b/install/deferred/polaris-install.sh @@ -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 diff --git a/install/deferred/roundcubemail-install.sh b/install/deferred/roundcubemail-install.sh index 40982d9c..cfa37f06 100644 --- a/install/deferred/roundcubemail-install.sh +++ b/install/deferred/roundcubemail-install.sh @@ -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 diff --git a/install/deferred/squirrelserversmanager-install.sh b/install/deferred/squirrelserversmanager-install.sh index 86eab5fb..9e6cedd0 100644 --- a/install/deferred/squirrelserversmanager-install.sh +++ b/install/deferred/squirrelserversmanager-install.sh @@ -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 diff --git a/install/deferred/timescaledb-install.sh b/install/deferred/timescaledb-install.sh index e5db3223..edcb20fa 100644 --- a/install/deferred/timescaledb-install.sh +++ b/install/deferred/timescaledb-install.sh @@ -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 diff --git a/install/deferred/vikunja-install.sh b/install/deferred/vikunja-install.sh index b51da342..f56d073d 100644 --- a/install/deferred/vikunja-install.sh +++ b/install/deferred/vikunja-install.sh @@ -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 diff --git a/install/dispatcharr-install.sh b/install/dispatcharr-install.sh index 17c23648..1daedb24 100644 --- a/install/dispatcharr-install.sh +++ b/install/dispatcharr-install.sh @@ -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 diff --git a/install/docspell-install.sh b/install/docspell-install.sh index 3cdf2b7c..43534d72 100644 --- a/install/docspell-install.sh +++ b/install/docspell-install.sh @@ -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 diff --git a/install/ente-install.sh b/install/ente-install.sh index f9afec8f..b08386d4 100644 --- a/install/ente-install.sh +++ b/install/ente-install.sh @@ -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 diff --git a/install/freepbx-install.sh b/install/freepbx-install.sh index 24c14a0a..4a4bd271 100644 --- a/install/freepbx-install.sh +++ b/install/freepbx-install.sh @@ -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 diff --git a/install/frigate-install.sh b/install/frigate-install.sh index e6852aaa..018261a1 100644 --- a/install/frigate-install.sh +++ b/install/frigate-install.sh @@ -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 diff --git a/install/garmin-grafana-install.sh b/install/garmin-grafana-install.sh index 23fb8797..70070f8c 100644 --- a/install/garmin-grafana-install.sh +++ b/install/garmin-grafana-install.sh @@ -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 diff --git a/install/ghostfolio-install.sh b/install/ghostfolio-install.sh index 7988124b..090b209b 100644 --- a/install/ghostfolio-install.sh +++ b/install/ghostfolio-install.sh @@ -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 diff --git a/install/globaleaks-install.sh b/install/globaleaks-install.sh index 966eb32d..650c8cbd 100644 --- a/install/globaleaks-install.sh +++ b/install/globaleaks-install.sh @@ -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 diff --git a/install/hanko-install.sh b/install/hanko-install.sh index 40ab829d..e1ec43c9 100644 --- a/install/hanko-install.sh +++ b/install/hanko-install.sh @@ -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 diff --git a/install/joplin-server-install.sh b/install/joplin-server-install.sh index 07b7920e..6187f565 100644 --- a/install/joplin-server-install.sh +++ b/install/joplin-server-install.sh @@ -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 diff --git a/install/kanba-install.sh b/install/kanba-install.sh index d7335fd5..10a306dd 100644 --- a/install/kanba-install.sh +++ b/install/kanba-install.sh @@ -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 diff --git a/install/leantime-install.sh b/install/leantime-install.sh index b5c2f5e7..98aa77a1 100644 --- a/install/leantime-install.sh +++ b/install/leantime-install.sh @@ -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 diff --git a/install/librenms-install.sh b/install/librenms-install.sh index 296f0351..ad1cbb6f 100644 --- a/install/librenms-install.sh +++ b/install/librenms-install.sh @@ -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 diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 251f078d..5d922b72 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -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 diff --git a/install/manyfold-install.sh b/install/manyfold-install.sh index be4dcd84..f7bb7c2f 100644 --- a/install/manyfold-install.sh +++ b/install/manyfold-install.sh @@ -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 diff --git a/install/maxun-install.sh b/install/maxun-install.sh index 27e3e710..004546bc 100644 --- a/install/maxun-install.sh +++ b/install/maxun-install.sh @@ -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 diff --git a/install/notesnook-install.sh b/install/notesnook-install.sh index ab95849e..cedb85ca 100644 --- a/install/notesnook-install.sh +++ b/install/notesnook-install.sh @@ -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 diff --git a/install/npmplus-install.sh b/install/npmplus-install.sh index e8e5f1bf..f63192c7 100644 --- a/install/npmplus-install.sh +++ b/install/npmplus-install.sh @@ -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 diff --git a/install/opencloud-install.sh b/install/opencloud-install.sh index a791ed0b..59f15950 100644 --- a/install/opencloud-install.sh +++ b/install/opencloud-install.sh @@ -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 diff --git a/install/postiz-install.sh b/install/postiz-install.sh index 2ed155c8..5b9e3592 100644 --- a/install/postiz-install.sh +++ b/install/postiz-install.sh @@ -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 diff --git a/install/proxmox-datacenter-manager-install.sh b/install/proxmox-datacenter-manager-install.sh index c4a3f387..e9a3c300 100644 --- a/install/proxmox-datacenter-manager-install.sh +++ b/install/proxmox-datacenter-manager-install.sh @@ -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 diff --git a/install/romm-install.sh b/install/romm-install.sh index bd5f9a28..438e4e5a 100644 --- a/install/romm-install.sh +++ b/install/romm-install.sh @@ -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 diff --git a/install/rybbit-install.sh b/install/rybbit-install.sh index 1f9481f9..055a101a 100644 --- a/install/rybbit-install.sh +++ b/install/rybbit-install.sh @@ -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 diff --git a/install/scraparr-install.sh b/install/scraparr-install.sh index 18b02425..8c0de782 100644 --- a/install/scraparr-install.sh +++ b/install/scraparr-install.sh @@ -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 diff --git a/install/signoz-install.sh b/install/signoz-install.sh index f506f315..fb52d12b 100644 --- a/install/signoz-install.sh +++ b/install/signoz-install.sh @@ -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 diff --git a/install/tunarr-install.sh b/install/tunarr-install.sh index 57d7f16e..854db713 100644 --- a/install/tunarr-install.sh +++ b/install/tunarr-install.sh @@ -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)? " prompt if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then - msg_info "Installing Intel Hardware Acceleration (non-free)" - cat </etc/apt/sources.list.d/non-free.list + msg_info "Installing Intel Hardware Acceleration (non-free)" + cat </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" diff --git a/install/ubuntu-install.sh b/install/ubuntu-install.sh index aa5766a0..97283d83 100644 --- a/install/ubuntu-install.sh +++ b/install/ubuntu-install.sh @@ -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 diff --git a/install/viseron-install.sh b/install/viseron-install.sh index 67cf18c4..e0835a59 100644 --- a/install/viseron-install.sh +++ b/install/viseron-install.sh @@ -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 diff --git a/install/wallabag-install.sh b/install/wallabag-install.sh index 3bcbce9c..2c1231d2 100644 --- a/install/wallabag-install.sh +++ b/install/wallabag-install.sh @@ -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 diff --git a/install/warracker-install.sh b/install/warracker-install.sh index 18ce630c..fb83fba0 100644 --- a/install/warracker-install.sh +++ b/install/warracker-install.sh @@ -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 diff --git a/misc/alpine-install.func b/misc/alpine-install.func index 0ba607ca..ce396f75 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -5,22 +5,22 @@ # https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE if ! command -v curl >/dev/null 2>&1; then - apk update && apk add curl >/dev/null 2>&1 + apk update && apk add curl >/dev/null 2>&1 fi source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) load_functions -init_error_traps +catch_errors # This function enables IPv6 if it's not disabled and sets verbose mode verb_ip6() { - set_std_mode # Set STD mode based on VERBOSE + set_std_mode # Set STD mode based on VERBOSE - if [ "$DISABLEIPV6" == "yes" ]; then - $STD sysctl -w net.ipv6.conf.all.disable_ipv6=1 - echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf - $STD rc-update add sysctl default - fi + if [ "$DISABLEIPV6" == "yes" ]; then + $STD sysctl -w net.ipv6.conf.all.disable_ipv6=1 + echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf + $STD rc-update add sysctl default + fi } set -Eeuo pipefail @@ -30,149 +30,149 @@ trap on_interrupt INT trap on_terminate TERM error_handler() { - local exit_code="$1" - local line_number="$2" - local command="$3" + local exit_code="$1" + local line_number="$2" + local command="$3" - # Exitcode 0 = kein Fehler → ignorieren - if [[ "$exit_code" -eq 0 ]]; then - return 0 - fi + # Exitcode 0 = kein Fehler → ignorieren + if [[ "$exit_code" -eq 0 ]]; then + return 0 + fi - printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}\n" - exit "$exit_code" + printf "\e[?25h" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}\n" + exit "$exit_code" } on_exit() { - local exit_code="$?" - [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" - exit "$exit_code" + local exit_code="$?" + [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" + exit "$exit_code" } on_interrupt() { - echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" - exit 130 + echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" + exit 130 } on_terminate() { - echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" - exit 143 + echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" + exit 143 } # This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection setting_up_container() { - msg_info "Setting up Container OS" - while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i - 1)) - done + msg_info "Setting up Container OS" + while [ $i -gt 0 ]; do + if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then + break + fi + echo 1>&2 -en "${CROSS}${RD} No Network! " + sleep $RETRY_EVERY + i=$((i - 1)) + done - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e "${NETWORK}Check Network Settings" - exit 1 - fi - msg_ok "Set up Container OS" - msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" + if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then + echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" + echo -e "${NETWORK}Check Network Settings" + exit 1 + fi + msg_ok "Set up Container OS" + msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" } # This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected network_check() { - set +e - trap - ERR - if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then - msg_ok "Internet Connected" - else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e "${INFO}${RD}Expect Issues Without Internet${CL}" + set +e + trap - ERR + if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then + msg_ok "Internet Connected" else - echo -e "${NETWORK}Check Network Settings" - exit 1 + msg_error "Internet NOT Connected" + read -r -p "Would you like to continue anyway? " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + echo -e "${INFO}${RD}Expect Issues Without Internet${CL}" + else + echo -e "${NETWORK}Check Network Settings" + exit 1 + fi fi - fi - RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') - if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi - set -e - trap 'error_handler $LINENO "$BASH_COMMAND"' ERR + RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') + if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi + set -e + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR } # This function updates the Container OS by running apt-get update and upgrade update_os() { - msg_info "Updating Container OS" - $STD apk update && $STD apk upgrade - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/alpine-tools.func) - msg_ok "Updated Container OS" + msg_info "Updating Container OS" + $STD apk update && $STD apk upgrade + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/alpine-tools.func) + msg_ok "Updated Container OS" } # This function modifies the message of the day (motd) and SSH settings motd_ssh() { - echo "export TERM='xterm-256color'" >>/root/.bashrc - IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1) + echo "export TERM='xterm-256color'" >>/root/.bashrc + IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1) - if [ -f "/etc/os-release" ]; then - OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"') - OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"') - else - OS_NAME="Alpine Linux" - OS_VERSION="Unknown" - fi + if [ -f "/etc/os-release" ]; then + OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"') + OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"') + else + OS_NAME="Alpine Linux" + OS_VERSION="Unknown" + fi - PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" - echo "echo -e \"\"" >"$PROFILE_FILE" - echo -e "echo -e \"${BOLD}${YW}${APPLICATION} LXC Container - DEV Repository${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${RD}WARNING: This is a DEVELOPMENT version (ProxmoxVED). Do NOT use in production!${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} IP Address: ${GN}${IP}${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} Repository: ${GN}https://github.com/community-scripts/ProxmoxVED${CL}\"" >>"$PROFILE_FILE" - echo "echo \"\"" >>"$PROFILE_FILE" + PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" + echo "echo -e \"\"" >"$PROFILE_FILE" + echo -e "echo -e \"${BOLD}${YW}${APPLICATION} LXC Container - DEV Repository${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${RD}WARNING: This is a DEVELOPMENT version (ProxmoxVED). Do NOT use in production!${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} IP Address: ${GN}${IP}${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} Repository: ${GN}https://github.com/community-scripts/ProxmoxVED${CL}\"" >>"$PROFILE_FILE" + echo "echo \"\"" >>"$PROFILE_FILE" - if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config - $STD /etc/init.d/sshd start - fi + if [[ "${SSH_ROOT}" == "yes" ]]; then + $STD rc-update add sshd + sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config + $STD /etc/init.d/sshd start + fi } # Validate Timezone for some LXC's validate_tz() { - [[ -f "/usr/share/zoneinfo/$1" ]] + [[ -f "/usr/share/zoneinfo/$1" ]] } # This function customizes the container and enables passwordless login for the root user customize() { - if [[ "$PASSWORD" == "" ]]; then - msg_info "Customizing Container" - passwd -d root >/dev/null 2>&1 + if [[ "$PASSWORD" == "" ]]; then + msg_info "Customizing Container" + passwd -d root >/dev/null 2>&1 - # Ensure agetty is available - apk add --no-cache --force-broken-world util-linux >/dev/null 2>&1 + # Ensure agetty is available + apk add --no-cache --force-broken-world util-linux >/dev/null 2>&1 - # Create persistent autologin boot script - mkdir -p /etc/local.d - cat <<'EOF' >/etc/local.d/autologin.start + # Create persistent autologin boot script + mkdir -p /etc/local.d + cat <<'EOF' >/etc/local.d/autologin.start #!/bin/sh sed -i 's|^tty1::respawn:.*|tty1::respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab kill -HUP 1 EOF - touch /root/.hushlogin + touch /root/.hushlogin - chmod +x /etc/local.d/autologin.start - rc-update add local >/dev/null 2>&1 + chmod +x /etc/local.d/autologin.start + rc-update add local >/dev/null 2>&1 - # Apply autologin immediately for current session - /etc/local.d/autologin.start + # Apply autologin immediately for current session + /etc/local.d/autologin.start - msg_ok "Customized Container" - fi + msg_ok "Customized Container" + fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update - chmod +x /usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + chmod +x /usr/bin/update } diff --git a/misc/build.func b/misc/build.func index 1802ab0d..c112f27d 100644 --- a/misc/build.func +++ b/misc/build.func @@ -134,13 +134,13 @@ if command -v curl >/dev/null 2>&1; then source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) load_functions - init_error_traps + catch_errors #echo "(build.func) Loaded core.func via curl" elif command -v wget >/dev/null 2>&1; then source <(wget -qO- https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) source <(wget -qO- https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) load_functions - init_error_traps + catch_errors #echo "(build.func) Loaded core.func via wget" fi diff --git a/misc/error_handler.func b/misc/error_handler.func index 21996969..d2f21d08 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -8,141 +8,141 @@ # ------------------------------------------------------------------------------ explain_exit_code() { - local code="$1" - case "$code" in - # --- Generic / Shell --- - 1) echo "General error / Operation not permitted" ;; - 2) echo "Misuse of shell builtins (e.g. syntax error)" ;; - 126) echo "Command invoked cannot execute (permission problem?)" ;; - 127) echo "Command not found" ;; - 128) echo "Invalid argument to exit" ;; - 130) echo "Terminated by Ctrl+C (SIGINT)" ;; - 137) echo "Killed (SIGKILL / Out of memory?)" ;; - 139) echo "Segmentation fault (core dumped)" ;; - 143) echo "Terminated (SIGTERM)" ;; + local code="$1" + case "$code" in + # --- Generic / Shell --- + 1) echo "General error / Operation not permitted" ;; + 2) echo "Misuse of shell builtins (e.g. syntax error)" ;; + 126) echo "Command invoked cannot execute (permission problem?)" ;; + 127) echo "Command not found" ;; + 128) echo "Invalid argument to exit" ;; + 130) echo "Terminated by Ctrl+C (SIGINT)" ;; + 137) echo "Killed (SIGKILL / Out of memory?)" ;; + 139) echo "Segmentation fault (core dumped)" ;; + 143) echo "Terminated (SIGTERM)" ;; - # --- Package manager / APT / DPKG --- - 100) echo "APT: Package manager error (broken packages / dependency problems)" ;; - 101) echo "APT: Configuration error (bad sources.list, malformed config)" ;; - 255) echo "DPKG: Fatal internal error" ;; + # --- Package manager / APT / DPKG --- + 100) echo "APT: Package manager error (broken packages / dependency problems)" ;; + 101) echo "APT: Configuration error (bad sources.list, malformed config)" ;; + 255) echo "DPKG: Fatal internal error" ;; - # --- Node.js / npm / pnpm / yarn --- - 243) echo "Node.js: Out of memory (JavaScript heap out of memory)" ;; - 245) echo "Node.js: Invalid command-line option" ;; - 246) echo "Node.js: Internal JavaScript Parse Error" ;; - 247) echo "Node.js: Fatal internal error" ;; - 248) echo "Node.js: Invalid C++ addon / N-API failure" ;; - 249) echo "Node.js: Inspector error" ;; - 254) echo "npm/pnpm/yarn: Unknown fatal error" ;; + # --- Node.js / npm / pnpm / yarn --- + 243) echo "Node.js: Out of memory (JavaScript heap out of memory)" ;; + 245) echo "Node.js: Invalid command-line option" ;; + 246) echo "Node.js: Internal JavaScript Parse Error" ;; + 247) echo "Node.js: Fatal internal error" ;; + 248) echo "Node.js: Invalid C++ addon / N-API failure" ;; + 249) echo "Node.js: Inspector error" ;; + 254) echo "npm/pnpm/yarn: Unknown fatal error" ;; - # --- Python / pip / uv --- - 210) echo "Python: Virtualenv / uv environment missing or broken" ;; - 211) echo "Python: Dependency resolution failed" ;; - 212) echo "Python: Installation aborted (permissions or EXTERNALLY-MANAGED)" ;; + # --- Python / pip / uv --- + 210) echo "Python: Virtualenv / uv environment missing or broken" ;; + 211) echo "Python: Dependency resolution failed" ;; + 212) echo "Python: Installation aborted (permissions or EXTERNALLY-MANAGED)" ;; - # --- PostgreSQL --- - 231) echo "PostgreSQL: Connection failed (server not running / wrong socket)" ;; - 232) echo "PostgreSQL: Authentication failed (bad user/password)" ;; - 233) echo "PostgreSQL: Database does not exist" ;; - 234) echo "PostgreSQL: Fatal error in query / syntax" ;; + # --- PostgreSQL --- + 231) echo "PostgreSQL: Connection failed (server not running / wrong socket)" ;; + 232) echo "PostgreSQL: Authentication failed (bad user/password)" ;; + 233) echo "PostgreSQL: Database does not exist" ;; + 234) echo "PostgreSQL: Fatal error in query / syntax" ;; - # --- MySQL / MariaDB --- - 241) echo "MySQL/MariaDB: Connection failed (server not running / wrong socket)" ;; - 242) echo "MySQL/MariaDB: Authentication failed (bad user/password)" ;; - 243) echo "MySQL/MariaDB: Database does not exist" ;; - 244) echo "MySQL/MariaDB: Fatal error in query / syntax" ;; + # --- MySQL / MariaDB --- + 241) echo "MySQL/MariaDB: Connection failed (server not running / wrong socket)" ;; + 242) echo "MySQL/MariaDB: Authentication failed (bad user/password)" ;; + 243) echo "MySQL/MariaDB: Database does not exist" ;; + 244) echo "MySQL/MariaDB: Fatal error in query / syntax" ;; - # --- MongoDB --- - 251) echo "MongoDB: Connection failed (server not running)" ;; - 252) echo "MongoDB: Authentication failed (bad user/password)" ;; - 253) echo "MongoDB: Database not found" ;; - 254) echo "MongoDB: Fatal query error" ;; + # --- MongoDB --- + 251) echo "MongoDB: Connection failed (server not running)" ;; + 252) echo "MongoDB: Authentication failed (bad user/password)" ;; + 253) echo "MongoDB: Database not found" ;; + 254) echo "MongoDB: Fatal query error" ;; - # --- Proxmox Custom Codes --- - 200) echo "Custom: Failed to create lock file" ;; - 203) echo "Custom: Missing CTID variable" ;; - 204) echo "Custom: Missing PCT_OSTYPE variable" ;; - 205) echo "Custom: Invalid CTID (<100)" ;; - 209) echo "Custom: Container creation failed" ;; - 210) echo "Custom: Cluster not quorate" ;; - 214) echo "Custom: Not enough storage space" ;; - 215) echo "Custom: Container ID not listed" ;; - 216) echo "Custom: RootFS entry missing in config" ;; - 217) echo "Custom: Storage does not support rootdir" ;; - 220) echo "Custom: Unable to resolve template path" ;; - 222) echo "Custom: Template download failed after 3 attempts" ;; - 223) echo "Custom: Template not available after download" ;; - 231) echo "Custom: LXC stack upgrade/retry failed" ;; + # --- Proxmox Custom Codes --- + 200) echo "Custom: Failed to create lock file" ;; + 203) echo "Custom: Missing CTID variable" ;; + 204) echo "Custom: Missing PCT_OSTYPE variable" ;; + 205) echo "Custom: Invalid CTID (<100)" ;; + 209) echo "Custom: Container creation failed" ;; + 210) echo "Custom: Cluster not quorate" ;; + 214) echo "Custom: Not enough storage space" ;; + 215) echo "Custom: Container ID not listed" ;; + 216) echo "Custom: RootFS entry missing in config" ;; + 217) echo "Custom: Storage does not support rootdir" ;; + 220) echo "Custom: Unable to resolve template path" ;; + 222) echo "Custom: Template download failed after 3 attempts" ;; + 223) echo "Custom: Template not available after download" ;; + 231) echo "Custom: LXC stack upgrade/retry failed" ;; - # --- Default --- - *) echo "Unknown error" ;; - esac + # --- Default --- + *) echo "Unknown error" ;; + esac } # === Error handler ============================================================ error_handler() { - local exit_code=${1:-$?} - local command=${2:-${BASH_COMMAND:-unknown}} - local line_number=${BASH_LINENO[0]:-unknown} + local exit_code=${1:-$?} + local command=${2:-${BASH_COMMAND:-unknown}} + local line_number=${BASH_LINENO[0]:-unknown} - command="${command//\$STD/}" + command="${command//\$STD/}" - if [[ "$exit_code" -eq 0 ]]; then - return 0 - fi + if [[ "$exit_code" -eq 0 ]]; then + return 0 + fi - local explanation - explanation="$(explain_exit_code "$exit_code")" + local explanation + explanation="$(explain_exit_code "$exit_code")" - printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YWB}${command}${CL}\n" + printf "\e[?25h" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YWB}${command}${CL}\n" - if [[ -n "${DEBUG_LOGFILE:-}" ]]; then - { - echo "------ ERROR ------" - echo "Timestamp : $(date '+%Y-%m-%d %H:%M:%S')" - echo "Exit Code : $exit_code ($explanation)" - echo "Line : $line_number" - echo "Command : $command" - echo "-------------------" - } >>"$DEBUG_LOGFILE" - fi + if [[ -n "${DEBUG_LOGFILE:-}" ]]; then + { + echo "------ ERROR ------" + echo "Timestamp : $(date '+%Y-%m-%d %H:%M:%S')" + echo "Exit Code : $exit_code ($explanation)" + echo "Line : $line_number" + echo "Command : $command" + echo "-------------------" + } >>"$DEBUG_LOGFILE" + fi - if [[ -n "${SILENT_LOGFILE:-}" && -s "$SILENT_LOGFILE" ]]; then - echo "--- Last 20 lines of silent log ($SILENT_LOGFILE) ---" - tail -n 20 "$SILENT_LOGFILE" - echo "---------------------------------------------------" - fi + if [[ -n "${SILENT_LOGFILE:-}" && -s "$SILENT_LOGFILE" ]]; then + echo "--- Last 20 lines of silent log ($SILENT_LOGFILE) ---" + tail -n 20 "$SILENT_LOGFILE" + echo "---------------------------------------------------" + fi - exit "$exit_code" + exit "$exit_code" } # === Exit handler ============================================================= on_exit() { - local exit_code=$? - [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" - exit "$exit_code" + local exit_code=$? + [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" + exit "$exit_code" } # === Signal handlers ========================================================== on_interrupt() { - echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" - exit 130 + echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" + exit 130 } on_terminate() { - echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" - exit 143 + echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" + exit 143 } # === Init traps =============================================================== -init_error_traps() { - set -Ee -o pipefail - if [ "${STRICT_UNSET:-0}" = "1" ]; then - set -u - fi - trap 'error_handler' ERR - trap on_exit EXIT - trap on_interrupt INT - trap on_terminate TERM +catch_errors() { + set -Ee -o pipefail + if [ "${STRICT_UNSET:-0}" = "1" ]; then + set -u + fi + trap 'error_handler' ERR + trap on_exit EXIT + trap on_interrupt INT + trap on_terminate TERM } diff --git a/misc/install.func b/misc/install.func index b27bfc01..f741b921 100644 --- a/misc/install.func +++ b/misc/install.func @@ -5,23 +5,23 @@ # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE if ! command -v curl >/dev/null 2>&1; then - printf "\r\e[2K%b" '\033[93m Setup Source \033[m' >&2 - apt-get update >/dev/null 2>&1 - apt-get install -y curl >/dev/null 2>&1 + printf "\r\e[2K%b" '\033[93m Setup Source \033[m' >&2 + apt-get update >/dev/null 2>&1 + apt-get install -y curl >/dev/null 2>&1 fi source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) load_functions -init_error_traps +catch_errors # This function enables IPv6 if it's not disabled and sets verbose mode verb_ip6() { - set_std_mode # Set STD mode based on VERBOSE + set_std_mode # Set STD mode based on VERBOSE - if [ "$DISABLEIPV6" == "yes" ]; then - echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf - $STD sysctl -p - fi + if [ "$DISABLEIPV6" == "yes" ]; then + echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf + $STD sysctl -p + fi } # # This function sets error handling options and defines the error_handler function to handle errors @@ -48,92 +48,92 @@ verb_ip6() { # This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection setting_up_container() { - msg_info "Setting up Container OS" - for ((i = RETRY_NUM; i > 0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break + msg_info "Setting up Container OS" + for ((i = RETRY_NUM; i > 0; i--)); do + if [ "$(hostname -I)" != "" ]; then + break + fi + echo 1>&2 -en "${CROSS}${RD} No Network! " + sleep $RETRY_EVERY + done + if [ "$(hostname -I)" = "" ]; then + echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" + echo -e "${NETWORK}Check Network Settings" + exit 1 fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - done - if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e "${NETWORK}Check Network Settings" - exit 1 - fi - rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED - systemctl disable -q --now systemd-networkd-wait-online.service - msg_ok "Set up Container OS" - #msg_custom "${CM}" "${GN}" "Network Connected: ${BL}$(hostname -I)" - msg_ok "Network Connected: ${BL}$(hostname -I)" + rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED + systemctl disable -q --now systemd-networkd-wait-online.service + msg_ok "Set up Container OS" + #msg_custom "${CM}" "${GN}" "Network Connected: ${BL}$(hostname -I)" + msg_ok "Network Connected: ${BL}$(hostname -I)" } # This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected network_check() { - set +e - trap - ERR - ipv4_connected=false - ipv6_connected=false - sleep 1 + set +e + trap - ERR + ipv4_connected=false + ipv6_connected=false + sleep 1 - # Check IPv4 connectivity to Google, Cloudflare & Quad9 DNS servers. - if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then - msg_ok "IPv4 Internet Connected" - ipv4_connected=true - else - msg_error "IPv4 Internet Not Connected" - fi - - # Check IPv6 connectivity to Google, Cloudflare & Quad9 DNS servers. - if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null || ping6 -c 1 -W 1 2001:4860:4860::8888 &>/dev/null || ping6 -c 1 -W 1 2620:fe::fe &>/dev/null; then - msg_ok "IPv6 Internet Connected" - ipv6_connected=true - else - msg_error "IPv6 Internet Not Connected" - fi - - # If both IPv4 and IPv6 checks fail, prompt the user - if [[ $ipv4_connected == false && $ipv6_connected == false ]]; then - read -r -p "No Internet detected, would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e "${INFO}${RD}Expect Issues Without Internet${CL}" + # Check IPv4 connectivity to Google, Cloudflare & Quad9 DNS servers. + if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then + msg_ok "IPv4 Internet Connected" + ipv4_connected=true else - echo -e "${NETWORK}Check Network Settings" - exit 1 + msg_error "IPv4 Internet Not Connected" fi - fi - # DNS resolution checks for GitHub-related domains (IPv4 and/or IPv6) - GIT_HOSTS=("github.com" "raw.githubusercontent.com" "api.github.com" "git.community-scripts.org") - GIT_STATUS="Git DNS:" - DNS_FAILED=false - - for HOST in "${GIT_HOSTS[@]}"; do - RESOLVEDIP=$(getent hosts "$HOST" | awk '{ print $1 }' | grep -E '(^([0-9]{1,3}\.){3}[0-9]{1,3}$)|(^[a-fA-F0-9:]+$)' | head -n1) - if [[ -z "$RESOLVEDIP" ]]; then - GIT_STATUS+="$HOST:($DNSFAIL)" - DNS_FAILED=true + # Check IPv6 connectivity to Google, Cloudflare & Quad9 DNS servers. + if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null || ping6 -c 1 -W 1 2001:4860:4860::8888 &>/dev/null || ping6 -c 1 -W 1 2620:fe::fe &>/dev/null; then + msg_ok "IPv6 Internet Connected" + ipv6_connected=true else - GIT_STATUS+=" $HOST:($DNSOK)" + msg_error "IPv6 Internet Not Connected" fi - done - if [[ "$DNS_FAILED" == true ]]; then - fatal "$GIT_STATUS" - else - msg_ok "$GIT_STATUS" - fi + # If both IPv4 and IPv6 checks fail, prompt the user + if [[ $ipv4_connected == false && $ipv6_connected == false ]]; then + read -r -p "No Internet detected, would you like to continue anyway? " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + echo -e "${INFO}${RD}Expect Issues Without Internet${CL}" + else + echo -e "${NETWORK}Check Network Settings" + exit 1 + fi + fi - set -e - trap 'error_handler $LINENO "$BASH_COMMAND"' ERR + # DNS resolution checks for GitHub-related domains (IPv4 and/or IPv6) + GIT_HOSTS=("github.com" "raw.githubusercontent.com" "api.github.com" "git.community-scripts.org") + GIT_STATUS="Git DNS:" + DNS_FAILED=false + + for HOST in "${GIT_HOSTS[@]}"; do + RESOLVEDIP=$(getent hosts "$HOST" | awk '{ print $1 }' | grep -E '(^([0-9]{1,3}\.){3}[0-9]{1,3}$)|(^[a-fA-F0-9:]+$)' | head -n1) + if [[ -z "$RESOLVEDIP" ]]; then + GIT_STATUS+="$HOST:($DNSFAIL)" + DNS_FAILED=true + else + GIT_STATUS+=" $HOST:($DNSOK)" + fi + done + + if [[ "$DNS_FAILED" == true ]]; then + fatal "$GIT_STATUS" + else + msg_ok "$GIT_STATUS" + fi + + set -e + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR } # This function updates the Container OS by running apt-get update and upgrade update_os() { - msg_info "Updating Container OS" - if [[ "$CACHER" == "yes" ]]; then - echo "Acquire::http::Proxy-Auto-Detect \"/usr/local/bin/apt-proxy-detect.sh\";" >/etc/apt/apt.conf.d/00aptproxy - cat <<'EOF' >/usr/local/bin/apt-proxy-detect.sh + msg_info "Updating Container OS" + if [[ "$CACHER" == "yes" ]]; then + echo "Acquire::http::Proxy-Auto-Detect \"/usr/local/bin/apt-proxy-detect.sh\";" >/etc/apt/apt.conf.d/00aptproxy + cat <<'EOF' >/usr/local/bin/apt-proxy-detect.sh #!/bin/bash if nc -w1 -z "${CACHER_IP}" 3142; then echo -n "http://${CACHER_IP}:3142" @@ -141,66 +141,66 @@ else echo -n "DIRECT" fi EOF - chmod +x /usr/local/bin/apt-proxy-detect.sh - fi - $STD apt-get update - $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade - rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED - msg_ok "Updated Container OS" - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) + chmod +x /usr/local/bin/apt-proxy-detect.sh + fi + $STD apt-get update + $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade + rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED + msg_ok "Updated Container OS" + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) } # This function modifies the message of the day (motd) and SSH settings motd_ssh() { - grep -qxF "export TERM='xterm-256color'" /root/.bashrc || echo "export TERM='xterm-256color'" >>/root/.bashrc + grep -qxF "export TERM='xterm-256color'" /root/.bashrc || echo "export TERM='xterm-256color'" >>/root/.bashrc - if [ -f "/etc/os-release" ]; then - OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"') - OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"') - elif [ -f "/etc/debian_version" ]; then - OS_NAME="Debian" - OS_VERSION=$(cat /etc/debian_version) - fi + if [ -f "/etc/os-release" ]; then + OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"') + OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"') + elif [ -f "/etc/debian_version" ]; then + OS_NAME="Debian" + OS_VERSION=$(cat /etc/debian_version) + fi - PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" - echo "echo -e \"\"" >"$PROFILE_FILE" - echo -e "echo -e \"${BOLD}${YW}${APPLICATION} LXC Container - DEV Repository${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${RD}WARNING: This is a DEVELOPMENT version (ProxmoxVED). Do NOT use in production!${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} IP Address: ${GN}\$(hostname -I | awk '{print \$1}')${CL}\"" >>"$PROFILE_FILE" - echo -e "echo -e \"${YW} Repository: ${GN}https://github.com/community-scripts/ProxmoxVED${CL}\"" >>"$PROFILE_FILE" - echo "echo \"\"" >>"$PROFILE_FILE" + PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" + echo "echo -e \"\"" >"$PROFILE_FILE" + echo -e "echo -e \"${BOLD}${YW}${APPLICATION} LXC Container - DEV Repository${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${RD}WARNING: This is a DEVELOPMENT version (ProxmoxVED). Do NOT use in production!${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} IP Address: ${GN}\$(hostname -I | awk '{print \$1}')${CL}\"" >>"$PROFILE_FILE" + echo -e "echo -e \"${YW} Repository: ${GN}https://github.com/community-scripts/ProxmoxVED${CL}\"" >>"$PROFILE_FILE" + echo "echo \"\"" >>"$PROFILE_FILE" - chmod -x /etc/update-motd.d/* + chmod -x /etc/update-motd.d/* - if [[ "${SSH_ROOT}" == "yes" ]]; then - sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config - systemctl restart sshd - fi + if [[ "${SSH_ROOT}" == "yes" ]]; then + sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config + systemctl restart sshd + fi } # This function customizes the container by modifying the getty service and enabling auto-login for the root user customize() { - if [[ "$PASSWORD" == "" ]]; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE + if [[ "$PASSWORD" == "" ]]; then + msg_info "Customizing Container" + GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" + mkdir -p $(dirname $GETTY_OVERRIDE) + cat <$GETTY_OVERRIDE [Service] ExecStart= ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" - fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update - chmod +x /usr/bin/update - if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then - mkdir -p /root/.ssh - echo "${SSH_AUTHORIZED_KEY}" >/root/.ssh/authorized_keys - chmod 700 /root/.ssh - chmod 600 /root/.ssh/authorized_keys - fi + systemctl daemon-reload + systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') + msg_ok "Customized Container" + fi + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + chmod +x /usr/bin/update + if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then + mkdir -p /root/.ssh + echo "${SSH_AUTHORIZED_KEY}" >/root/.ssh/authorized_keys + chmod 700 /root/.ssh + chmod 600 /root/.ssh/authorized_keys + fi }