fix(npmplus): graceful timeout for login retrieval (#11238)

- Change msg_error to msg_warn when login not found
- Add helpful user instructions for manual setup
- Script now exits normally instead of appearing stuck
- Resolves #10988
This commit is contained in:
CanbiZ (MickLesk)
2026-01-28 10:22:32 +01:00
committed by GitHub
parent ba279675a8
commit 497cefa850

View File

@@ -90,6 +90,7 @@ 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
@@ -104,21 +105,24 @@ for i in {1..60}; do
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" || true
' _ "$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 (live)"
msg_ok "Saved default login to /opt/.npm_pwd"
PASSWORD_FOUND=1
fi
fi
if [[ $PASSWORD_FOUND -eq 0 ]]; then
msg_error "Could not retrieve default login after 120s."
echo -e "\nYou can manually check the container logs with:\n docker logs $CONTAINER_ID | grep 'Creating a new user:'\n"
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