2016-10-21 03:26:40 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-03-04 20:24:53 +01:00
|
|
|
# Check if user is root or sudo
|
|
|
|
if ! [ $(id -u) = 0 ]; then echo "Please run this script as sudo or root"; exit 1 ; fi
|
|
|
|
|
2018-03-12 22:54:36 +01:00
|
|
|
# Version number of Guacamole to install
|
2020-07-04 03:24:18 +02:00
|
|
|
GUACVERSION="1.2.0"
|
2017-02-11 15:47:49 +01:00
|
|
|
|
2018-03-12 22:44:55 +01:00
|
|
|
# Get script arguments for non-interactive mode
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
-m | --mysqlpwd )
|
|
|
|
shift
|
|
|
|
mysqlpwd="$1"
|
|
|
|
;;
|
|
|
|
-g | --guacpwd )
|
|
|
|
shift
|
|
|
|
guacpwd="$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2017-12-01 18:55:22 +01:00
|
|
|
done
|
2018-03-12 22:44:55 +01:00
|
|
|
|
|
|
|
# Get MySQL root password and Guacamole User password
|
|
|
|
if [ -n "$mysqlpwd" ] && [ -n "$guacpwd" ]; then
|
|
|
|
mysqlrootpassword=$mysqlpwd
|
|
|
|
guacdbuserpassword=$guacpwd
|
|
|
|
else
|
2020-03-04 20:24:53 +01:00
|
|
|
echo
|
2018-03-12 22:44:55 +01:00
|
|
|
while true
|
|
|
|
do
|
|
|
|
read -s -p "Enter a MySQL ROOT Password: " mysqlrootpassword
|
|
|
|
echo
|
|
|
|
read -s -p "Confirm MySQL ROOT Password: " password2
|
|
|
|
echo
|
|
|
|
[ "$mysqlrootpassword" = "$password2" ] && break
|
|
|
|
echo "Passwords don't match. Please try again."
|
|
|
|
echo
|
|
|
|
done
|
2017-12-01 18:55:22 +01:00
|
|
|
echo
|
2018-03-12 22:44:55 +01:00
|
|
|
while true
|
|
|
|
do
|
|
|
|
read -s -p "Enter a Guacamole User Database Password: " guacdbuserpassword
|
|
|
|
echo
|
|
|
|
read -s -p "Confirm Guacamole User Database Password: " password2
|
|
|
|
echo
|
|
|
|
[ "$guacdbuserpassword" = "$password2" ] && break
|
|
|
|
echo "Passwords don't match. Please try again."
|
|
|
|
echo
|
|
|
|
done
|
2017-12-01 18:55:22 +01:00
|
|
|
echo
|
2018-03-12 22:44:55 +01:00
|
|
|
fi
|
2016-10-21 03:26:40 +02:00
|
|
|
|
2020-03-04 20:24:53 +01:00
|
|
|
# Install Stuff
|
2018-03-12 22:44:55 +01:00
|
|
|
apt-get update
|
2018-04-01 17:00:47 +02:00
|
|
|
apt-get -y install docker-ce mysql-client wget
|
2018-03-12 22:44:55 +01:00
|
|
|
|
|
|
|
# Set SERVER to be the preferred download server from the Apache CDN
|
|
|
|
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"
|
2016-10-21 03:26:40 +02:00
|
|
|
|
2018-03-12 22:44:55 +01:00
|
|
|
# Download Guacamole authentication extensions
|
|
|
|
wget -O guacamole-auth-jdbc-${GUACVERSION}.tar.gz ${SERVER}/binary/guacamole-auth-jdbc-${GUACVERSION}.tar.gz
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to download guacamole-auth-jdbc-${GUACVERSION}.tar.gz"
|
|
|
|
echo "${SERVER}/binary/guacamole-auth-jdbc-${GUACVERSION}.tar.gz"
|
|
|
|
exit
|
|
|
|
fi
|
2017-07-24 03:42:16 +02:00
|
|
|
|
2018-03-12 22:44:55 +01:00
|
|
|
tar -xzf guacamole-auth-jdbc-${GUACVERSION}.tar.gz
|
2016-10-21 03:26:40 +02:00
|
|
|
|
|
|
|
# Start MySQL
|
2017-12-01 18:55:22 +01:00
|
|
|
docker run --restart=always --detach --name=mysql --env="MYSQL_ROOT_PASSWORD=$mysqlrootpassword" --publish 3306:3306 mysql
|
2016-10-21 03:26:40 +02:00
|
|
|
|
2017-10-13 17:52:34 +02:00
|
|
|
# Sleep to let MySQL load (there's probably a better way to do this)
|
|
|
|
echo "Waiting 30 seconds for MySQL to load"
|
|
|
|
sleep 30
|
2016-10-21 03:26:40 +02:00
|
|
|
|
2017-10-13 17:52:34 +02:00
|
|
|
# Create the Guacamole database and the user account
|
2017-02-11 15:47:49 +01:00
|
|
|
# SQL Code
|
|
|
|
SQLCODE="
|
2020-03-04 20:24:53 +01:00
|
|
|
create database guacamole_db;
|
|
|
|
create user 'guacamole_user'@'%' identified by '$guacdbuserpassword';
|
|
|
|
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'%';
|
2017-02-11 15:47:49 +01:00
|
|
|
flush privileges;"
|
|
|
|
|
|
|
|
# Execute SQL Code
|
2017-12-01 18:55:22 +01:00
|
|
|
echo $SQLCODE | mysql -h 127.0.0.1 -P 3306 -u root -p$mysqlrootpassword
|
2017-02-11 15:47:49 +01:00
|
|
|
|
2018-03-12 22:44:55 +01:00
|
|
|
cat guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/*.sql | mysql -u root -p$mysqlrootpassword -h 127.0.0.1 -P 3306 guacamole_db
|
2016-10-21 03:26:40 +02:00
|
|
|
|
2017-07-24 03:38:35 +02:00
|
|
|
docker run --restart=always --name guacd -d guacamole/guacd
|
2017-12-01 18:55:22 +01:00
|
|
|
docker run --restart=always --name guacamole --link mysql:mysql --link guacd:guacd -e MYSQL_HOSTNAME=127.0.0.1 -e MYSQL_DATABASE=guacamole_db -e MYSQL_USER=guacamole_user -e MYSQL_PASSWORD=$guacdbuserpassword --detach -p 8080:8080 guacamole/guacamole
|
2017-02-11 15:47:49 +01:00
|
|
|
|
2018-03-12 22:44:55 +01:00
|
|
|
rm -rf guacamole-auth-jdbc-${GUACVERSION}*
|