File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ PREFIX="${TRONBROWSER_PREFIX:-$HOME/.local}"
6666APP_DIR="$PREFIX/lib/tronbrowser"
6767CURRENT="$APP_DIR/current"
6868VERSION_FILE="$APP_DIR/VERSION"
69+ AUTO_UPGRADE_STAMP="$APP_DIR/.last-auto-upgrade-check"
6970INSTALL_URL="https://tronbrowser.dev/install.sh"
7071
7172usage() {
@@ -80,11 +81,37 @@ Usage:
8081 tron remove Uninstall TronBrowser (keeps your profile data)
8182 tron version Print the installed version
8283 tron help Show this help
84+
85+ Set TRONBROWSER_AUTO_UPGRADE=0 to skip the once-daily background upgrade check.
8386USAGE
8487}
8588
89+ maybe_auto_upgrade() {
90+ case "${TRONBROWSER_AUTO_UPGRADE:-1}" in
91+ 0|false|False|FALSE|no|No|NO) return 0 ;;
92+ esac
93+ command -v curl >/dev/null 2>&1 || return 0
94+ [ -d "$APP_DIR" ] || return 0
95+
96+ now="$(date +%s 2>/dev/null || echo 0)"
97+ last="$(cat "$AUTO_UPGRADE_STAMP" 2>/dev/null || echo 0)"
98+ case "$now:$last" in
99+ 0:*) return 0 ;;
100+ esac
101+ case "$last" in
102+ ''|*[!0-9]*) last=0 ;;
103+ esac
104+ [ "$((now - last))" -lt 86400 ] && return 0
105+
106+ printf '%s\n' "$now" > "$AUTO_UPGRADE_STAMP" 2>/dev/null || return 0
107+ (
108+ TRONBROWSER_AUTO_UPGRADE=0 sh -c "curl -fsSL '$INSTALL_URL' | sh -s -- upgrade"
109+ ) >/dev/null 2>&1 &
110+ }
111+
86112launch() {
87113 [ -x "$CURRENT" ] || { echo "TronBrowser is not installed. Run: curl -fsSL $INSTALL_URL | sh" >&2; exit 1; }
114+ maybe_auto_upgrade
88115 exec "$CURRENT" "$@"
89116}
90117
You can’t perform that action at this time.
0 commit comments