From c67afb2b3a597c33312b0df7dfeb748b77724202 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 10 Mar 2025 16:33:50 +0100 Subject: [PATCH] Update npm-plus-install.sh --- install/npm-plus-install.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/install/npm-plus-install.sh b/install/npm-plus-install.sh index aaab7a4..3edd2b4 100644 --- a/install/npm-plus-install.sh +++ b/install/npm-plus-install.sh @@ -61,12 +61,30 @@ msg_ok "Started NPM Plus" msg_info "Get Default Login" CONTAINER_ID=$(docker ps --format "{{.ID}}" --filter "name=npmplus") + if [[ -z "$CONTAINER_ID" ]]; then msg_error "NPMplus container not found." exit 1 fi -TIMEOUT=30 +TIMEOUT=60 +while [[ $TIMEOUT -gt 0 ]]; do + STATUS=$(docker inspect --format '{{.State.Health.Status}}' "$CONTAINER_ID" 2>/dev/null) + + if [[ "$STATUS" == "healthy" ]]; then + break + fi + + sleep 2 + ((TIMEOUT--)) +done + +if [[ "$STATUS" != "healthy" ]]; then + msg_error "NPMplus container did not reach a healthy state." + exit 1 +fi + +TIMEOUT=60 while [[ $TIMEOUT -gt 0 ]]; do PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | grep -m1 "Creating a new user: admin@example.org with password:") @@ -74,7 +92,8 @@ while [[ $TIMEOUT -gt 0 ]]; do PASSWORD=$(echo "$PASSWORD_LINE" | gawk -F 'password: ' '{print $2}') echo -e "username: admin@example.org\npassword: $PASSWORD" >/opt/.npm_pwd msg_ok "Saved default login to /opt/.npm_pwd" - break + msg_ok "Get Default Login Successful" + exit 0 fi sleep 2