Initial commit - podman-mvp net na toevoegen cpu en mem kolommen
This commit is contained in:
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE_URL="http://127.0.0.1:8080/api"
|
||||
ALLOWLIST_FILE="$HOME/systemctl-webui/allowed_units.txt"
|
||||
LOG_FILE="./systemd_api_test_$(date +%F_%H%M%S).log"
|
||||
|
||||
# Helper: log zowel naar scherm als bestand
|
||||
log() {
|
||||
echo "$*" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Helper: POST en log response
|
||||
post() {
|
||||
local path="$1"
|
||||
log ""
|
||||
log "### POST $BASE_URL$path"
|
||||
# -sS: silent maar errors tonen, -i: headers ook, voor debugging
|
||||
curl -sS -i -X POST "$BASE_URL$path" | tee -a "$LOG_FILE"
|
||||
log ""
|
||||
}
|
||||
|
||||
# URL-encode alleen het @ teken (meest voorkomende issue)
|
||||
# (Als je later meer nodig hebt, kunnen we dat uitbreiden)
|
||||
encode_unit() {
|
||||
echo "$1" | sed 's/@/%40/g'
|
||||
}
|
||||
|
||||
log "== Systemd API test gestart =="
|
||||
log "Base URL: $BASE_URL"
|
||||
log "Allowlist: $ALLOWLIST_FILE"
|
||||
log "Log file: $LOG_FILE"
|
||||
|
||||
if [[ ! -f "$ALLOWLIST_FILE" ]]; then
|
||||
log "ERROR: allowlist bestand niet gevonden: $ALLOWLIST_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log ""
|
||||
log "== 1) daemon-reload =="
|
||||
post "/daemon-reload"
|
||||
|
||||
log ""
|
||||
log "== 2) status van allowlisted units =="
|
||||
while IFS= read -r unit; do
|
||||
unit="$(echo "$unit" | sed 's/#.*//; s/[[:space:]]//g')"
|
||||
[[ -z "$unit" ]] && continue
|
||||
[[ "$unit" != *.service ]] && continue
|
||||
|
||||
enc_unit="$(encode_unit "$unit")"
|
||||
post "/status/$enc_unit"
|
||||
done < "$ALLOWLIST_FILE"
|
||||
|
||||
log ""
|
||||
log "== 3) start sonarr.service (als in allowlist) =="
|
||||
if grep -qE '^[[:space:]]*sonarr\.service[[:space:]]*$' "$ALLOWLIST_FILE"; then
|
||||
post "/start/sonarr.service"
|
||||
log "== 4) status sonarr.service na start =="
|
||||
post "/status/sonarr.service"
|
||||
else
|
||||
log "SKIP: sonarr.service staat niet in allowlist"
|
||||
fi
|
||||
|
||||
log ""
|
||||
log "== Klaar. Output staat in: $LOG_FILE =="
|
||||
Reference in New Issue
Block a user