halkyon/deploy/host/halkyon-li-env.sh

96 lines
3.7 KiB
Shell
Raw Permalink Normal View History

#!/bin/sh
# Writes halkyon.li's first deploy/.env (ADR 0039; first-start.md, step 4), as deploy,
# on the instance's host at home:
#
# sh deploy/host/halkyon-li-env.sh deploy/.env
#
# Every secret is made here and now (32 random bytes, in hex), and never leaves the
# host but into Proton Pass (vault Infra, a note "halkyon.li .env", the whole file).
# It refuses to write over an existing file: the session peppers and the database
# passwords must never change once the instance runs (.env.example says why for each).
# The settings are the developer's choices of 8 Nov 2026; .env.example explains each
# one. SimpleLogin's client ID and secret stay empty until its app is registered
# (first-start.md, step 5).
set -eu
target=${1:?usage: halkyon-li-env.sh <path of the new .env>}
if [ -e "$target" ]; then
echo "Error: $target exists; its secrets must stay as they are." >&2
exit 1
fi
secret() { openssl rand -hex 32; }
umask 077
cat >"$target" <<EOF
# halkyon.li's .env, written by deploy/host/halkyon-li-env.sh on $(date -u +%Y-%m-%d).
# Its secrets are in Proton Pass (Infra, "halkyon.li .env"). .env.example explains each
# setting.
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
# Names (ADR 0039, D7; Halkyon Days' ADR 0045, D22): Halkyon on halkyon.li itself,
# Myrmex on myrmex.li, each register's handles on its own domain.
HALKYON_DOMAIN=halkyon.li
HALKYON_PUBLIC_HOST=halkyon.li
TRAIN_DOMAIN=train.halkyon.li
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
MYRMEX_DOMAIN=myrmex.li
MEDITATE_DOMAIN=meditate.halkyon.li
JELLYFIN_DOMAIN=jellyfin.halkyon.li
# Everything runs, behind ramiel's forward (compose.forwarded.yaml last, its ports win).
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
COMPOSE_FILE=compose.halkyon.yaml:compose.jellyfin.yaml:compose.languagetool.yaml:compose.train.yaml:compose.maps.yaml:compose.search.yaml:compose.myrmex.yaml:compose.myrmex-search.yaml:compose.meditate.yaml:compose.forwarded.yaml
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
# Who comes in, at each app's own register (ADR 0045, D7, D9, D20): SimpleLogin alone,
# each register with an app of its own, approved by an operator (ADR 0039, D4). No
# mail, so neither email codes nor passwords. The client IDs and secrets from each
# SimpleLogin app (first-start.md, step 5).
HALKYON_SIGN_IN_WAYS=simplelogin
HALKYON_SIGN_UP=approval
HALKYON_SIGN_IN_DECOY_KEY=$(secret)
HALKYON_SIMPLELOGIN_CLIENT_ID=
HALKYON_SIMPLELOGIN_CLIENT_SECRET=
MYRMEX_SIGN_IN_WAYS=simplelogin
MYRMEX_SIGN_UP=approval
MYRMEX_SIGN_IN_DECOY_KEY=$(secret)
MYRMEX_SIMPLELOGIN_CLIENT_ID=
MYRMEX_SIMPLELOGIN_CLIENT_SECRET=
TRAIN_SIGN_IN_WAYS=simplelogin
TRAIN_SIGN_UP=approval
TRAIN_SIGN_IN_DECOY_KEY=$(secret)
TRAIN_SIMPLELOGIN_CLIENT_ID=
TRAIN_SIMPLELOGIN_CLIENT_SECRET=
MEDITATE_SIGN_IN_WAYS=simplelogin
MEDITATE_SIGN_UP=approval
MEDITATE_SIGN_IN_DECOY_KEY=$(secret)
MEDITATE_SIMPLELOGIN_CLIENT_ID=
MEDITATE_SIMPLELOGIN_CLIENT_SECRET=
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
# Halkyon: the instance's PostgreSQL superuser and Halkyon's session pepper.
HALKYON_POSTGRES_PASSWORD=$(secret)
HALKYON_SESSION_KEY_HASH_PEPPER=$(secret)
# Train, with BRouter, its own map and Photon. Until the Instance console cuts regions
# (ADR 0040): the map and routes over southern Bavaria, the search over Germany, the
# smallest Photon's databases come in, with memory to fit beside the rest.
TRAIN_POSTGRES_PASSWORD=$(secret)
TRAIN_SESSION_KEY_HASH_PEPPER=$(secret)
BROUTER_REGION=10,45,15,50
MAP_KEY_SECRET=$(secret)
MAP_REGION=10,47.2,13.9,49
PHOTON_REGION=europe/germany
PHOTON_HEAP=2g
PHOTON_MEMORY=3g
feat(halkyon,myrmex,train,meditate)!: a register for each app, at halkyon.li and myrmex.li (ADR 0045, step 5) halkyon.li's deploy under Halkyon Days' names (D13, D23): the compose files compose.halkyon.yaml, compose.myrmex.yaml and compose.myrmex-search.yaml, the service myrmex-server, the images halkyon-halkyon-server, halkyon-halkyon-dictionaries and halkyon-myrmex-server, the databases halkyon_halkyon and halkyon_myrmex and the superuser halkyon_halkyon, and every variable under its service's name (LEARN_ is HALKYON_, TODO_ MYRMEX_). The Compose project and its network keep halkyon-learn, as the volumes are named after it. Every server is a register of its own (D7, D9, D20): no ACCOUNT_REGISTER_URL, INSTANCE_SECRET or INSTANCE_MEMBER_ any more; each reads its sign-in settings as <APP>_SIGN_UP, <APP>_SIMPLELOGIN_…, and so on (the mail server alone is shared), signs in with a SimpleLogin app of its own, and serves its register's pages itself: Myrmex's, Train's and Meditate's servers add the SimpleLogin callback, the privacy page and the profile pages, and their Caddy sites forward them. Halkyon answers at halkyon.li and Myrmex at myrmex.li (D22): learn.halkyon.li and todo.halkyon.li leave ramiel's HAProxy and Caddy; Halkyon's and Myrmex's builds, snaps and F-Droid listings connect to the new addresses, and Halkyon's App Links name halkyon.li. The switch is a script run once by hand (D24), as the deployed redeploy.sh can't carry the migration records nor rename an open database: deploy/host/switch-0045.sh rewrites .env (env-0045.sh: every secret kept, a decoy key made for each new register), dumps every database, renames them and the superuser through a temporary superuser in one transaction, fast-forwards, carries the migration records to the modules' new names, migrates, copies the developer's account (its keys and its operator's scope, D21) into the other registers, and starts everything. deploy/host/link-simplelogin.sh then links each register's new SimpleLogin identity to that account, found by the four words of its wait screen. Their SQL was run against PostgreSQL 16 on the databases the migrations define. redeploy.sh no longer carries records. BREAKING CHANGE: learn.halkyon.li and todo.halkyon.li no longer answer; the apps connect to halkyon.li and myrmex.li, and each app's accounts are its own. Whats-New: Each app now keeps its own accounts; Halkyon is at halkyon.li and Myrmex at myrmex.li. Whats-New-De: Jede App führt jetzt ihre eigenen Konten; Halkyon ist unter halkyon.li erreichbar und Myrmex unter myrmex.li. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-13 02:04:48 +01:00
# Myrmex and Meditate (no library yet).
MYRMEX_POSTGRES_PASSWORD=$(secret)
MYRMEX_SESSION_KEY_HASH_PEPPER=$(secret)
MEDITATE_POSTGRES_PASSWORD=$(secret)
MEDITATE_SESSION_KEY_HASH_PEPPER=$(secret)
# Jellyfin's library on the HDD (sidecars/README.md, Jellyfin on halkyon.li).
JELLYFIN_MEDIA=/data/media
# What the app tells people: the iMac at home and the Storage Box, both in Germany.
DATA_LOCATION=DE
BACKUP_LOCATION=DE
EOF
echo "Written: $target"