Implement feedback from PR review

This commit is contained in:
Rémi Bédard-Couture 2025-07-03 13:09:38 -04:00
parent 45a6418d59
commit c1bdeb0653
2 changed files with 61 additions and 58 deletions

View File

@ -13,7 +13,6 @@ var_disk="${var_disk:-4}"
var_os="${var_os:-debian}"
var_version="${var_version:-12}"
var_unprivileged="${var_unprivileged:-1}"
var_postfix_sat="${var_postfix_sat:-yes}"
header_info "$APP"
variables
@ -21,42 +20,43 @@ color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /etc/systemd/system/keycloak.service ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Stopping ${APP}"
systemctl stop keycloak
msg_ok "Stopped ${APP}"
msg_info "Updating packages"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated packages"
RELEASE=$(curl -fsSL https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
msg_info "Updating ${APP} to v$RELEASE"
cd /opt
wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz
mv keycloak keycloak.old
tar -xzf keycloak-$RELEASE.tar.gz
tar -czf keycloak_conf_backup.tar.gz keycloak.old/conf
mv keycloak_conf_backup.tar.gz keycloak-$RELEASE/conf
cp -r keycloak.old/providers keycloak-$RELEASE
cp -r keycloak.old/themes keycloak-$RELEASE
mv keycloak-$RELEASE keycloak
rm keycloak-$RELEASE.tar.gz
rm -rf keycloak.old
msg_ok "Updated ${APP} LXC"
msg_info "Restating Keycloak"
systemctl restart keycloak
msg_ok "Restated Keycloak"
header_info
check_container_storage
check_container_resources
if [[ ! -f /etc/systemd/system/keycloak.service ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Stopping ${APP}"
systemctl stop keycloak
msg_ok "Stopped ${APP}"
msg_info "Updating packages"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated packages"
msg_info "Backup old Keycloak"
cd /opt
mv keycloak keycloak.old
tar -czf keycloak_conf_backup.tar.gz keycloak.old/conf
msg_ok "Backup done"
fetch_and_deploy_gh_release "keycloak" "keycloak/keycloak" "tarball" "latest" "/opt/keycloak"
msg_info "Updating ${APP}"
cd /opt
mv keycloak_conf_backup.tar.gz keycloak/conf
cp -r keycloak.old/providers keycloak
cp -r keycloak.old/themes keycloak
rm -rf keycloak.old
msg_ok "Updated ${APP} LXC"
msg_info "Restating Keycloak"
systemctl restart keycloak
msg_ok "Restated Keycloak"
exit
}
start

View File

@ -14,24 +14,25 @@ network_check
update_os
msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y curl
$STD apt-get install -y sudo
$STD apt-get install -y mc
$STD apt-get install -y ca-certificates-java
#$STD apt-get install -y ca-certificates-java
msg_ok "Installed Dependencies"
msg_info "Installing OpenJDK"
$STD apt install wget lsb-release -y
$STD wget https://packages.microsoft.com/config/debian/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$STD dpkg -i packages-microsoft-prod.deb
$STD apt update
$STD apt install -y msopenjdk-21
sudo update-java-alternatives --set msopenjdk-21-amd64
rm packages-microsoft-prod.deb
msg_ok "Installed OpenJDK"
#msg_info "Installing OpenJDK"
#$STD apt install wget lsb-release -y
#$STD wget https://packages.microsoft.com/config/debian/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
#$STD dpkg -i packages-microsoft-prod.deb
#$STD apt update
#$STD apt install -y msopenjdk-21
#sudo update-java-alternatives --set msopenjdk-21-amd64
#rm packages-microsoft-prod.deb
#msg_ok "Installed OpenJDK"
JAVA_VERSION=21 setup_java
msg_info "Installing PostgreSQL"
$STD apt-get install -y postgresql
#$STD apt-get install -y postgresql
PG_VERSION=16 setup_postgresql
DB_NAME="keycloak"
DB_USER="keycloak"
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
@ -40,13 +41,15 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCO
$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
msg_ok "Installed PostgreSQL"
msg_info "Installing Keycloak"
temp_file=$(mktemp)
RELEASE=$(curl -fsSL https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz" -o "$temp_file"
tar xzf $temp_file
mv keycloak-$RELEASE /opt/keycloak
msg_ok "Installed Keycloak"
fetch_and_deploy_gh_release "keycloak" "keycloak/keycloak" "tarball" "latest" "/opt/keycloak"
#msg_info "Installing Keycloak"
#temp_file=$(mktemp)
#RELEASE=$(curl -fsSL https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
#curl -fsSL "https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz" -o "$temp_file"
#tar xzf $temp_file
#mv keycloak-$RELEASE /opt/keycloak
#msg_ok "Installed Keycloak"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/keycloak.service
@ -84,7 +87,7 @@ motd_ssh
customize
msg_info "Cleaning up"
rm -f $temp_file
#rm -f $temp_file
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"