cd
apt-get -y install build-essential libcairo2-dev libpng-dev libtool-bin uuid-dev libossp-uuid-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev libvorbis-dev libwebp-dev
wget https://downloads.apache.org/guacamole/1.5.5/source/guacamole-server-1.5.5.tar.gz
tar -xzf guacamole-server-1.5.5.tar.gz
cd guacamole-server-1.5.5
CFLAGS=-Wno-error ./configure --with-systemd-dir=/etc/systemd/system/
make
make install
apt-get -y install tomcat9 tomcat9-admin tomcat9-common tomcat9-user

wget https://downloads.apache.org/guacamole/1.5.5/binary/guacamole-1.5.5.war
mv guacamole-1.5.5.war /var/lib/tomcat9/webapps/guacamole.war
apt-get -y install mariadb-server

mysql_secure_installation
mysql -u root -pazerty << FIN
CREATE DATABASE guacadb;
CREATE USER 'azerty'@'localhost' IDENTIFIED BY 'azerty';
GRANT SELECT,INSERT,UPDATE,DELETE ON guacadb.* TO 'azerty'@'localhost';
FIN
cd ..
wget https://downloads.apache.org/guacamole/1.5.5/binary/guacamole-auth-jdbc-1.5.5.tar.gz

tar -xzf guacamole-auth-jdbc-1.5.5.tar.gz
mkdir -p /etc/guacamole/{extensions,lib}
mv guacamole-auth-jdbc-1.5.5/mysql/guacamole-auth-jdbc-mysql-1.5.5.jar /etc/guacamole/extensions/

wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-8.0.33.tar.gz
tar -xzf mysql-connector-j-8.0.33.tar.gz
cp mysql-connector-j-8.0.33/mysql-connector-j-8.0.33.jar /etc/guacamole/lib/
cd guacamole-auth-jdbc-1.5.5/mysql/schema/
cat *.sql | mysql -u root -pazerty guacadb
cat > /etc/guacamole/guacamole.properties << FIN
mysql-hostname: 127.0.0.1
mysql-database: guacadb
mysql-port: 3306
mysql-username: azerty
mysql-password: azerty
FIN
cat >> /etc/guacamole/guacd.conf << FIN
[server]
bind_host = localhost
bind_port = 4822
FIN
systemctl restart tomcat9  guacd  mariadb
