Refactor: NPMPlus / Default Login (#11262)

This commit is contained in:
CanbiZ (MickLesk)
2026-01-28 11:06:02 +01:00
committed by GitHub
parent 0453673115
commit 6c1d1e1e71
2 changed files with 5 additions and 49 deletions

View File

@@ -39,8 +39,8 @@
}
],
"default_credentials": {
"username": "admin@example.org",
"password": null
"username": "admin@local.com",
"password": "helper-scripts.com"
},
"notes": [
{
@@ -48,11 +48,7 @@
"type": "info"
},
{
"text": "The initial starting process can be take 1-2min. ",
"type": "info"
},
{
"text": "Application credentials: `cat /opt/.npm_pwd` - if file not exist in LXC check docker logs for password with `docker logs npmplus`",
"text": "The initial starting process can take 1-2min. ",
"type": "info"
}
]

View File

@@ -59,8 +59,8 @@ read -r -p "${TAB3}Enter your ACME Email: " ACME_EMAIL_INPUT
yq -i "
.services.npmplus.environment |=
(map(select(. != \"TZ=*\" and . != \"ACME_EMAIL=*\")) +
[\"TZ=$TZ_INPUT\", \"ACME_EMAIL=$ACME_EMAIL_INPUT\"])
(map(select(. != \"TZ=*\" and . != \"ACME_EMAIL=*\" and . != \"INITIAL_ADMIN_EMAIL=*\" and . != \"INITIAL_ADMIN_PASSWORD=*\")) +
[\"TZ=$TZ_INPUT\", \"ACME_EMAIL=$ACME_EMAIL_INPUT\", \"INITIAL_ADMIN_EMAIL=admin@local.com\", \"INITIAL_ADMIN_PASSWORD=helper-scripts.com\"])
" /opt/compose.yaml
msg_info "Building and Starting NPMplus (Patience)"
@@ -86,43 +86,3 @@ msg_ok "Builded and started NPMplus"
motd_ssh
customize
msg_info "Retrieving Default Login (Patience)"
PASSWORD_FOUND=0
# Try to find password in existing logs (max 120 seconds)
for i in {1..60}; do
PASSWORD_LINE=$(
{ awk '/Creating a new user:/{print; exit}' < <(docker logs "$CONTAINER_ID" 2>&1); } || true
)
if [[ -n "${PASSWORD_LINE:-}" ]]; then
PASSWORD="${PASSWORD_LINE#*password: }"
printf 'username: admin@example.org\npassword: %s\n' "$PASSWORD" >/opt/.npm_pwd
msg_ok "Saved default login to /opt/.npm_pwd"
PASSWORD_FOUND=1
break
fi
sleep 2
done
# If not found, try live log stream (30s)
if [[ $PASSWORD_FOUND -eq 0 ]]; then
PASSWORD_LINE=$(
timeout 30s bash -c '
docker logs -f --since=0s --tail=0 "$1" 2>&1 | awk "/Creating a new user:/{print; exit}"
' _ "$CONTAINER_ID" 2>/dev/null || true
)
if [[ -n "${PASSWORD_LINE:-}" ]]; then
PASSWORD="${PASSWORD_LINE#*password: }"
printf 'username: admin@example.org\npassword: %s\n' "$PASSWORD" >/opt/.npm_pwd
msg_ok "Saved default login to /opt/.npm_pwd"
PASSWORD_FOUND=1
fi
fi
if [[ $PASSWORD_FOUND -eq 0 ]]; then
msg_warn "Default login not found in logs (this is normal for NPMplus)"
msg_custom "💡" "${GN}" "NPMplus creates an admin account on first web access"
msg_custom "📋" "${GN}" "Visit http://<IP>:81 and create your admin user"
fi