| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/bin/sh
- # ---------------------------------------------------------------------------
- # WeBrake updater — pulls the latest app.py and index.html (and this script)
- # directly from the repo and restarts the service.
- #
- # token.json is local-only: it is never fetched from the repo and never
- # overwritten by this script.
- #
- # /opt/webrake/update.sh
- # ---------------------------------------------------------------------------
- set -eu
- REPO_RAW="${WEBRAKE_REPO:-https://gogs.av2x.dev/av2x/WeBrake/raw/master}"
- APP_DIR="/opt/webrake"
- say() { printf '\033[1;33m[WeBrake]\033[0m %s\n' "$*"; }
- die() { printf '\033[1;31m[WeBrake]\033[0m %s\n' "$*" >&2; exit 1; }
- [ "$(id -u)" = "0" ] || die "Run as root inside the Alpine container."
- [ -d "$APP_DIR" ] || die "WeBrake is not installed at $APP_DIR — run install.sh first."
- changed=0
- for f in app.py index.html update.sh; do
- say "Fetching $f ..."
- wget -q -O "$APP_DIR/$f.new" "$REPO_RAW/$f" || die "Failed to fetch $f from the repo."
- if [ -f "$APP_DIR/$f" ] && cmp -s "$APP_DIR/$f" "$APP_DIR/$f.new"; then
- rm -f "$APP_DIR/$f.new"
- say " $f unchanged."
- else
- # Keep one backup of the previous version.
- [ -f "$APP_DIR/$f" ] && cp "$APP_DIR/$f" "$APP_DIR/$f.bak"
- mv "$APP_DIR/$f.new" "$APP_DIR/$f"
- say " $f updated (previous copy at $f.bak)."
- changed=1
- fi
- done
- chmod +x "$APP_DIR/update.sh"
- if [ "$changed" = "1" ]; then
- say "Restarting WeBrake service..."
- rc-service webrake restart || say "Could not restart via OpenRC — restart manually."
- say "Update complete. token.json was left untouched."
- else
- say "Already up to date."
- fi
|