fix(sshinstall.sh): support non-systemd init (SysVinit, e.g. MX Linux)

The service step called `systemctl enable --now`, which aborts under
`set -e` when systemd is not PID 1. On MX Linux (SysVinit) this meant sshd
was never started and the firewall and admin-key steps were never reached.

Detect systemd via /run/systemd/system; otherwise fall back to
`update-rc.d`/`chkconfig` + `service <name> start`, failing with a clear
message if the service cannot be started.

Found on the first real-machine run (ThinkCentre M71e, MX Linux 25.2).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
edemilovandClaude Sonnet 5 committed 2026-09-19 18:45:20 +03:00
1 parent 0480c7aed5
commit 84929af184
1 file changed
+24 -5
+24 -5
View File
@@ -88,12 +88,31 @@ esac
# ── Enable + start service ────────────────────────────────────────
header "SSH service"
if systemctl is-active --quiet "$SERVICE"; then
skip "$SERVICE service"
if [[ -d /run/systemd/system ]]; then
# systemd is PID 1
if systemctl is-active --quiet "$SERVICE"; then
skip "$SERVICE service"
else
info "Enabling + starting $SERVICE..."
systemctl enable --now "$SERVICE"
success "$SERVICE running"
fi
else
info "Enabling + starting $SERVICE..."
systemctl enable --now "$SERVICE"
success "$SERVICE running"
# SysVinit / no systemd (e.g. MX Linux default) — use the classic tools
warn "systemd is not running — using SysV init scripts"
if service "$SERVICE" status &>/dev/null; then
skip "$SERVICE service"
else
info "Enabling + starting $SERVICE (SysV)..."
if command -v update-rc.d &>/dev/null; then
update-rc.d "$SERVICE" defaults &>/dev/null || true
update-rc.d "$SERVICE" enable &>/dev/null || true
elif command -v chkconfig &>/dev/null; then
chkconfig "$SERVICE" on || true
fi
service "$SERVICE" start || die "Could not start $SERVICE via 'service' — check /etc/init.d/$SERVICE"
success "$SERVICE running"
fi
fi
# ── Firewall ───────────────────────────────────────────────────────