Initial Commit

This commit is contained in:
2026-05-21 23:14:36 +02:00
parent 2fc1bc480c
commit 2b77272263
10 changed files with 469 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
CONFIG_FILE="${1:-/etc/relaydock/config.json}"
PREFIX="${RELAYDOCK_PREFIX:-relaydock}"
command -v jq >/dev/null 2>&1 || { echo "Fehlt: jq" >&2; exit 1; }
[[ -f "$CONFIG_FILE" ]] || { echo "Config fehlt: $CONFIG_FILE" >&2; exit 1; }
mapfile -t desired < <(jq -r '.rules[].name' "$CONFIG_FILE" | sort -u)
mapfile -t current < <(systemctl list-units --full --all "${PREFIX}@*.service" --no-legend | awk '{print $1}' | sed -E "s/^${PREFIX}@(.*)\\.service$/\\1/" | sort -u)
for name in "${desired[@]}"; do
systemctl enable --now "${PREFIX}@${name}.service"
done
for name in "${current[@]}"; do
if ! printf '%s\n' "${desired[@]}" | grep -qx "$name"; then
systemctl disable --now "${PREFIX}@${name}.service" || true
else
systemctl restart "${PREFIX}@${name}.service"
fi
done