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 header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /opt/keycloak ]]; then if [[ ! -d /opt/keycloak ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} installation found!"
exit exit 1
fi 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 check_for_update "${APP}" "keycloak/keycloak"; then
if [[ "${RELEASE}" != "$(cat ~/.keycloak 2>/dev/null)" ]] || [[ ! -f ~/.keycloak ]]; then local release="$CHECK_UPDATE_RELEASE"
msg_info "Stopping ${APP}" msg_info "Stopping ${APP}"
systemctl stop keycloak systemctl stop keycloak
msg_ok "Stopped ${APP}" msg_ok "Stopped ${APP}"
@ -45,7 +47,7 @@ function update_script() {
tar -czf keycloak_conf_backup.tar.gz keycloak.old/conf tar -czf keycloak_conf_backup.tar.gz keycloak.old/conf
msg_ok "Backup done" 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}" msg_info "Updating ${APP}"
cd /opt cd /opt
@ -55,14 +57,15 @@ function update_script() {
rm -rf keycloak.old rm -rf keycloak.old
msg_ok "Updated ${APP} LXC" msg_ok "Updated ${APP} LXC"
msg_info "Restating Keycloak" echo "${release}" >~/.keycloak
msg_info "Restarting Keycloak"
systemctl restart keycloak systemctl restart keycloak
msg_ok "Restated Keycloak" msg_ok "Restarted Keycloak"
msg_ok "Update Successful" msg_ok "Update to v${release} successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi fi
exit
exit 0
} }
start start