Installing rocketchat failed with
invalid IPv4 address: ParseAddr("IP_DATA_2"): unable to parse IP
ipUpdateComposeTags allocates one IP per SERVICE_TAG_N annotation and fills
IP_TAG_i only where SERVICE_TAG_i exists. The four new apps tagged only their
primary service, so every sidecar — matrix's postgres, mattermost's postgres,
rocketchat's mongo, and fifteen of stoat's sixteen — kept a literal IP_DATA_n
in the deployed compose and docker refused to create the container.
Tag every service that carries an ipv4_address, index-aligned with its IP_TAG.
For stoat that also meant moving caddy from SERVICE_TAG_1 to _6 so the indices
line up with the IPs rather than the reading order.
mastodon had the same latent break (IP_TAG_2 and _3 untagged) and is fixed the
same way — it would have failed on first install for the same reason.
SERVICE_TAG carries the compose *key*, not container_name: 'libreportal app
restart <app> <service>' passes it to 'docker compose restart', which only
understands keys.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
85 lines
3.4 KiB
Bash
85 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Bookstack install hooks — drive the post-start admin account bootstrap.
|
|
# Generic installApp driver handles compose / start / db / monitoring; this
|
|
# adds the readiness probe + first-admin provisioning the original
|
|
# installBookstack() did inline.
|
|
|
|
bookstack_install_post_start()
|
|
{
|
|
local app_name="$1"
|
|
|
|
local bookstack_target_email="${CFG_BOOKSTACK_ADMIN_EMAIL:-admin@admin.com}"
|
|
local bookstack_target_pass="${CFG_BOOKSTACK_ADMIN_PASSWORD_1:-password}"
|
|
|
|
local bookstack_compose_file="$containers_dir$app_name/docker-compose.yml"
|
|
local bookstack_port_pair
|
|
bookstack_port_pair=$(tagsManagerGetTagContent "$bookstack_compose_file" "PORTS_TAG_1")
|
|
local bookstack_host_port="${bookstack_port_pair%%:*}"
|
|
local bookstack_probe_url="http://127.0.0.1:${bookstack_host_port}/login"
|
|
|
|
isNotice "Waiting for Bookstack to come online at ${bookstack_probe_url} ..."
|
|
isNotice "This may take up to 20 seconds, please wait..."
|
|
|
|
local bookstack_attempts=0
|
|
local bookstack_ready=0
|
|
local bookstack_http_code
|
|
while ((bookstack_attempts < 60)); do
|
|
bookstack_http_code=$(curl -sS -o /dev/null --max-time 3 -w '%{http_code}' "$bookstack_probe_url" 2>/dev/null)
|
|
if [[ "$bookstack_http_code" =~ ^(200|302)$ ]]; then
|
|
bookstack_ready=1
|
|
break
|
|
fi
|
|
sleep 2
|
|
((bookstack_attempts++))
|
|
done
|
|
|
|
if ((bookstack_ready == 0)); then
|
|
isNotice "Bookstack did not respond on ${bookstack_probe_url} within $((60 * 2))s — admin account left at upstream defaults."
|
|
echo ""
|
|
isNotice "Bookstack admin login (default):"
|
|
echo ""
|
|
echo " Email : admin@admin.com"
|
|
echo " Password : password"
|
|
echo ""
|
|
return 0
|
|
fi
|
|
isSuccessful "Bookstack is online (HTTP ${bookstack_http_code})."
|
|
|
|
local bookstack_create_output
|
|
bookstack_create_output=$(runFileOp docker exec \
|
|
-e EZ_BS_NEW_EMAIL="$bookstack_target_email" \
|
|
-e EZ_BS_NEW_PASS="$bookstack_target_pass" \
|
|
bookstack sh -c 'cd /app/www && s6-setuidgid abc php artisan bookstack:create-admin --no-ansi --email="$EZ_BS_NEW_EMAIL" --name=Admin --password="$EZ_BS_NEW_PASS" 2>&1')
|
|
local bookstack_create_rc=$?
|
|
if [[ $bookstack_create_rc -eq 0 ]]; then
|
|
isSuccessful "Bookstack admin account created (email: $bookstack_target_email)."
|
|
|
|
if [[ "$bookstack_target_email" != "admin@admin.com" ]]; then
|
|
runFileOp docker exec -i bookstack php /app/www/artisan tinker --no-ansi >/dev/null 2>&1 <<'PHP'
|
|
$c = class_exists('\BookStack\Users\Models\User') ? '\BookStack\Users\Models\User' : '\BookStack\Auth\User';
|
|
optional($c::where('email', 'admin@admin.com')->first())->delete();
|
|
PHP
|
|
isSuccessful "Removed seeded admin@admin.com account."
|
|
fi
|
|
|
|
echo ""
|
|
isNotice "Bookstack admin login:"
|
|
echo ""
|
|
echo " Email : ${bookstack_target_email}"
|
|
echo " Password : ${bookstack_target_pass}"
|
|
echo ""
|
|
else
|
|
isNotice "Bookstack admin auto-create failed (exit $bookstack_create_rc). Output:"
|
|
echo "$bookstack_create_output" | sed 's/^/ /'
|
|
echo ""
|
|
isNotice "Falling back to upstream defaults — update from inside Bookstack."
|
|
echo ""
|
|
isNotice "Bookstack admin login (default):"
|
|
echo ""
|
|
echo " Email : admin@admin.com"
|
|
echo " Password : password"
|
|
echo ""
|
|
fi
|
|
}
|