Compare commits

...
1 Commits
Author SHA1 Message Date
esefandClaude Opus 5.5 153e44b661 make-mirror: keep the login out of the upload folder, upload only pinned files
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:00:43 +03:00
+6 -3
View File
@@ -11,8 +11,9 @@ cd "$(dirname "$0")/.."
API=https://git.userevolt.app/api/v1/repos/esef/cs16-dm-server API=https://git.userevolt.app/api/v1/repos/esef/cs16-dm-server
TAG=mods TAG=mods
PY=$(command -v python3 || command -v python) || { echo "needs python3"; exit 1; } PY=$(command -v python3 || command -v python) || { echo "needs python3"; exit 1; }
DIR=$(mktemp -d); trap 'rm -rf "$DIR"' EXIT # Two separate temp folders: only $DIR's files get uploaded, so the login must never be in it.
CFG=$DIR/curl.cfg # credentials go to curl through a file, not the command line DIR=$(mktemp -d); SEC=$(mktemp -d); trap 'rm -rf "$DIR" "$SEC"' EXIT
CFG=$SEC/curl.cfg # credentials go to curl through a file, not the command line
umask 077 umask 077
if [ -n "$GITEA_TOKEN" ]; then if [ -n "$GITEA_TOKEN" ]; then
printf 'header = "Authorization: token %s"\n' "$GITEA_TOKEN" > "$CFG" printf 'header = "Authorization: token %s"\n' "$GITEA_TOKEN" > "$CFG"
@@ -39,7 +40,7 @@ cat tools/versions.txt tools/versions-windows.txt | tr -d '\r' | grep -v '^#' |
done done
echo "== release '$TAG'" echo "== release '$TAG'"
id=$(curl -fsS -K "$CFG" "$API/releases/tags/$TAG" 2>/dev/null | json "d['id']" || true) id=$(curl -fsS -K "$CFG" "$API/releases/tags/$TAG" 2>/dev/null | json "d['id']" 2>/dev/null || true)
if [ -z "$id" ]; then if [ -z "$id" ]; then
body='Backup copies of the mod downloads, used by setup only when a main site is down. Every file is checked against tools/versions.txt before it is installed. Sources and licenses: ReHLDS, ReGameDLL_CS (MIT), Metamod-R, ReAPI, ReUnion (GPL-3.0) at github.com/rehlds; AMX Mod X (GPL-3.0) at github.com/alliedmodders/amxmodx; YaPB (Unlicense) at github.com/yapb/yapb.' body='Backup copies of the mod downloads, used by setup only when a main site is down. Every file is checked against tools/versions.txt before it is installed. Sources and licenses: ReHLDS, ReGameDLL_CS (MIT), Metamod-R, ReAPI, ReUnion (GPL-3.0) at github.com/rehlds; AMX Mod X (GPL-3.0) at github.com/alliedmodders/amxmodx; YaPB (Unlicense) at github.com/yapb/yapb.'
id=$(printf '{"tag_name":"%s","target_commitish":"main","name":"Mod downloads (backup copies)","body":"%s"}' "$TAG" "$body" | id=$(printf '{"tag_name":"%s","target_commitish":"main","name":"Mod downloads (backup copies)","body":"%s"}' "$TAG" "$body" |
@@ -53,6 +54,8 @@ have=$(curl -fsS -K "$CFG" "$API/releases/$id/assets" | json "'\n'.join(a['name'
echo "== uploading" echo "== uploading"
for p in "$DIR"/*; do for p in "$DIR"/*; do
f=$(basename "$p") f=$(basename "$p")
# upload only files that are pinned in versions*.txt (and were hash-checked above)
grep -qE "^$f [0-9a-f]{64} " tools/versions.txt tools/versions-windows.txt || { echo " skip $f (not a pinned file)"; continue; }
if printf '%s\n' "$have" | grep -qxF "$f"; then echo " have $f"; continue; fi if printf '%s\n' "$have" | grep -qxF "$f"; then echo " have $f"; continue; fi
curl -fsS -K "$CFG" -F "attachment=@$p" "$API/releases/$id/assets?name=$f" > /dev/null curl -fsS -K "$CFG" -F "attachment=@$p" "$API/releases/$id/assets?name=$f" > /dev/null
echo " up $f" echo " up $f"