Compare commits
2 Commits
c41a4560c1
...
132604de2d
| Author | SHA1 | Date | |
|---|---|---|---|
| 132604de2d | |||
| 37087e7925 |
@ -25,6 +25,8 @@ By: Codex (GPT-5)
|
||||
| 28.12.2025 | ⚙️ Code | ID: Update-Config Keys in Settings/ENV/README definiert. By: Codex (GPT-5) |
|
||||
| 28.12.2025 | 📝 Req | ID: Update-Flow fuer Client dokumentiert. By: Codex (GPT-5) |
|
||||
| 28.12.2025 | 📝 Req | ID: Update-Flow Prototyp dokumentiert. By: Codex (GPT-5) |
|
||||
| 28.12.2025 | 📝 Req | ID: Update-Status-Schema dokumentiert. By: Codex (GPT-5) |
|
||||
| 28.12.2025 | ⚙️ Code | ID: Update-Status-URL und Report im Client-Prototyp. By: Codex (GPT-5) |
|
||||
| 28.12.2025 | ⚙️ Code | ID: Update-Client Prototyp-Skript hinzugefuegt. By: Codex (GPT-5) |
|
||||
|
||||
---
|
||||
|
||||
@ -36,6 +36,7 @@ Set in `/etc/skd/env` (see `env.example`):
|
||||
- `SKD_UPDATE_URL` (default `https://update.wlkns.org`)
|
||||
- `SKD_UPDATE_TOKEN` (API token for update service)
|
||||
- `SKD_UPDATE_INTERVAL` (seconds; default 3600)
|
||||
- `SKD_UPDATE_STATUS_URL` (default `https://update.wlkns.org/status`)
|
||||
Notes:
|
||||
- `./scripts/install.sh` will create `/etc/skd/env` from `env.example` if missing (edit afterwards) and ensure the `skd` service user/group exist.
|
||||
|
||||
|
||||
@ -42,6 +42,9 @@ class Settings:
|
||||
self.update_url: str = os.getenv("SKD_UPDATE_URL", "https://update.wlkns.org")
|
||||
self.update_token: str = os.getenv("SKD_UPDATE_TOKEN", "")
|
||||
self.update_interval: int = int(os.getenv("SKD_UPDATE_INTERVAL", "3600"))
|
||||
self.update_status_url: str = os.getenv(
|
||||
"SKD_UPDATE_STATUS_URL", "https://update.wlkns.org/status"
|
||||
)
|
||||
# Paths/tools
|
||||
self.notify_send_path: str = os.getenv("SKD_NOTIFY_SEND_PATH", "notify-send")
|
||||
self.sound_player: str = os.getenv("SKD_SOUND_PLAYER", "paplay")
|
||||
|
||||
@ -42,3 +42,7 @@ Beispiel:
|
||||
## Constraints
|
||||
- Update-Service ist extern (update.wlkns.org).
|
||||
- Service muss als root stoppen/starten koennen.
|
||||
|
||||
## Status Reporting
|
||||
- Status wird per HTTP POST an `https://update.wlkns.org/status` gemeldet.
|
||||
- Schema siehe `docs/update-status.md`.
|
||||
|
||||
25
docs/update-status.md
Normal file
25
docs/update-status.md
Normal file
@ -0,0 +1,25 @@
|
||||
ID: DOC_000005 | Version: 0.1.0 | Status: Draft
|
||||
By: Codex (GPT-5)
|
||||
|
||||
# Update Status Reporting
|
||||
|
||||
## Purpose
|
||||
Definiert das Status-Schema fuer Update-Resultate und den Uebertragungsweg.
|
||||
|
||||
## Status Schema (JSON)
|
||||
```json
|
||||
{
|
||||
"device_id": "<hostname>",
|
||||
"version": "0.1.2",
|
||||
"status": "success|failed",
|
||||
"error": "<optional message>",
|
||||
"timestamp": "2025-12-28T12:34:56Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Transport
|
||||
- HTTP POST an `https://update.wlkns.org/status`
|
||||
- Auth: Bearer Token (`SKD_UPDATE_TOKEN`)
|
||||
|
||||
## Notes
|
||||
- Statusmeldungen sind best-effort; Fehler beim Senden blockieren kein Update.
|
||||
@ -25,5 +25,6 @@ SKD_NOTIFY_TIMEOUT=5
|
||||
SKD_UPDATE_URL=https://update.wlkns.org
|
||||
SKD_UPDATE_TOKEN=
|
||||
SKD_UPDATE_INTERVAL=3600
|
||||
SKD_UPDATE_STATUS_URL=https://update.wlkns.org/status
|
||||
# Set to true to test without performing real system changes
|
||||
SKD_DRY_RUN=false
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ID: TASK_000029 | Version: 0.1.0 | Status: Draft
|
||||
ID: TASK_000029 | Version: 0.1.0 | Status: In Progress
|
||||
By: Codex (GPT-5)
|
||||
|
||||
# TASK_000029: Report update status
|
||||
@ -13,6 +13,7 @@ US_000028
|
||||
- Status-Schema definieren (Version, Ergebnis, Fehler, Zeitpunkt).
|
||||
- Transportweg festlegen (z.B. HTTP POST oder Log-Export).
|
||||
- Erfolg/Fehler konsistent dokumentieren.
|
||||
- Schema dokumentiert in `docs/update-status.md`.
|
||||
|
||||
## Definition of Done (DoD)
|
||||
- Status-Schema dokumentiert.
|
||||
|
||||
@ -4,6 +4,7 @@ set -euo pipefail
|
||||
SERVICE_NAME="${SERVICE_NAME:-skd}"
|
||||
UPDATE_URL="${SKD_UPDATE_URL:-https://update.wlkns.org}"
|
||||
UPDATE_TOKEN="${SKD_UPDATE_TOKEN:-}"
|
||||
STATUS_URL="${SKD_UPDATE_STATUS_URL:-https://update.wlkns.org/status}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/opt/sk}"
|
||||
STAGING_DIR=""
|
||||
MANIFEST_FILE=""
|
||||
@ -14,6 +15,24 @@ log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
||||
}
|
||||
|
||||
report_status() {
|
||||
local status="$1"
|
||||
local error="${2:-}"
|
||||
local timestamp
|
||||
timestamp="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
|
||||
local payload
|
||||
payload=$(cat <<JSON
|
||||
{"device_id":"$(hostname)","version":"${VERSION}","status":"${status}","error":"${error}","timestamp":"${timestamp}"}
|
||||
JSON
|
||||
)
|
||||
if [[ -n "${UPDATE_TOKEN}" ]]; then
|
||||
curl -sS -X POST -H "Authorization: Bearer ${UPDATE_TOKEN}" -H "Content-Type: application/json" \
|
||||
-d "${payload}" "${STATUS_URL}" >/dev/null || true
|
||||
else
|
||||
curl -sS -X POST -H "Content-Type: application/json" -d "${payload}" "${STATUS_URL}" >/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${STAGING_DIR}" && -d "${STAGING_DIR}" ]]; then
|
||||
rm -rf "${STAGING_DIR}"
|
||||
@ -80,6 +99,7 @@ log "Verifying checksum..."
|
||||
CALC_SHA="$(sha256sum "${ARTIFACT_FILE}" | awk '{print $1}')"
|
||||
if [[ "${CALC_SHA}" != "${ARTIFACT_SHA256}" ]]; then
|
||||
echo "Checksum mismatch: expected ${ARTIFACT_SHA256} got ${CALC_SHA}" >&2
|
||||
report_status "failed" "checksum mismatch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -101,6 +121,7 @@ STAGING_DIR=""
|
||||
log "Starting service ${SERVICE_NAME}..."
|
||||
if sudo systemctl start "${SERVICE_NAME}.service"; then
|
||||
log "Update applied successfully."
|
||||
report_status "success" ""
|
||||
else
|
||||
log "Service failed to start, rolling back..."
|
||||
sudo rm -rf "${INSTALL_DIR}"
|
||||
@ -108,5 +129,6 @@ else
|
||||
sudo mv "${BACKUP_DIR}" "${INSTALL_DIR}"
|
||||
fi
|
||||
sudo systemctl start "${SERVICE_NAME}.service" || true
|
||||
report_status "failed" "service start failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user