packages/guacamole-client/install.sh
2022-06-16 12:20:42 +02:00

97 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# script for installing guacamole-client
# in the moment systemd only
# warning: this script is using sudo (line 70)!
#--------------------------------------------------
version="1.4.0"
tomcat="tomcat9"
declare -i errors
errors=0
both=false
#--------------------------------------------------
echo "running checks"
if [[ ! -f /usr/bin/curl ]] || [[ ! -f /usr/bin/sha256sum ]]
then
echo "Please install curl and sha256sum on your system. They are needed during the installation process."
errors+=1
fi
if [[ ! -d /etc/${tomcat} ]]
then
echo "Please install ${tomcat} first."
errors+=1
fi
if [[ ! -f /usr/lib/systemd/system/${tomcat}.service ]]
then
echo "${tomcat} doesn't appear as a systemd service. Make shure that you installed ${tomcat} properly."
errors+=1
fi
if [[ ! -f /usr/lib/systemd/system/guacd.service ]]
then
echo "Make shure that you have guacamole-server installed on your system."
errors+=1
fi
webappdir="/var/lib/${tomcat}/webapps"
if [[ ! -d $webappdir ]]
then
echo "Make shure that $webappdir is the right directory for ${tomcat} applications."
errors+=1
fi
if [[ $errors -eq 0 ]]
then
echo "checks complete"
else
echo "Some errors occured (${errors}). Exiting."
exit $errors
fi
#--------------------------------------------------
echo "preparing for installation"
dir="/tmp/guacamole-client-installation"
mkdir $dir
cd $dir
echo "downloading files"
file="guacamole-${version}.war"
curl https://dlcdn.apache.org/guacamole/1.4.0/binary/${file} -o ${file}
curl https://dlcdn.apache.org/guacamole/1.4.0/binary/${file}.sha256 -o ${file}.sha256
checksum="$(cat ${file}.sha256 | cut -b 1-64)"
echo "checksum: $checksum"
echo $checksum ${file} | sha256sum -c
#--------------------------------------------------
echo "installing guacamole-client"
#-- sudo command --
sudo cp $file $webappdir
status="$(systemctl status ${tomcat}.service | grep active | cut -d":" -f2 | cut -b2-3)"
if [[ ${status} == "ac" ]]
then
systemctl restart ${tomcat}.service
elif [[ ${status} == "in" ]]
then
systemctl start ${tomcat}.service
fi
guacd="$(systemctl status guacd.service | grep active | cut -d":" -f2 | cut -b2-3)"
if [[ ${guacd} == "ac" ]]
then
systemctl restart guacd.service
elif [[ ${guacd} == "in" ]]
then
systemctl start guacd.service
fi
#--------------------------------------------------
echo "cleaning up"
rm $file
rm ${file}.sha256
cd /tmp
rm -r $dir
echo "Guacamole-client is now ready for configuration. Take a look at https://guacamole.apache.org/doc/1.4.0/gug/configuring-guacamole.html."
exit 0