Skip to content

Commit 04f781c

Browse files
authored
NPMPlus: update function & better create handling (user/password) (#3520)
* Update npmplus-install.sh * Update npmplus.sh
1 parent a95403e commit 04f781c

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

ct/npmplus.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,35 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 1 \
24-
"1" "Check for Alpine Updates" ON \
23+
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE MODE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 14 60 2 \
24+
"1" "Check for Alpine Updates" OFF \
25+
"2" "Update NPMplus Docker Container" ON \
2526
3>&1 1>&2 2>&3)
2627

27-
header_info
28-
if [ "$UPD" == "1" ]; then
29-
apk update && apk upgrade
30-
exit
31-
fi
28+
header_info "$APP"
29+
30+
case "$UPD" in
31+
"1")
32+
msg_info "Updating Alpine OS"
33+
apk update && apk upgrade
34+
msg_ok "System updated"
35+
exit
36+
;;
37+
"2")
38+
msg_info "Updating NPMplus Container"
39+
cd /opt || exit 1
40+
msg_info "Pulling latest container image"
41+
$STD docker compose pull
42+
msg_info "Recreating container"
43+
$STD docker compose up -d
44+
msg_ok "NPMplus container updated"
45+
exit
46+
;;
47+
esac
48+
exit 0
3249
}
3350

51+
3452
start
3553
build_container
3654
description

install/npmplus-install.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ update_os
1515

1616
msg_info "Installing Dependencies"
1717
$STD apk add \
18-
newt \
19-
curl \
20-
openssh \
2118
tzdata \
22-
nano \
2319
gawk \
24-
yq \
25-
mc
20+
yq
2621
msg_ok "Installed Dependencies"
2722

2823
msg_info "Installing Docker & Compose"
@@ -95,7 +90,7 @@ customize
9590
msg_info "Retrieving Default Login (Patience)"
9691
PASSWORD_FOUND=0
9792
for i in {1..60}; do
98-
PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | grep -m1 "Creating a new user:")
93+
PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | awk '/Creating a new user:/ { print; exit }')
9994
if [[ -n "$PASSWORD_LINE" ]]; then
10095
PASSWORD=$(echo "$PASSWORD_LINE" | awk -F 'password: ' '{print $2}')
10196
echo -e "username: [email protected]\npassword: $PASSWORD" >/opt/.npm_pwd
@@ -107,5 +102,6 @@ for i in {1..60}; do
107102
done
108103

109104
if [[ $PASSWORD_FOUND -eq 0 ]]; then
110-
msg_ok "No default login found, use docker ps & docker logs for container password."
105+
msg_error "Could not retrieve default login after 60 seconds."
106+
echo -e "\nYou can manually check the container logs with:\n docker logs $CONTAINER_ID | grep 'Creating a new user:'\n"
111107
fi

0 commit comments

Comments
 (0)