77 lines
2.0 KiB
Bash
77 lines
2.0 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
#
|
|
# 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.
|
|
#
|
|
|
|
export XDG_RUNTIME_DIR=/run/user/$UID
|
|
location=$HOME
|
|
olddir=`readlink $location/latest`
|
|
|
|
# becomes $location/latest/themes/themename
|
|
# script does not require this to function
|
|
#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
|
|
|
|
cd $location
|
|
|
|
# FIXME: move to rsync or use git tags directly
|
|
wget "https://github.com/keycloak/keycloak/releases/download/$release/keycloak-$release.zip"
|
|
unzip keycloak-$release.zip
|
|
rm keycloak-$release.zip
|
|
|
|
[ -L $location/latest ] && rm -v $location/latest
|
|
ln -sv $location/keycloak-$1 $location/latest
|
|
|
|
# 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 |