Compare commits

..

3 Commits

Author SHA1 Message Date
CanbiZ
cd306efc9d Change updateable status to true in npmplus.json 2025-09-10 08:04:35 +02:00
CanbiZ
9d89cfbfa0 Update npmplus.json 2025-09-10 07:59:22 +02:00
CanbiZ
5d17626b83 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.
2025-09-10 07:58:02 +02:00
3 changed files with 26 additions and 10 deletions

View File

@@ -6,7 +6,7 @@
], ],
"date_created": "2025-03-13", "date_created": "2025-03-13",
"type": "ct", "type": "ct",
"updateable": false, "updateable": true,
"privileged": false, "privileged": false,
"interface_port": 81, "interface_port": 81,
"documentation": "https://github.com/ZoeyVid/NPMplus/blob/develop/README.md", "documentation": "https://github.com/ZoeyVid/NPMplus/blob/develop/README.md",
@@ -39,7 +39,7 @@
} }
], ],
"default_credentials": { "default_credentials": {
"username": "root", "username": "admin@example.org",
"password": null "password": null
}, },
"notes": [ "notes": [
@@ -52,7 +52,7 @@
"type": "info" "type": "info"
}, },
{ {
"text": "Application credentials: `cat /opt/.npm_pwd`", "text": "Application credentials: `cat /opt/.npm_pwd` - if file not exist in LXC check docker logs for password with `docker logs npmplus`",
"type": "info" "type": "info"
} }
] ]

View File

@@ -46,7 +46,7 @@ $STD npm run build --configuration=production
msg_ok "Built Frontend" msg_ok "Built Frontend"
msg_info "Creating Environment" msg_info "Creating Environment"
mkdir -p /opt/booklore_storage{/data,/books,/bookdrop} mkdir -p /opt/booklore_storage{/data,/books}
cat <<EOF >/opt/booklore_storage/.env cat <<EOF >/opt/booklore_storage/.env
DATABASE_URL=jdbc:mariadb://localhost:3306/$DB_NAME DATABASE_URL=jdbc:mariadb://localhost:3306/$DB_NAME
DATABASE_USERNAME=$DB_USER DATABASE_USERNAME=$DB_USER
@@ -55,7 +55,6 @@ BOOKLORE_PORT=6060
BOOKLORE_DATA_PATH=/opt/booklore_storage/data BOOKLORE_DATA_PATH=/opt/booklore_storage/data
BOOKLORE_BOOKS_PATH=/opt/booklore_storage/books BOOKLORE_BOOKS_PATH=/opt/booklore_storage/books
BOOKLORE_BOOKDROP_PATH=/opt/booklore_storage/bookdrop
EOF EOF
msg_ok "Created Environment" msg_ok "Created Environment"

View File

@@ -89,19 +89,36 @@ customize
msg_info "Retrieving Default Login (Patience)" msg_info "Retrieving Default Login (Patience)"
PASSWORD_FOUND=0 PASSWORD_FOUND=0
for i in {1..60}; do for i in {1..60}; do
PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | awk '/Creating a new user:/ { print; exit }') PASSWORD_LINE=$(
if [[ -n "$PASSWORD_LINE" ]]; then { awk '/Creating a new user:/{print; exit}' < <(docker logs "$CONTAINER_ID" 2>&1); } || true
PASSWORD=$(echo "$PASSWORD_LINE" | awk -F 'password: ' '{print $2}') )
echo -e "username: admin@example.org\npassword: $PASSWORD" >/opt/.npm_pwd
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" msg_ok "Saved default login to /opt/.npm_pwd"
PASSWORD_FOUND=1 PASSWORD_FOUND=1
break break
fi fi
sleep 2 sleep 2
done done
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
)
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)"
PASSWORD_FOUND=1
fi
fi
if [[ $PASSWORD_FOUND -eq 0 ]]; then if [[ $PASSWORD_FOUND -eq 0 ]]; then
msg_error "Could not retrieve default login after 60 seconds." 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" echo -e "\nYou can manually check the container logs with:\n docker logs $CONTAINER_ID | grep 'Creating a new user:'\n"
fi fi