Update keycloak.sh

This commit is contained in:
CanbiZ 2025-07-25 10:52:59 +02:00
parent 6334e3173a
commit 69f4341aaa

View File

@ -23,13 +23,15 @@ function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/keycloak ]]; then
msg_error "No ${APP} Installation Found!"
exit
msg_error "No ${APP} installation found!"
exit 1
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ "${RELEASE}" != "$(cat ~/.keycloak 2>/dev/null)" ]] || [[ ! -f ~/.keycloak ]]; then
if check_for_update "${APP}" "keycloak/keycloak"; then
local release="$CHECK_UPDATE_RELEASE"
msg_info "Stopping ${APP}"
systemctl stop keycloak
msg_ok "Stopped ${APP}"
@ -45,7 +47,7 @@ function update_script() {
tar -czf keycloak_conf_backup.tar.gz keycloak.old/conf
msg_ok "Backup done"
fetch_and_deploy_gh_release "keycloak" "keycloak/keycloak" "prebuild" "latest" "/opt/keycloak" "keycloak-*.tar.gz"
fetch_and_deploy_gh_release "keycloak" "keycloak/keycloak" "prebuild" "$release" "/opt/keycloak" "keycloak-*.tar.gz"
msg_info "Updating ${APP}"
cd /opt
@ -55,14 +57,15 @@ function update_script() {
rm -rf keycloak.old
msg_ok "Updated ${APP} LXC"
msg_info "Restating Keycloak"
echo "${release}" >~/.keycloak
msg_info "Restarting Keycloak"
systemctl restart keycloak
msg_ok "Restated Keycloak"
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
msg_ok "Restarted Keycloak"
msg_ok "Update to v${release} successful"
fi
exit
exit 0
}
start