Archived
fix(installer): restart Stalwart after bootstrap
This commit is contained in:
5 files changed
+54
-13
No files matched your search
@@ -112,8 +112,10 @@ sudo --preserve-env=CLOUDFLARE_API_TOKEN ./scripts/install-server.sh install \
|
|||||||
unset CLOUDFLARE_API_TOKEN
|
unset CLOUDFLARE_API_TOKEN
|
||||||
```
|
```
|
||||||
|
|
||||||
Visit the printed HTTPS URL and complete the browser wizard. After creating and
|
Visit the printed HTTPS URL, complete the browser wizard, and save the generated
|
||||||
testing a permanent administrator, finish the security setup:
|
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
|
```bash
|
||||||
sudo ./scripts/install-server.sh finalize
|
sudo ./scripts/install-server.sh finalize
|
||||||
@@ -147,11 +149,15 @@ one-time result shown on the final screen.
|
|||||||
After setup:
|
After setup:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
docker compose restart stalwart
|
||||||
./mailctl configure-tls
|
./mailctl configure-tls
|
||||||
./mailctl doctor --hostname mail.example.com
|
./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
|
```bash
|
||||||
./mailctl harden
|
./mailctl harden
|
||||||
|
|||||||
+1
-1
@@ -348,7 +348,7 @@ function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
|||||||
} catch (reason) { setError(reason instanceof Error ? reason.message : "Setup failed."); }
|
} catch (reason) { setError(reason instanceof Error ? reason.message : "Setup failed."); }
|
||||||
finally { setBusy(false); }
|
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 (
|
return (
|
||||||
<div className="setup-screen">
|
<div className="setup-screen">
|
||||||
<aside className="setup-aside">
|
<aside className="setup-aside">
|
||||||
|
|||||||
+13
-2
@@ -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
|
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
|
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
|
stops when it finds a conflicting unmanaged Nginx site or container package
|
||||||
rather than replacing an existing setup. After the browser wizard and permanent
|
rather than replacing an existing setup. After the browser wizard, save the
|
||||||
administrator verification, run:
|
generated permanent-administrator credentials and run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./scripts/install-server.sh finalize
|
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
|
The rest of this document describes the same integration for manual installs
|
||||||
and explains the files managed by the installer.
|
and explains the files managed by the installer.
|
||||||
|
|
||||||
@@ -130,7 +134,14 @@ the temporary recovery account, register the mounted files with Stalwart:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose up -d --build --remove-orphans
|
docker compose up -d --build --remove-orphans
|
||||||
|
docker compose restart stalwart
|
||||||
./mailctl configure-tls
|
./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
|
./mailctl harden
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ func (s *Server) setupComplete(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ = s.Store.Audit(r.Context(), app.RandomID("aud_"), in.AdminEmail, "installation.completed", in.Hostname, in)
|
_ = 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) {
|
func (s *Server) sessionExchange(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -73,8 +73,9 @@ Usage:
|
|||||||
Commands:
|
Commands:
|
||||||
install Install Docker, Nginx, and Certbot; initialize the bundle; obtain
|
install Install Docker, Nginx, and Certbot; initialize the bundle; obtain
|
||||||
TLS; install proxy/renewal configuration; and start the appliance.
|
TLS; install proxy/renewal configuration; and start the appliance.
|
||||||
finalize After completing the browser wizard and creating a permanent
|
finalize After completing the browser wizard, restart Stalwart into its
|
||||||
administrator, register TLS with Stalwart and remove recovery access.
|
persistent configuration, register TLS, verify the permanent
|
||||||
|
administrator, and remove recovery access.
|
||||||
status Show service, certificate, and local endpoint status without changes.
|
status Show service, certificate, and local endpoint status without changes.
|
||||||
|
|
||||||
This script does not modify PTR records, provider firewalls, SSH, or UFW.
|
This script does not modify PTR records, provider firewalls, SSH, or UFW.
|
||||||
@@ -895,8 +896,8 @@ MEOVV Mail prerequisites and services are installed.
|
|||||||
|
|
||||||
Next:
|
Next:
|
||||||
1. Open https://$MAIL_HOSTNAME and complete the setup wizard.
|
1. Open https://$MAIL_HOSTNAME and complete the setup wizard.
|
||||||
2. Create and verify a permanent Stalwart administrator.
|
2. Save the one-time permanent administrator credentials shown by the wizard.
|
||||||
3. Run:
|
3. Run finalization; it restarts Stalwart and pauses for sign-in verification:
|
||||||
sudo $BUNDLE_DIR/scripts/install-server.sh finalize --bundle-dir $BUNDLE_DIR
|
sudo $BUNDLE_DIR/scripts/install-server.sh finalize --bundle-dir $BUNDLE_DIR
|
||||||
|
|
||||||
Required provider-side work that this script cannot perform:
|
Required provider-side work that this script cannot perform:
|
||||||
@@ -924,12 +925,35 @@ finalize_command() {
|
|||||||
|
|
||||||
if ! $ASSUME_YES; then
|
if ! $ASSUME_YES; then
|
||||||
[[ -t 0 ]] || die "non-interactive use requires --yes"
|
[[ -t 0 ]] || die "non-interactive use requires --yes"
|
||||||
warn "Finalize removes the temporary Stalwart recovery administrator."
|
warn "Finalize restarts Stalwart and then removes the temporary recovery administrator."
|
||||||
read -r -p "Have you completed the wizard and verified a permanent administrator? [y/N] " answer
|
read -r -p "Have you completed the wizard and saved its permanent administrator credentials? [y/N] " answer
|
||||||
[[ "$answer" =~ ^[Yy]$ ]] || die "finalization cancelled"
|
[[ "$answer" =~ ^[Yy]$ ]] || die "finalization cancelled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_and_install_mailctl
|
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"
|
log "Registering Certbot TLS with Stalwart"
|
||||||
"$MAILCTL_BIN" configure-tls --directory "$BUNDLE_DIR"
|
"$MAILCTL_BIN" configure-tls --directory "$BUNDLE_DIR"
|
||||||
log "Removing temporary recovery access"
|
log "Removing temporary recovery access"
|
||||||
|
|||||||
Reference in new issue
Block a user