feat(server): add self-hosted fws Arch repo server and Caddy config
Publishes the Python stdlib server (admin UI, upload API, repo-add compatible DB generation) with its deployed Caddyfile, install script and pacman client snippet, so the whole fws repository stack lives next to the package sources. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
a73a901389
commit
c903e28254
10 files changed
+1851
No files matched your search
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
# Envoie un ou plusieurs paquets vers le dépôt archrepo.
|
||||
#
|
||||
# REPO_URL=http://mc.laxacube.ch:30065 REPO_TOKEN=... ./push.sh *.pkg.tar.zst
|
||||
#
|
||||
# REPO_URL URL du dépôt (défaut : http://127.0.0.1:30065 ; Caddy écoute le port
|
||||
# pour n'importe quel Host, le nom public fonctionne aussi)
|
||||
# REPO_TOKEN jeton d'administration ; à défaut, lu dans $ARCHREPO_TOKEN_FILE
|
||||
# (/etc/archrepo/token par défaut), avec sudo si nécessaire.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="${REPO_URL:-http://127.0.0.1:30065}"
|
||||
TOKEN_FILE="${ARCHREPO_TOKEN_FILE:-/etc/archrepo/token}"
|
||||
REPO_TOKEN="${REPO_TOKEN:-}"
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 [--url URL] [--token JETON] <paquet.pkg.tar.zst> [...]" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--url) REPO_URL="${2:?}"; shift 2 ;;
|
||||
--token) REPO_TOKEN="${2:?}"; shift 2 ;;
|
||||
-h|--help) usage ;;
|
||||
--) shift; break ;;
|
||||
-*) echo "option inconnue : $1" >&2; usage ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $# -eq 0 ]]; then usage; fi
|
||||
|
||||
if [[ -z "$REPO_TOKEN" ]]; then
|
||||
if [[ -r "$TOKEN_FILE" ]]; then
|
||||
REPO_TOKEN="$(<"$TOKEN_FILE")"
|
||||
elif command -v sudo >/dev/null 2>&1 && sudo -n cat "$TOKEN_FILE" >/dev/null 2>&1; then
|
||||
REPO_TOKEN="$(sudo -n cat "$TOKEN_FILE")"
|
||||
else
|
||||
echo "jeton introuvable : passez --token ou REPO_TOKEN" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
REPO_TOKEN="${REPO_TOKEN//[$'\r\n']/}"
|
||||
|
||||
REPO_URL="${REPO_URL%/}"
|
||||
echo "→ $REPO_URL"
|
||||
|
||||
status=0
|
||||
for pkg in "$@"; do
|
||||
[[ -f "$pkg" ]] || { echo "fichier introuvable : $pkg" >&2; status=1; continue; }
|
||||
name="$(basename "$pkg")"
|
||||
printf ' %s ' "$name"
|
||||
if response="$(curl -sS -w '\n%{http_code}' -X POST "$REPO_URL/api/packages" \
|
||||
-H "Authorization: Bearer $REPO_TOKEN" \
|
||||
-H "X-Filename: $name" \
|
||||
-H 'Content-Type: application/octet-stream' \
|
||||
--data-binary "@$pkg")"; then
|
||||
code="${response##*$'\n'}"
|
||||
body="${response%$'\n'*}"
|
||||
# Un simple 200 ne suffit pas : on exige une réponse JSON valide du service
|
||||
# (un hôte mal configuré dans Caddy renvoie un 200 vide).
|
||||
if [[ "$code" == "200" ]] && grep -Eq '"ok" *: *true' <<<"$body"; then
|
||||
echo "✓"
|
||||
else
|
||||
echo "✗ ($code)"
|
||||
if [[ -n "$body" ]]; then
|
||||
printf '%s\n' "$body" | sed 's/^/ /'
|
||||
else
|
||||
echo " réponse vide — vérifiez l'URL publiée par Caddy pour cet hôte"
|
||||
fi
|
||||
status=1
|
||||
fi
|
||||
else
|
||||
echo "✗ (connexion impossible)"
|
||||
status=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "$status"
|
||||
Reference in new issue
Block a user