This commit is contained in:
CanbiZ 2025-08-28 13:51:26 +02:00
parent 3bab2781e2
commit 431f2bd741
2 changed files with 25 additions and 6 deletions

View File

@ -28,8 +28,9 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/FlareSolverr/FlareSolverr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
if [[ "${RELEASE}" != "$(cat ~/.flaresolverr 2>/dev/null)" ]] || [[ ! -f ~/.flaresolverr ]]; then
if check_for_gh_release "flaresolverr" "FlareSolverr/FlareSolverr"; then
msg_info "Stopping service"
systemctl stop flaresolverr
msg_ok "Stopped service"
@ -52,10 +53,8 @@ EOF
msg_info "Starting service"
systemctl start flaresolverr
msg_ok "Started service"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit
exit 0
}
start

View File

@ -2001,7 +2001,27 @@ EOF
fi
}
check_for_update() {
# ------------------------------------------------------------------------------
# Checks for new GitHub release (latest tag).
#
# Description:
# - Queries the GitHub API for the latest release tag
# - Compares it to a local cached version (~/.<app>)
# - If newer, sets global CHECK_UPDATE_RELEASE and returns 0
#
# Usage:
# check_for_gh_release "AppName" "user/repo"
# if [[ $? -eq 0 ]]; then
# echo "New version available: $CHECK_UPDATE_RELEASE"
# # trigger update...
# fi
#
# Notes:
# - Requires `jq` (auto-installed if missing)
# - Does not modify anything, only checks version state
# - Does not support pre-releases
# ------------------------------------------------------------------------------
check_for_gh_release() {
local app="$1"
local source="$2"
local current_file="$HOME/.${app,,}"