64 lines
1.6 KiB
Bash
64 lines
1.6 KiB
Bash
#!/bin/bash
|
|
# source: https://git.tchncs.de/tchncs/tchncs-scripts/-/blob/main/updates/keycloak.sh
|
|
|
|
# Use ./update.sh 1.2.3 to OVERRIDE the release check.
|
|
|
|
# Without an argument, THIS SCRIPT WILL AUTODETECT the release
|
|
# that was tagged as "latest" by the project.
|
|
set -e
|
|
|
|
if [ -z "$1" ]
|
|
then
|
|
release=`curl -L https://api.github.com/repos/keycloak/keycloak/releases/latest -s | jq -r '.tag_name'`
|
|
echo ">>> Detected v$release being tagged as the latest release."
|
|
else
|
|
release=$1
|
|
fi
|
|
|
|
current_release=$(cat latest/version.txt)
|
|
current_release=${current_release#'Keycloak - Version '}
|
|
|
|
if [[ $current_release == "$release" ]]
|
|
then
|
|
echo ">>> It appears, are on v$current_release. Nothing to do."
|
|
exit
|
|
else
|
|
read -p "Proceed? With Keycloak ${release}?" -n 1 -r
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
then
|
|
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
|
|
fi
|
|
fi
|
|
|
|
systemctl stop --user keycloak
|
|
|
|
echo ">>> calling for rollback.sh"
|
|
. $HOME/scripts/rollback.sh
|
|
|
|
cd $location
|
|
|
|
wget "https://github.com/keycloak/keycloak/releases/download/$release/keycloak-$release.zip"
|
|
unzip keycloak-$release.zip
|
|
rm keycloak-$release.zip
|
|
|
|
[ -L latest ] && rm -v latest
|
|
ln -sv $location/keycloak-$1 $location/latest
|
|
|
|
# default config got the same filename!
|
|
rm -v latest/conf/keycloak.conf
|
|
|
|
ln -sv $location/config/* $location/latest/conf/
|
|
|
|
bash latest/bin/kc.sh build
|
|
|
|
cp -r $HOME/themes/$theme $HOME/latest/themes/
|
|
|
|
systemctl restart --user keycloak
|
|
|
|
echo ">>> waiting 10s so Keycloak may run migrations..."
|
|
sleep 10
|
|
|
|
echo ">>> calling setstate.sh to make the update permanent"
|
|
. $HOME/scripts/setstate.sh
|
|
|
|
echo "Done." |