added restapi

This commit is contained in:
2026-11-02 16:46:20 +03:00
parent 9d74d06ce3
commit 588c2e0135
74 changed files with 7253 additions and 129 deletions
+31 -3
View File
@@ -64,13 +64,36 @@ except Exception:
PY
}
# Missing key means enabled, matching ConfigManager::ensureDefaults().
collector_enabled() {
python3 - <<'PY'
import json, os, sys
root = os.environ.get("BUTTONTASK_ROOT", "/opt/buttontask")
path = os.path.join(root, "config", "config.json")
try:
with open(path, encoding="utf-8") as f:
cfg = json.load(f)
enabled = cfg.get("settings", {}).get("collectorEnabled", True)
except Exception:
enabled = True
sys.exit(0 if enabled else 1)
PY
}
restart_services() {
log "restart buttontask"
systemctl restart buttontask 2>/dev/null || true
log "restart buttontask-web"
systemctl restart buttontask-web 2>/dev/null || true
log "restart buttontask-collector"
systemctl restart buttontask-collector 2>/dev/null || true
if collector_enabled; then
log "restart buttontask-collector"
systemctl unmask buttontask-collector >/dev/null 2>&1 || true
systemctl enable buttontask-collector >/dev/null 2>&1 || true
systemctl restart buttontask-collector 2>/dev/null || true
else
log "collector disabled — leave it stopped"
systemctl disable --now buttontask-collector >/dev/null 2>&1 || true
fi
}
# Returns 0 when the freshly started version looks healthy.
@@ -179,7 +202,12 @@ cmd_stage() {
install -m0644 "$dest/webconfig/buttontask-collector.service" \
/etc/systemd/system/buttontask-collector.service
systemctl daemon-reload 2>/dev/null || true
systemctl enable buttontask-collector >/dev/null 2>&1 || true
if collector_enabled; then
systemctl unmask buttontask-collector >/dev/null 2>&1 || true
systemctl enable buttontask-collector >/dev/null 2>&1 || true
else
systemctl disable --now buttontask-collector >/dev/null 2>&1 || true
fi
log "synced buttontask-collector.service"
fi