hs.scripts/updates/keycloak.sh

77 lines
2.0 KiB
Bash
Raw Normal View History

2024-04-25 13:49:12 +02:00
#!/bin/bash
set -e
2024-10-23 15:20:21 +02:00
#
# 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.
#
2024-04-25 13:49:12 +02:00
2024-10-23 15:20:21 +02:00
export XDG_RUNTIME_DIR=/run/user/$UID
2024-04-25 13:49:12 +02:00
location=$HOME
olddir=`readlink $location/latest`
# becomes $location/latest/themes/themename
# script does not require this to function
#themename=mytheme
2024-10-23 15:20:21 +02:00
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
2024-04-25 13:49:12 +02:00
systemctl stop --user keycloak
cd $location
# FIXME: move to rsync or use git tags directly
2024-10-23 15:20:21 +02:00
wget "https://github.com/keycloak/keycloak/releases/download/$release/keycloak-$release.zip"
unzip keycloak-$release.zip
rm keycloak-$release.zip
2024-04-25 13:49:12 +02:00
[ -L $location/latest ] && rm -v $location/latest
ln -sv $location/keycloak-$release $location/latest
2024-04-25 13:49:12 +02:00
# default config got the same filename!
rm -v $location/latest/conf/keycloak.conf
ln -sv $location/config/* $location/latest/conf/
if [ -z ${themename+x} ];
# FIXME: had trouble with symlinking but might have been a coincidence
then
echo "Theme directory is not configured for this script."
echo "Uncomment its variable of needed."
echo "Checking directories in ./themes of old install:"
find $olddir/themes -maxdepth 1 -mindepth 1 -type d
echo
echo "Proceeding..."
else
cp -rp $location/theme $location/latest/themes/$themename;
fi
bash $location/latest/bin/kc.sh build
systemctl start --user keycloak
sleep 2
systemctl status --user keycloak