From 9140fd52acd532b263f100f7ef0a6139000d8376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Mon, 12 May 2025 16:07:07 +0200 Subject: [PATCH] Use onliner for updates (#4414) --- .../scripts/app-test/pr-alpine-install.func | 5 +- ct/alpine-adguard.sh | 23 +++++---- ct/alpine-docker.sh | 4 +- ct/alpine-gitea.sh | 23 +++++---- ct/alpine-grafana.sh | 4 +- ct/alpine-mariadb.sh | 21 ++++---- ct/alpine-node-red.sh | 27 +++++------ ct/alpine-postgresql.sh | 3 +- ct/alpine-prometheus.sh | 21 ++++---- ct/alpine-tinyauth.sh | 3 +- ct/alpine-vaultwarden.sh | 7 +-- ct/alpine-wireguard.sh | 3 +- ct/alpine-zigbee2mqtt.sh | 4 +- ct/alpine.sh | 2 +- ct/npmplus.sh | 48 +++++++++---------- frontend/public/json/alpine.json | 2 +- misc/alpine-install.func | 3 +- tools/pve/update-lxcs-cron.sh | 14 +++--- tools/pve/update-lxcs.sh | 4 +- 19 files changed, 106 insertions(+), 115 deletions(-) diff --git a/.github/workflows/scripts/app-test/pr-alpine-install.func b/.github/workflows/scripts/app-test/pr-alpine-install.func index ae3bc174d..b76d38564 100644 --- a/.github/workflows/scripts/app-test/pr-alpine-install.func +++ b/.github/workflows/scripts/app-test/pr-alpine-install.func @@ -72,8 +72,7 @@ network_check() { update_os() { msg_info "Updating Container OS" - apk update - apk upgrade + $STD apk -U upgrade msg_ok "Updated Container OS" } @@ -83,4 +82,4 @@ motd_ssh() { customize() { return -} \ No newline at end of file +} diff --git a/ct/alpine-adguard.sh b/ct/alpine-adguard.sh index c5d43a7db..b04adf729 100644 --- a/ct/alpine-adguard.sh +++ b/ct/alpine-adguard.sh @@ -20,21 +20,20 @@ color catch_errors function update_script() { - header_info - msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade - msg_ok "Updated Alpine Packages" + header_info + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" - msg_info "Updating AdGuard Home" - $STD /opt/AdGuardHome/AdGuardHome --update - msg_ok "Updated AdGuard Home" + msg_info "Updating AdGuard Home" + $STD /opt/AdGuardHome/AdGuardHome --update + msg_ok "Updated AdGuard Home" - msg_info "Restarting AdGuard Home" - $STD rc-service adguardhome restart - msg_ok "Restarted AdGuard Home" + msg_info "Restarting AdGuard Home" + $STD rc-service adguardhome restart + msg_ok "Restarted AdGuard Home" - exit 0 + exit 0 } start diff --git a/ct/alpine-docker.sh b/ct/alpine-docker.sh index 18629137c..da417e406 100644 --- a/ct/alpine-docker.sh +++ b/ct/alpine-docker.sh @@ -36,7 +36,7 @@ function update_script() { header_info case $CHOICE in 1) - apk update && apk upgrade + $STD apk -U upgrade exit ;; esac @@ -47,4 +47,4 @@ start build_container description -msg_ok "Completed Successfully!\n" \ No newline at end of file +msg_ok "Completed Successfully!\n" diff --git a/ct/alpine-gitea.sh b/ct/alpine-gitea.sh index c7d0b3720..9dceb48f1 100644 --- a/ct/alpine-gitea.sh +++ b/ct/alpine-gitea.sh @@ -20,19 +20,18 @@ color catch_errors function update_script() { - header_info - msg_info "Updating Alpine Packages" - apk update - apk upgrade - msg_ok "Updated Alpine Packages" + header_info + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" - msg_info "Updating Gitea" - apk upgrade gitea - msg_ok "Updated Gitea" + msg_info "Updating Gitea" + apk upgrade gitea + msg_ok "Updated Gitea" - msg_info "Restarting Gitea" - rc-service gitea restart - msg_ok "Restarted Gitea" + msg_info "Restarting Gitea" + rc-service gitea restart + msg_ok "Restarted Gitea" } start @@ -42,4 +41,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/ct/alpine-grafana.sh b/ct/alpine-grafana.sh index a4a22ee12..f2df965e0 100644 --- a/ct/alpine-grafana.sh +++ b/ct/alpine-grafana.sh @@ -39,7 +39,7 @@ function update_script() { header_info case $CHOICE in 1) - apk update && apk upgrade + $STD apk -U upgrade exit ;; 2) @@ -62,4 +62,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" \ No newline at end of file + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-mariadb.sh b/ct/alpine-mariadb.sh index aa6337283..154924c04 100644 --- a/ct/alpine-mariadb.sh +++ b/ct/alpine-mariadb.sh @@ -20,20 +20,19 @@ color catch_errors function update_script() { - msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade - msg_ok "Updated Alpine Packages" + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" - msg_info "Updating MariaDB" - $STD apk upgrade mariadb mariadb-client - msg_ok "Updated MariaDB" + msg_info "Updating MariaDB" + $STD apk upgrade mariadb mariadb-client + msg_ok "Updated MariaDB" - msg_info "Restarting MariaDB" - $STD rc-service mariadb restart - msg_ok "Restarted MariaDB" + msg_info "Restarting MariaDB" + $STD rc-service mariadb restart + msg_ok "Restarted MariaDB" - exit 0 + exit 0 } start diff --git a/ct/alpine-node-red.sh b/ct/alpine-node-red.sh index c9afc6888..727cb3808 100644 --- a/ct/alpine-node-red.sh +++ b/ct/alpine-node-red.sh @@ -20,24 +20,23 @@ color catch_errors function update_script() { - msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade - msg_ok "Updated Alpine Packages" + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" - msg_info "Updating Node.js and npm" - $STD apk upgrade nodejs npm - msg_ok "Updated Node.js and npm" + msg_info "Updating Node.js and npm" + $STD apk upgrade nodejs npm + msg_ok "Updated Node.js and npm" - msg_info "Updating Node-RED" - $STD npm install -g --unsafe-perm node-red - msg_ok "Updated Node-RED" + msg_info "Updating Node-RED" + $STD npm install -g --unsafe-perm node-red + msg_ok "Updated Node-RED" - msg_info "Restarting Node-RED" - $STD rc-service nodered restart - msg_ok "Restarted Node-RED" + msg_info "Restarting Node-RED" + $STD rc-service nodered restart + msg_ok "Restarted Node-RED" - exit 0 + exit 0 } start diff --git a/ct/alpine-postgresql.sh b/ct/alpine-postgresql.sh index c8afad0f1..3d611d592 100644 --- a/ct/alpine-postgresql.sh +++ b/ct/alpine-postgresql.sh @@ -21,8 +21,7 @@ catch_errors function update_script() { msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade + $STD apk -U upgrade msg_ok "Updated Alpine Packages" msg_info "Updating PostgreSQL" diff --git a/ct/alpine-prometheus.sh b/ct/alpine-prometheus.sh index bb3066edc..b8140b2e3 100644 --- a/ct/alpine-prometheus.sh +++ b/ct/alpine-prometheus.sh @@ -20,20 +20,19 @@ color catch_errors function update_script() { - msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade - msg_ok "Updated Alpine Packages" + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" - msg_info "Updating Prometheus" - $STD apk upgrade prometheus - msg_ok "Updated Prometheus" + msg_info "Updating Prometheus" + $STD apk upgrade prometheus + msg_ok "Updated Prometheus" - msg_info "Restarting Prometheus" - $STD rc-service prometheus restart - msg_ok "Restarted Prometheus" + msg_info "Restarting Prometheus" + $STD rc-service prometheus restart + msg_ok "Restarted Prometheus" - exit 0 + exit 0 } start diff --git a/ct/alpine-tinyauth.sh b/ct/alpine-tinyauth.sh index fec46ba0a..f36a7be7f 100644 --- a/ct/alpine-tinyauth.sh +++ b/ct/alpine-tinyauth.sh @@ -26,8 +26,7 @@ function update_script() { fi msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade + $STD apk -U upgrade msg_ok "Updated Alpine Packages" msg_info "Updating tinyauth" diff --git a/ct/alpine-vaultwarden.sh b/ct/alpine-vaultwarden.sh index be683f1c2..5ccb8f0c8 100644 --- a/ct/alpine-vaultwarden.sh +++ b/ct/alpine-vaultwarden.sh @@ -37,14 +37,15 @@ function update_script() { header_info case $CHOICE in 1) - apk update && apk upgrade && rc-service vaultwarden restart -q + $STD apk -U upgrade + rc-service vaultwarden restart -q exit ;; 2) if NEWTOKEN=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "Setup your ADMIN_TOKEN (make it strong)" 10 58 3>&1 1>&2 2>&3); then if [[ -z "$NEWTOKEN" ]]; then exit-script; fi if ! command -v argon2 >/dev/null 2>&1; then apk add argon2 &>/dev/null; fi - TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1) + TOKEN=$(echo -n "${NEWTOKEN}" | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1) if [[ ! -f /var/lib/vaultwarden/config.json ]]; then sed -i "s|export ADMIN_TOKEN=.*|export ADMIN_TOKEN='${TOKEN}'|" /etc/conf.d/vaultwarden else @@ -65,4 +66,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" \ No newline at end of file + ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/alpine-wireguard.sh b/ct/alpine-wireguard.sh index a217aa457..a715e5918 100644 --- a/ct/alpine-wireguard.sh +++ b/ct/alpine-wireguard.sh @@ -21,8 +21,7 @@ catch_errors function update_script() { msg_info "Updating Alpine Packages" - $STD apk update - $STD apk upgrade + $STD apk -U upgrade msg_ok "Updated Alpine Packages" msg_info "update wireguard-tools" diff --git a/ct/alpine-zigbee2mqtt.sh b/ct/alpine-zigbee2mqtt.sh index 40e93272f..0af68ea97 100644 --- a/ct/alpine-zigbee2mqtt.sh +++ b/ct/alpine-zigbee2mqtt.sh @@ -36,7 +36,7 @@ function update_script() { header_info case $CHOICE in 1) - apk update && apk upgrade + $STD apk -U upgrade exit ;; esac @@ -47,4 +47,4 @@ start build_container description -msg_ok "Completed Successfully!\n" \ No newline at end of file +msg_ok "Completed Successfully!\n" diff --git a/ct/alpine.sh b/ct/alpine.sh index 95ea5d841..9a636fafd 100644 --- a/ct/alpine.sh +++ b/ct/alpine.sh @@ -28,7 +28,7 @@ function update_script() { header_info if [ "$UPD" == "1" ]; then - apk update && apk upgrade + $STD apk -U upgrade exit fi } diff --git a/ct/npmplus.sh b/ct/npmplus.sh index d0b2dbe10..2c2994905 100644 --- a/ct/npmplus.sh +++ b/ct/npmplus.sh @@ -20,32 +20,32 @@ color 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 \ - "1" "Check for Alpine Updates" OFF \ - "2" "Update NPMplus Docker Container" ON \ - 3>&1 1>&2 2>&3) + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE MODE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 14 60 2 \ + "1" "Check for Alpine Updates" OFF \ + "2" "Update NPMplus Docker Container" ON \ + 3>&1 1>&2 2>&3) - header_info "$APP" + header_info "$APP" - case "$UPD" in - "1") - msg_info "Updating Alpine OS" - apk update && apk upgrade - msg_ok "System updated" - exit - ;; - "2") - msg_info "Updating NPMplus Container" - cd /opt - msg_info "Pulling latest container image" - $STD docker compose pull - msg_info "Recreating container" - $STD docker compose up -d - msg_ok "NPMplus container updated" - exit - ;; - esac - exit 0 + case "$UPD" in + "1") + msg_info "Updating Alpine OS" + $STD apk -U upgrade + msg_ok "System updated" + exit + ;; + "2") + msg_info "Updating NPMplus Container" + cd /opt + msg_info "Pulling latest container image" + $STD docker compose pull + msg_info "Recreating container" + $STD docker compose up -d + msg_ok "NPMplus container updated" + exit + ;; + esac + exit 0 } start diff --git a/frontend/public/json/alpine.json b/frontend/public/json/alpine.json index 6510d21e3..6918563a9 100644 --- a/frontend/public/json/alpine.json +++ b/frontend/public/json/alpine.json @@ -44,7 +44,7 @@ }, "notes": [ { - "text": "To Update Alpine: `apk update && apk upgrade`", + "text": "To Update Alpine: `apk -U upgrade`", "type": "info" } ] diff --git a/misc/alpine-install.func b/misc/alpine-install.func index 07d477c5a..08e1733ea 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -137,8 +137,7 @@ network_check() { # 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 + $STD apk -U upgrade msg_ok "Updated Container OS" msg_info "Installing core dependencies" diff --git a/tools/pve/update-lxcs-cron.sh b/tools/pve/update-lxcs-cron.sh index 9c0def0c4..adb2af63b 100644 --- a/tools/pve/update-lxcs-cron.sh +++ b/tools/pve/update-lxcs-cron.sh @@ -13,7 +13,7 @@ function update_container() { echo -e "\n [Info] Updating $container : $name \n" os=$(pct config "$container" | awk '/^ostype/ {print $2}') case "$os" in - alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;; + alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;; archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;; fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;; ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;; @@ -33,17 +33,17 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do echo -e "[Info] Skipping $container" sleep 1 else - status=$(pct status $container) - template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + status=$(pct status "$container") + template=$(pct config "$container" | grep -q "template:" && echo "true" || echo "false") if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then echo -e "[Info] Starting $container" - pct start $container + pct start "$container" sleep 5 - update_container $container + update_container "$container" echo -e "[Info] Shutting down $container" - pct shutdown $container & + pct shutdown "$container" & elif [ "$status" == "status: running" ]; then - update_container $container + update_container "$container" fi fi done diff --git a/tools/pve/update-lxcs.sh b/tools/pve/update-lxcs.sh index 4aa41b1ac..84fa4c226 100644 --- a/tools/pve/update-lxcs.sh +++ b/tools/pve/update-lxcs.sh @@ -5,7 +5,7 @@ # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -function header_info { +function header_info() { clear cat <<"EOF" __ __ __ __ __ _ ________ @@ -64,7 +64,7 @@ function update_container() { echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}[No disk info for ${os}]${CL}\n" fi case "$os" in - alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;; + alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;; archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;; fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;; ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;