Skip to content

Commit 3e18297

Browse files
authored
Improve npmplus credential retrieval and messaging (#7532)
* Improve npmplus credential retrieval and messaging Enhanced the install script to attempt live log monitoring for credentials if not found initially, and updated the info message in npmplus.json to guide users to check docker logs if the credentials file is missing. * Update npmplus.json * Change updateable status to true in npmplus.json
1 parent e7adf1a commit 3e18297

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

frontend/public/json/npmplus.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"date_created": "2025-03-13",
88
"type": "ct",
9-
"updateable": false,
9+
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 81,
1212
"documentation": "https://github.com/ZoeyVid/NPMplus/blob/develop/README.md",
@@ -39,7 +39,7 @@
3939
}
4040
],
4141
"default_credentials": {
42-
"username": "root",
42+
"username": "[email protected]",
4343
"password": null
4444
},
4545
"notes": [
@@ -52,7 +52,7 @@
5252
"type": "info"
5353
},
5454
{
55-
"text": "Application credentials: `cat /opt/.npm_pwd`",
55+
"text": "Application credentials: `cat /opt/.npm_pwd` - if file not exist in LXC check docker logs for password with `docker logs npmplus`",
5656
"type": "info"
5757
}
5858
]

install/npmplus-install.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,36 @@ customize
8989

9090
msg_info "Retrieving Default Login (Patience)"
9191
PASSWORD_FOUND=0
92+
9293
for i in {1..60}; do
93-
PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | awk '/Creating a new user:/ { print; exit }')
94-
if [[ -n "$PASSWORD_LINE" ]]; then
95-
PASSWORD=$(echo "$PASSWORD_LINE" | awk -F 'password: ' '{print $2}')
96-
echo -e "username: [email protected]\npassword: $PASSWORD" >/opt/.npm_pwd
94+
PASSWORD_LINE=$(
95+
{ awk '/Creating a new user:/{print; exit}' < <(docker logs "$CONTAINER_ID" 2>&1); } || true
96+
)
97+
98+
if [[ -n "${PASSWORD_LINE:-}" ]]; then
99+
PASSWORD="${PASSWORD_LINE#*password: }"
100+
printf 'username: [email protected]\npassword: %s\n' "$PASSWORD" >/opt/.npm_pwd
97101
msg_ok "Saved default login to /opt/.npm_pwd"
98102
PASSWORD_FOUND=1
99103
break
100104
fi
101105
sleep 2
102106
done
107+
if [[ $PASSWORD_FOUND -eq 0 ]]; then
108+
PASSWORD_LINE=$(
109+
timeout 30s bash -c '
110+
docker logs -f --since=0s --tail=0 "$1" 2>&1 | awk "/Creating a new user:/{print; exit}"
111+
' _ "$CONTAINER_ID" || true
112+
)
113+
if [[ -n "${PASSWORD_LINE:-}" ]]; then
114+
PASSWORD="${PASSWORD_LINE#*password: }"
115+
printf 'username: [email protected]\npassword: %s\n' "$PASSWORD" >/opt/.npm_pwd
116+
msg_ok "Saved default login to /opt/.npm_pwd (live)"
117+
PASSWORD_FOUND=1
118+
fi
119+
fi
103120

104121
if [[ $PASSWORD_FOUND -eq 0 ]]; then
105-
msg_error "Could not retrieve default login after 60 seconds."
122+
msg_error "Could not retrieve default login after 120s."
106123
echo -e "\nYou can manually check the container logs with:\n docker logs $CONTAINER_ID | grep 'Creating a new user:'\n"
107124
fi

0 commit comments

Comments
 (0)