31 lines
868 B
Bash
Executable File
31 lines
868 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
n8n_url="${1:-http://127.0.0.1:15678}"
|
|
|
|
if ! curl -fsS "${n8n_url}/rest/settings" | grep -q '"showSetupOnFirstLoad":true'; then
|
|
echo "n8n owner setup is already complete"
|
|
exit 0
|
|
fi
|
|
|
|
owner_email="mobilityops-admin@northstar.invalid"
|
|
owner_password="MobilityOps9-$(openssl rand -hex 16)"
|
|
payload="$(printf '{"email":"%s","firstName":"MobilityOps","lastName":"Admin","password":"%s"}' \
|
|
"${owner_email}" "${owner_password}")"
|
|
|
|
curl -fsS \
|
|
-X POST \
|
|
-H "Content-Type: application/json" \
|
|
--data-binary "${payload}" \
|
|
"${n8n_url}/rest/owner/setup" >/dev/null
|
|
|
|
{
|
|
printf '\n# Server-only n8n owner access\n'
|
|
printf 'N8N_OWNER_EMAIL=%s\n' "${owner_email}"
|
|
printf 'N8N_OWNER_PASSWORD=%s\n' "${owner_password}"
|
|
} >>.env
|
|
chmod 0600 .env
|
|
|
|
unset owner_password payload
|
|
echo "n8n owner setup completed; server-only credentials stored in .env"
|