Compare commits

...

2 Commits

Author SHA1 Message Date
Milan
fc352f2ff3 Merge branch 'main' of dev.hostsharing.net:hostsharing/hs.scripts 2024-10-23 15:21:58 +02:00
Milan
58176fd84c smarter keycloak update script 2024-10-23 15:20:21 +02:00

View File

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
set -e set -e
if [ -z "$1" ] #
then # Use ./update.sh 1.2.3 to OVERRIDE the release check.
echo "ERROR: Can't continue. Version querying not implemented, because we might not use the latest major release." #
echo "Usage: bash ./update.sh 9.9.9" # Without an argument, THIS SCRIPT WILL AUTODETECT the release
exit 1 # that was tagged as "latest" by the project.
fi #
export XDG_RUNTIME_DIR=/run/user/$UID
export XDG_RUNTIME_DIR=/run/user/$UID
location=$HOME location=$HOME
olddir=`readlink $location/latest` olddir=`readlink $location/latest`
@ -16,14 +16,37 @@ olddir=`readlink $location/latest`
# script does not require this to function # script does not require this to function
#themename=mytheme #themename=mytheme
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 systemctl stop --user keycloak
cd $location cd $location
# FIXME: move to rsync or use git tags directly # FIXME: move to rsync or use git tags directly
wget "https://github.com/keycloak/keycloak/releases/download/$1/keycloak-$1.zip" wget "https://github.com/keycloak/keycloak/releases/download/$release/keycloak-$release.zip"
unzip keycloak-$1.zip unzip keycloak-$release.zip
rm keycloak-$1.zip rm keycloak-$release.zip
[ -L $location/latest ] && rm -v $location/latest [ -L $location/latest ] && rm -v $location/latest
ln -sv $location/keycloak-$1 $location/latest ln -sv $location/keycloak-$1 $location/latest