From 04f781c512e67583fbabff593bfe8a68dc49fae6 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:54:40 +0200 Subject: [PATCH] NPMPlus: update function & better create handling (user/password) (#3520) * Update npmplus-install.sh * Update npmplus.sh --- ct/npmplus.sh | 32 +++++++++++++++++++++++++------- install/npmplus-install.sh | 12 ++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ct/npmplus.sh b/ct/npmplus.sh index cbc4682ed..65bfeb178 100644 --- a/ct/npmplus.sh +++ b/ct/npmplus.sh @@ -20,17 +20,35 @@ color catch_errors function update_script() { - UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 1 \ - "1" "Check for Alpine Updates" ON \ + 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 - if [ "$UPD" == "1" ]; then - apk update && apk upgrade - exit - fi + 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 || exit 1 + 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 build_container description diff --git a/install/npmplus-install.sh b/install/npmplus-install.sh index 64fbe6bdc..66cdc9f8f 100644 --- a/install/npmplus-install.sh +++ b/install/npmplus-install.sh @@ -15,14 +15,9 @@ update_os msg_info "Installing Dependencies" $STD apk add \ - newt \ - curl \ - openssh \ tzdata \ - nano \ gawk \ - yq \ - mc + yq msg_ok "Installed Dependencies" msg_info "Installing Docker & Compose" @@ -95,7 +90,7 @@ customize msg_info "Retrieving Default Login (Patience)" PASSWORD_FOUND=0 for i in {1..60}; do - PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | grep -m1 "Creating a new user:") + PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | awk '/Creating a new user:/ { print; exit }') if [[ -n "$PASSWORD_LINE" ]]; then PASSWORD=$(echo "$PASSWORD_LINE" | awk -F 'password: ' '{print $2}') echo -e "username: admin@example.org\npassword: $PASSWORD" >/opt/.npm_pwd @@ -107,5 +102,6 @@ for i in {1..60}; do done if [[ $PASSWORD_FOUND -eq 0 ]]; then - msg_ok "No default login found, use docker ps & docker logs for container password." + msg_error "Could not retrieve default login after 60 seconds." + echo -e "\nYou can manually check the container logs with:\n docker logs $CONTAINER_ID | grep 'Creating a new user:'\n" fi