A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys, Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun VPN routing, and a web dashboard to manage it all. Free & open forever to self-host; optional paid hosted services fund it. See PROMISE.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
67 lines
2.1 KiB
Bash
67 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
manifestCollect()
|
|
{
|
|
local app_name="$1"
|
|
local app_dir="$containers_dir$app_name"
|
|
|
|
local libreportal_commit
|
|
libreportal_commit=$(git -C "${install_scripts_dir%/scripts/}" rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
|
|
|
local compose_file=""
|
|
for candidate in "$app_dir/docker-compose.yml" "$app_dir/compose.yml"; do
|
|
[[ -f "$candidate" ]] && compose_file="$candidate" && break
|
|
done
|
|
|
|
local compose_hash="unknown"
|
|
[[ -n "$compose_file" ]] && compose_hash=$(sha256sum "$compose_file" 2>/dev/null | cut -d' ' -f1)
|
|
|
|
local images_json="[]"
|
|
if [[ -n "$compose_file" ]]; then
|
|
local images=()
|
|
while IFS= read -r line; do
|
|
local img
|
|
img=$(echo "$line" | sed -E 's/^[[:space:]]*image:[[:space:]]*["'\'']?([^"'\'' ]+)["'\'']?.*/\1/')
|
|
[[ -n "$img" ]] && images+=("\"$img\"")
|
|
done < <(grep -E '^[[:space:]]+image:' "$compose_file" 2>/dev/null)
|
|
if [[ ${#images[@]} -gt 0 ]]; then
|
|
images_json="[$(IFS=,; echo "${images[*]}")]"
|
|
fi
|
|
fi
|
|
|
|
local volumes_json="[]"
|
|
if [[ -d "$app_dir" ]]; then
|
|
local vols=()
|
|
while IFS= read -r d; do
|
|
[[ -n "$d" ]] && vols+=("\"$(basename "$d")\"")
|
|
done < <(find "$app_dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null)
|
|
if [[ ${#vols[@]} -gt 0 ]]; then
|
|
volumes_json="[$(IFS=,; echo "${vols[*]}")]"
|
|
fi
|
|
fi
|
|
|
|
local size_bytes
|
|
size_bytes=$(sudo du -sb "$app_dir" 2>/dev/null | awk '{print $1}')
|
|
[[ -z "$size_bytes" ]] && size_bytes=0
|
|
|
|
local file_count
|
|
file_count=$(sudo find "$app_dir" -type f 2>/dev/null | wc -l | tr -d ' ')
|
|
|
|
cat <<EOF
|
|
{
|
|
"version": 2,
|
|
"app": "$app_name",
|
|
"host": "${CFG_INSTALL_NAME:-libreportal}",
|
|
"created_at": "$(date -Iseconds)",
|
|
"libreportal_commit": "$libreportal_commit",
|
|
"engine": "restic",
|
|
"compose_hash": "$compose_hash",
|
|
"images": $images_json,
|
|
"volumes": $volumes_json,
|
|
"size_bytes": $size_bytes,
|
|
"file_count": $file_count,
|
|
"strategy": "${CFG_BACKUP_STRATEGY:-stop-snapshot-start}"
|
|
}
|
|
EOF
|
|
}
|