This commit is contained in:
Slaviša Arežina
2025-08-01 07:24:33 +02:00
committed by GitHub
parent 47ab850e5b
commit afd577db9e
2 changed files with 8 additions and 30 deletions

View File

@@ -30,26 +30,18 @@ function update_script() {
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/oauth2-proxy/oauth2-proxy/releases/latest | jq -r .tag_name | sed 's/^v//')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
if [[ ! -f ~/.oauth2-proxy ]] || [[ "${RELEASE}" != "$(cat ~/.oauth2-proxy)" ]]; then
msg_info "Stopping ${APP} services"
systemctl stop oauth2-proxy
msg_ok "Stopped ${APP}"
msg_ok "Stopped ${APP} service"
msg_info "Updating $APP to ${RELEASE}"
rm -f /opt/oauth2-proxy/oauth2-proxy
curl -fsSL "https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v${RELEASE}/oauth2-proxy-v${RELEASE}.linux-amd64.tar.gz" -o /opt/oauth2-proxy.tar.gz
tar -xzf /opt/oauth2-proxy.tar.gz
mv /opt/oauth2-proxy-v${RELEASE}.linux-amd64/oauth2-proxy /opt/oauth2-proxy
fetch_and_deploy_gh_release "oauth2-proxy" "oauth2-proxy/oauth2-proxy" "prebuild" "latest" "/opt/oauth2-proxy" "oauth2-proxy*linux-amd64.tar.gz"
msg_info "Starting ${APP} service"
systemctl start oauth2-proxy
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_ok "Started ${APP} service"
msg_info "Cleaning up"
rm -f "/opt/oauth2-proxy.tar.gz"
rm -rf "/opt/oauth2-proxy-v${RELEASE}.linux-amd64"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
msg_ok "Updated successfully!\n"
else
msg_ok "${APP} is already up to date (${RELEASE})"
fi