fix(installer): restart Stalwart after bootstrap

This commit is contained in:
Meghdad committed 2026-08-13 04:33:01 +03:30
1 parent 9272a10f72
commit 7159f122ce
5 files changed
+54 -13

No files matched your search

+9 -3
View File
@@ -112,8 +112,10 @@ sudo --preserve-env=CLOUDFLARE_API_TOKEN ./scripts/install-server.sh install \
unset CLOUDFLARE_API_TOKEN
```
Visit the printed HTTPS URL and complete the browser wizard. After creating and
testing a permanent administrator, finish the security setup:
Visit the printed HTTPS URL, complete the browser wizard, and save the generated
permanent-administrator credentials. Then finish the security setup. Finalize
restarts Stalwart into its persistent configuration and pauses so an interactive
operator can verify administrator sign-in before recovery access is removed:
```bash
sudo ./scripts/install-server.sh finalize
@@ -147,11 +149,15 @@ one-time result shown on the final screen.
After setup:
```bash
docker compose restart stalwart
./mailctl configure-tls
./mailctl doctor --hostname mail.example.com
```
Sign in with the permanent Stalwart administrator, create the dedicated `API_SUBMISSION_USER` account referenced by `.env`, put that account's application password in `secrets/api_submission_password`, verify REST submission, then remove the recovery backdoor:
Sign in with the permanent Stalwart administrator and verify it before removing
the recovery backdoor. Then create the dedicated `API_SUBMISSION_USER` account
referenced by `.env`, put that account's application password in
`secrets/api_submission_password`, and verify REST submission:
```bash
./mailctl harden
+1 -1
View File
@@ -348,7 +348,7 @@ function SetupWizard({ onComplete }: { onComplete: () => void }) {
} catch (reason) { setError(reason instanceof Error ? reason.message : "Setup failed."); }
finally { setBusy(false); }
};
if (bootstrapResult) return <div className="setup-finished"><div><span className="step-icon"><CheckCircle2 /></span><h1>Your mail appliance is configured.</h1><p>Save the one-time mail-core result below, restart the mail core, verify the permanent administrator account, and remove recovery access with <code>mailctl harden</code>.</p><pre>{JSON.stringify(bootstrapResult, null, 2)}</pre><div className="setup-warning"><ShieldCheck />This result is not stored by MEOVV Mail.</div><button className="primary" onClick={onComplete}>I saved it — continue to sign in <ArrowRight /></button></div></div>;
if (bootstrapResult) return <div className="setup-finished"><div><span className="step-icon"><CheckCircle2 /></span><h1>Your mail appliance is configured.</h1><p>Save the one-time mail-core result below, then run <code>sudo ./scripts/install-server.sh finalize</code> on the server. Finalization restarts the mail core and pauses so you can verify this administrator before recovery access is removed.</p><pre>{JSON.stringify(bootstrapResult, null, 2)}</pre><div className="setup-warning"><ShieldCheck />This result is not stored by MEOVV Mail.</div><button className="primary" onClick={onComplete}>I saved it — show sign in <ArrowRight /></button></div></div>;
return (
<div className="setup-screen">
<aside className="setup-aside">
+13 -2
View File
@@ -29,13 +29,17 @@ secrets directory, installs the renewal hook, and starts both containers.
It deliberately leaves DNS, PTR records, provider firewall rules, SSH, and UFW
to the operator unless the optional Cloudflare DNS prompt is accepted. It also
stops when it finds a conflicting unmanaged Nginx site or container package
rather than replacing an existing setup. After the browser wizard and permanent
administrator verification, run:
rather than replacing an existing setup. After the browser wizard, save the
generated permanent-administrator credentials and run:
```bash
sudo ./scripts/install-server.sh finalize
```
Finalization restarts Stalwart so it leaves its in-memory bootstrap mode, waits
for the persistent configuration to become ready, and pauses for administrator
sign-in verification before removing recovery access.
The rest of this document describes the same integration for manual installs
and explains the files managed by the installer.
@@ -130,7 +134,14 @@ the temporary recovery account, register the mounted files with Stalwart:
```bash
docker compose up -d --build --remove-orphans
docker compose restart stalwart
./mailctl configure-tls
```
Sign in with the permanent administrator shown by the wizard. Only after that
account is verified, remove temporary recovery access:
```bash
./mailctl harden
```
+1 -1
View File
@@ -180,7 +180,7 @@ func (s *Server) setupComplete(w http.ResponseWriter, r *http.Request) {
return
}
_ = s.Store.Audit(r.Context(), app.RandomID("aud_"), in.AdminEmail, "installation.completed", in.Hostname, in)
writeJSON(w, 201, map[string]any{"configured": true, "next": "Save the one-time administrator result, restart Stalwart, verify permanent administrator sign-in, then run mailctl harden.", "mail_core_result": json.RawMessage(bootstrapResult), "dns_checks": []string{"A/AAAA", "MX", "PTR", "SPF", "DKIM", "DMARC", "TLS"}})
writeJSON(w, 201, map[string]any{"configured": true, "next": "Save the one-time administrator result, then run install-server.sh finalize. It restarts Stalwart and pauses for permanent administrator sign-in verification before removing recovery access.", "mail_core_result": json.RawMessage(bootstrapResult), "dns_checks": []string{"A/AAAA", "MX", "PTR", "SPF", "DKIM", "DMARC", "TLS"}})
}
func (s *Server) sessionExchange(w http.ResponseWriter, r *http.Request) {
+30 -6
View File
@@ -73,8 +73,9 @@ Usage:
Commands:
install Install Docker, Nginx, and Certbot; initialize the bundle; obtain
TLS; install proxy/renewal configuration; and start the appliance.
finalize After completing the browser wizard and creating a permanent
administrator, register TLS with Stalwart and remove recovery access.
finalize After completing the browser wizard, restart Stalwart into its
persistent configuration, register TLS, verify the permanent
administrator, and remove recovery access.
status Show service, certificate, and local endpoint status without changes.
This script does not modify PTR records, provider firewalls, SSH, or UFW.
@@ -895,8 +896,8 @@ MEOVV Mail prerequisites and services are installed.
Next:
1. Open https://$MAIL_HOSTNAME and complete the setup wizard.
2. Create and verify a permanent Stalwart administrator.
3. Run:
2. Save the one-time permanent administrator credentials shown by the wizard.
3. Run finalization; it restarts Stalwart and pauses for sign-in verification:
sudo $BUNDLE_DIR/scripts/install-server.sh finalize --bundle-dir $BUNDLE_DIR
Required provider-side work that this script cannot perform:
@@ -924,12 +925,35 @@ finalize_command() {
if ! $ASSUME_YES; then
[[ -t 0 ]] || die "non-interactive use requires --yes"
warn "Finalize removes the temporary Stalwart recovery administrator."
read -r -p "Have you completed the wizard and verified a permanent administrator? [y/N] " answer
warn "Finalize restarts Stalwart and then removes the temporary recovery administrator."
read -r -p "Have you completed the wizard and saved its permanent administrator credentials? [y/N] " answer
[[ "$answer" =~ ^[Yy]$ ]] || die "finalization cancelled"
fi
build_and_install_mailctl
log "Restarting Stalwart into its persistent configuration"
compose restart stalwart
local attempt stalwart_ready=false
for attempt in {1..30}; do
if curl --fail --silent --show-error --max-time 3 \
http://127.0.0.1:8081/.well-known/jmap >/dev/null; then
stalwart_ready=true
break
fi
sleep 2
done
if [[ "$stalwart_ready" != true ]]; then
compose ps
die "Stalwart did not become ready after its post-bootstrap restart"
fi
if ! $ASSUME_YES; then
printf '\nStalwart is now running its persistent configuration.\n'
read -r -p "Can you sign in with the permanent administrator shown by the wizard? [y/N] " answer
[[ "$answer" =~ ^[Yy]$ ]] || die "finalization stopped; recovery access remains enabled"
fi
log "Registering Certbot TLS with Stalwart"
"$MAILCTL_BIN" configure-tls --directory "$BUNDLE_DIR"
log "Removing temporary recovery access"