fix(deploy): update.sh synchronisiert systemd-Units bei jedem Deploy
Bisher schrieb nur install.sh die Unit-Dateien (einmalig beim Erst-Setup). Server, die vor einer Unit-Änderung installiert wurden, blieben dauerhaft auf altem Stand — konkret fehlte auf 192.168.1.132 CAP_NET_ADMIN (wurde in install.sh ergänzt, aber nie auf bereits laufende Installationen nachgezogen), wodurch die Security-Tab-Aktion "Firewall aktivieren" (nft -f /etc/nftables.conf) mit "Operation not permitted" fehlschlug. update.sh schreibt jetzt bei jedem Deploy beide Unit-Dateien neu (identisch zum install.sh-Template) und lädt sie per daemon-reload nach, bevor die Dienste gestartet werden. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
af16138687
commit
c274df5023
@@ -215,6 +215,77 @@ if [[ -d "$BUILD_DIR/public" ]]; then
|
|||||||
fi
|
fi
|
||||||
log "Frontend eingespielt"
|
log "Frontend eingespielt"
|
||||||
|
|
||||||
|
# ── systemd Units synchronisieren ─────────────────────────────────────────
|
||||||
|
# install.sh schreibt die Unit-Dateien nur beim Erst-Setup. Ohne diesen
|
||||||
|
# Schritt bleiben bereits installierte Server auf dem Stand von damals
|
||||||
|
# eingefroren, selbst wenn sich die Unit-Definition im Repo ändert (z.B.
|
||||||
|
# CAP_NET_ADMIN für die Security-Tab-Firewall-Aktion, nachträglich ergänzt —
|
||||||
|
# Server die vor dieser Änderung installiert wurden, hatten die Capability
|
||||||
|
# bis zu diesem Fix hier gefehlt). Bei jedem Deploy neu schreiben + reload,
|
||||||
|
# damit Unit-Änderungen aus install.sh automatisch nachgezogen werden.
|
||||||
|
info "Synchronisiere systemd Units..."
|
||||||
|
STORE_DIR="/var/archivmail"
|
||||||
|
LOG_DIR="/var/log/archivmail"
|
||||||
|
CONFIG_DIR="/etc/archivmail"
|
||||||
|
SSL_DIR="/etc/ssl/archivmail"
|
||||||
|
AM_USER="archivmail"
|
||||||
|
|
||||||
|
cat > /etc/systemd/system/archivmail.service << UNIT
|
||||||
|
[Unit]
|
||||||
|
Description=archivmail Mail Archive Daemon
|
||||||
|
After=network.target postgresql.service manticore.service
|
||||||
|
Requires=postgresql.service manticore.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=${AM_USER}
|
||||||
|
Group=${AM_USER}
|
||||||
|
# CAP_NET_ADMIN: required for the admin "enable firewall" action (nft -f /etc/nftables.conf)
|
||||||
|
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
|
||||||
|
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
|
||||||
|
ExecStart=${INSTALL_DIR}/archivmail --config ${CONFIG_DIR}/config.yml
|
||||||
|
ExecReload=/bin/kill -HUP \$MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier=archivmail
|
||||||
|
NoNewPrivileges=false
|
||||||
|
ProtectSystem=strict
|
||||||
|
ReadWritePaths=${STORE_DIR} ${LOG_DIR}
|
||||||
|
ReadOnlyPaths=${CONFIG_DIR} ${SSL_DIR}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
UNIT
|
||||||
|
|
||||||
|
cat > /etc/systemd/system/archivmail-web.service << UNIT
|
||||||
|
[Unit]
|
||||||
|
Description=archivmail Web Frontend
|
||||||
|
After=network.target archivmail.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=${AM_USER}
|
||||||
|
Group=${AM_USER}
|
||||||
|
WorkingDirectory=${INSTALL_DIR}/web
|
||||||
|
ExecStart=/usr/bin/node server.js
|
||||||
|
Environment=NODE_ENV=production
|
||||||
|
Environment=PORT=3000
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier=archivmail-web
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
UNIT
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable archivmail archivmail-web --quiet
|
||||||
|
log "systemd Units synchronisiert"
|
||||||
|
|
||||||
# ── Dienste starten ───────────────────────────────────────────────────────
|
# ── Dienste starten ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
info "Starte Dienste..."
|
info "Starte Dienste..."
|
||||||
|
|||||||
Reference in New Issue
Block a user