From 5df560a9228a7f26a4159d0ac051b1e8a30edbfe Mon Sep 17 00:00:00 2001 From: Denton Social Date: Sat, 26 Sep 2026 17:27:47 -0500 Subject: [PATCH] bootstrap: put simplex profile under .runtime/simplex/, apply changed units -d is a path prefix, so pass .runtime/simplex/simplex_v1 to keep the daemon DBs inside the profile dir. Also detect a changed rendered unit and restart already-running services so a rerun applies template changes. --- scripts/bootstrap.sh | 25 +++++++++++++++++++++++- scripts/systemd/semif-simplex.service.in | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index f0a206f..6203a7f 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -280,9 +280,22 @@ render_unit() { -e "s|@DISPLAY_NAME@|$SIMPLEX_DISPLAY|g" "$src" > "$dst" } echo "== rendering systemd user units into $UNITS" +UNIT_CHANGED=0 +ACTIVE_BEFORE="" for unit in semif-simplex.service semif-gateway.service; do - render_unit "$REPO_ROOT/scripts/systemd/$unit.in" "$UNITS/$unit" + tmp="$UNITS/$unit.new" + render_unit "$REPO_ROOT/scripts/systemd/$unit.in" "$tmp" + if [[ ! -f "$UNITS/$unit" ]] || ! cmp -s "$tmp" "$UNITS/$unit"; then + mv "$tmp" "$UNITS/$unit" + UNIT_CHANGED=1 + else + rm -f "$tmp" + fi ln -sf "$UNITS/$unit" "$USER_UNITS/$unit" + if command -v systemctl >/dev/null 2>&1; then + export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" + systemctl --user is-active --quiet "$unit" 2>/dev/null && ACTIVE_BEFORE="$ACTIVE_BEFORE $unit" + fi done if command -v systemctl >/dev/null 2>&1; then @@ -291,6 +304,16 @@ if command -v systemctl >/dev/null 2>&1; then systemctl --user enable --now semif-simplex.service semif-gateway.service 2>/dev/null \ && echo "== enabled semif-simplex.service semif-gateway.service" \ || echo "WARN: could not enable user services (run: systemctl --user enable --now semif-simplex semif-gateway)" >&2 + # Apply a changed unit to services that were already running (enable --now + # leaves active units untouched). A daemon restart is safe: the simplex + # profile persists and the gateway reconnects. + if [[ "$UNIT_CHANGED" = 1 && -n "$ACTIVE_BEFORE" ]]; then + for unit in $ACTIVE_BEFORE; do + systemctl --user restart "$unit" 2>/dev/null \ + && echo "== restarted $unit (unit changed)" \ + || echo "WARN: could not restart $unit" >&2 + done + fi else echo "WARN: systemctl --user unavailable; units are at $USER_UNITS" >&2 fi diff --git a/scripts/systemd/semif-simplex.service.in b/scripts/systemd/semif-simplex.service.in index d985e2f..a91fe5f 100644 --- a/scripts/systemd/semif-simplex.service.in +++ b/scripts/systemd/semif-simplex.service.in @@ -5,7 +5,7 @@ Wants=network-online.target [Service] Type=simple -ExecStart=@REPO@/.runtime/bin/simplex-chat -p @PORT@ -d @REPO@/.runtime/simplex -k "" --relay --headless --user-display-name "@DISPLAY_NAME@" +ExecStart=@REPO@/.runtime/bin/simplex-chat -p @PORT@ -d @REPO@/.runtime/simplex/simplex_v1 -k "" --relay --headless --user-display-name "@DISPLAY_NAME@" Restart=always RestartSec=10 StandardOutput=journal