Initial commit: Media Server Dashboard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
MOUNT="/downloads"
|
||||
OUTPUT="/html/disk.json"
|
||||
|
||||
update_disk() {
|
||||
LINE=$(df -h "$MOUNT" 2>/dev/null | awk 'NR==2')
|
||||
if [ -z "$LINE" ]; then
|
||||
echo "ERROR: df failed for $MOUNT" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
TOTAL=$(echo "$LINE" | awk '{print $2}')
|
||||
USED=$(echo "$LINE" | awk '{print $3}')
|
||||
AVAILABLE=$(echo "$LINE" | awk '{print $4}')
|
||||
USE_PERCENT=$(echo "$LINE" | awk '{print $5}')
|
||||
|
||||
cat > "$OUTPUT" <<JSON
|
||||
{
|
||||
"total": "$TOTAL",
|
||||
"used": "$USED",
|
||||
"available": "$AVAILABLE",
|
||||
"use_percent": "$USE_PERCENT",
|
||||
"updated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
}
|
||||
JSON
|
||||
|
||||
echo "disk.json updated: $USE_PERCENT used ($USED / $TOTAL)"
|
||||
}
|
||||
|
||||
while true; do
|
||||
update_disk || true
|
||||
sleep 30
|
||||
done
|
||||
Reference in New Issue
Block a user