feat: initial commit — void-installer multi-profile (stable-cinnamon + mainline-niri)
This commit is contained in:
35
tools/start-xbps-proxy.sh
Executable file
35
tools/start-xbps-proxy.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Start the XBPS caching proxy in the background.
|
||||
# Idempotent: does nothing if already running.
|
||||
set -Eeuo pipefail
|
||||
|
||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CACHE_DIR="${XBPS_CACHE_DIR:-$PROJECT_DIR/cache/xbps-pkgs}"
|
||||
PORT="${XBPS_PROXY_PORT:-3142}"
|
||||
PIDFILE="${XBPS_PROXY_PIDFILE:-$PROJECT_DIR/out/xbps-proxy.pid}"
|
||||
LOGFILE="${XBPS_PROXY_LOG:-$PROJECT_DIR/out/xbps-proxy.log}"
|
||||
|
||||
mkdir -p "$(dirname "$PIDFILE")" "$CACHE_DIR"
|
||||
|
||||
# Already running?
|
||||
if [[ -f "$PIDFILE" ]] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||
echo ">>> XBPS proxy already running (pid $(cat "$PIDFILE"), port $PORT)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
XBPS_CACHE_DIR="$CACHE_DIR" \
|
||||
XBPS_PROXY_PORT="$PORT" \
|
||||
python3 "$PROJECT_DIR/tools/xbps-proxy.py" > "$LOGFILE" 2>&1 &
|
||||
echo $! > "$PIDFILE"
|
||||
|
||||
# Wait for the socket to open (up to 5 s).
|
||||
for i in $(seq 1 20); do
|
||||
if curl -sf --max-time 1 "http://127.0.0.1:$PORT/" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
|
||||
echo ">>> XBPS proxy started (pid $(cat "$PIDFILE"), port $PORT)"
|
||||
echo " cache : $CACHE_DIR"
|
||||
echo " log : $LOGFILE"
|
||||
Reference in New Issue
Block a user