Skip to content

Instantly share code, notes, and snippets.

@npatel007
Forked from martezr/Guacamole_Installer
Created October 4, 2015 18:14
Show Gist options
  • Save npatel007/cfa3db25b1a49446838b to your computer and use it in GitHub Desktop.
Save npatel007/cfa3db25b1a49446838b to your computer and use it in GitHub Desktop.
Guacamole HTML5 Gateway Installation Script
#!/bin/bash
#Guacamole 0.9.0 Installation Script
#Versioning Variables
guacamoleclientdownload = "http://sourceforge.net/projects/guacamole/files/current/binary/guacamole-0.9.0.war"
guacamoleserverdownload = "http://sourceforge.net/projects/guacamole/files/current/source/guacamole-server-0.9.0.tar.gz"
guacamoleservertar = "guacamole-server-0.9.0.tar.gz"
guacamoleserversource = "guacamole-server-0.9.0"
guacamoleclientwar = "guacamole-0.9.0.war"
#Guacamole Properties
guacdhostname = "localhost"
guacdport = "4822"
authprovider = "auth-provider: net.sourceforge.guacamole.net.auth.mysql.MySQLAuthenticationProvider"
mysqlhostname = "localhost"
mysqlport = "3306"
mysqldatabase = "guacamole"
mysqlusername = "greenrt"
mysqlpassword = "greenrt"
libdirectory = "/var/lib/guacamole/classpath"
#Guacamole MySQL Authenitcation Module Variables
guacamolemysqlmoduledownload = "http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-mysql-0.9.0.tar.gz"
guacamolemysqlmoduletar = "guacamole-auth-mysql-0.9.0.tar.gz"
guacamolemysqlmodule = "guacamole-auth-mysql-0.9.0"
#MySQL J-Connector Variables
mysqlconnectordownload = "http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.tar.gz"
mysqlconnectortar = "mysql-connector-java-5.1.30.tar.gz"
mysqlconnector = "mysql-connector-java-5.1.30"
mysqlconnectorjar = "mysql-connector-java-5.1.30-bin.jar"
#MySQL Variables
mysqlrootpassword = "greenrt"
guacamolemysqlconfigscript = "guacamolemysql.sql"
#SSL Ceritifcate Information
sslcountry = "US"
sslstate = "IL"
sslcity = "Chicago"
sslorganization = "GreenReedTechnology"
sslorgunit = "IT"
sslcommonname = "guacamole.localdomain.local"
sslemailaddress = "admin@localdomain.local"
sslcertfilename = "guacamole.crt"
sslkeyfilename = "guacamole.key"
#System Update
sudo apt-get update -y
#System Upgrade
sudo apt-get upgrade -y
#Install Tomcat 7
sudo apt-get install -y tomcat7
#Install packages
sudo apt-get install -y make libcairo2-dev libpango-1.0-0 libpango1.0-dev libssh2-1-dev libpng12-dev freerdp-x11 libssh2-1 libvncserver-dev libfreerdp-dev libvorbis-dev libssl1.0.0 gcc libssh-dev libpulse-dev tomcat7-admin tomcat7-docs
#Stop Tomcat 7
sudo service tomcat7 stop
#Download GUacamole Client
sudo wget http://sourceforge.net/projects/guacamole/files/current/binary/guacamole-0.9.0.war
#Download Guacamole Server
sudo wget http://sourceforge.net/projects/guacamole/files/current/source/guacamole-server-0.9.0.tar.gz
# Untar the guacamole server source files
tar -xzf guacamole-server-0.9.0.tar.gz
# Change directory to the source files
cd guacamole-server-0.9.0/
#
./configure --with-init-dir=/etc/init.d
#
sudo make
#
sudo make install
#
sudo update-rc.d guacd defaults
#
sudo ldconfig
#
sudo mkdir /etc/guacamole
#Download Guacamole properties file
sudo wget http://www.greenreedtech.com/guacamole/guacamole.properties
# Copy Guacamole properties file to /etc/guacamole/
sudo cp guacamole.properties /etc/guacamole/
#
sudo mkdir /usr/share/tomcat7/.guacamole
# Create a symbolic link of the properties file for Tomcat7
sudo ln -s /etc/guacamole/guacamole.properties /usr/share/tomcat7/.guacamole
# Move up a directory to copy the guacamole.war file
cd ..
# Copy the guacamole war file to the Tomcat 7 webapps directory
sudo cp guacamole-0.9.0.war /var/lib/tomcat7/webapps/guacamole.war
# Start the Guacamole (guacd) service
sudo service guacd start
# Restart Tomcat 7
sudo service tomcat7 restart
########################################
# MySQL Installation and configuration #
########################################
# Download Guacamole MySQL Authentication Module
sudo wget http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-mysql-0.9.0.tar.gz
# Untar the Guacamole MySQL Authentication Module
sudo tar -xzf guacamole-auth-mysql-0.9.0.tar.gz
# Create Guacamole classpath directory for MySQL Authentication files
sudo mkdir -p /var/lib/guacamole/classpath
# Copy Guacamole MySQL Authentication module files to the created directory
sudo cp guacamole-auth-mysql-0.9.0/lib/* /var/lib/guacamole/classpath/
# Download MySQL Connector-J
sudo wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.tar.gz
# Untar the MySQL Connector-J
sudo tar -xzf mysql-connector-java-5.1.30.tar.gz
# Copy the MySQL Connector-J jar file to the guacamole classpath diretory
sudo cp mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar /var/lib/guacamole/classpath/
# Provide mysql root password to automate installation
echo "mysql-server mysql-server/root_password password greenrt" | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password greenrt" | debconf-set-selections
# Install MySQL
sudo apt-get install -y mysql-server
# Secure MySQL
sudo mysql_secure_installation
# Download mysql script
sudo wget http://www.greenreedtech.com/guacamole/guacamolemysql.sql
# Create Guacamole database and user
sudo mysql -u root -p < guacamolemysql.sql
# Change directory to mysql-auth directory
cd guacamole-auth-mysql-0.9.0
# Run database scripts to create schema and users
sudo cat schema/*.sql | mysql -u root -p guacamole
##########################################
# Apache2 Installation and configuration #
##########################################
# Install Apache
sudo apt-get install -y apache2
# Enable SSL Module
sudo a2enmod ssl
# Restart Apache
sudo service apache2 restart
# Create directory to store server key and certificate
sudo mkdir /etc/apache2/ssl
# Create self-signed certificate
sudo openssl req -x509 -subj '/C=US/ST=Illinois/L=Chicago/O=IT/CN=guacamole.localdomain.local' -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt -extensions v3_ca
# Enable SSL
sudo a2ensite default-ssl
# Replace default ssl certificates in apache ssl config file
sudo sed -i 's\/etc/ssl/certs/ssl-cert-snakeoil.pem\/etc/apache2/ssl/apache.crt\' /etc/apache2/sites-enabled/default-ssl.conf
sudo sed -i 's\/etc/ssl/private/ssl-cert-snakeoil.key\/etc/apache2/ssl/apache.key\' /etc/apache2/sites-enabled/default-ssl.conf
# Reoload Apache
sudo service apache2 reload
################################################
# Apache2 Proxy Installation and Configuration #
################################################
# Configure Tomcat for AJP
sudo sed '98i <Connector port="8009" protocol="AJP/1.3" URIEncoding="UTF-8" redirectPort="8443" />' /etc/tomcat7/server.xml
# Install apache proxy module
sudo apt-get install -y libapache2-mod-proxy-html libxml2-dev
# Enable apache proxy modules
sudo a2enmod proxy proxy_http proxy_ajp rewrite
# Add proxy settings to apache config file
#<Proxy */>
# Order allow,deny
# Allow from all
#</Proxy>
#
# ProxyPass /guacamole ajp://localhost:8009/guacamole/ max=20 flushpackets=on
# ProxyPassReverse /guacamole ajp://localhost:8009/guacamole/" /etc/tomcat7/server.xml
# Restart apache service
sudo service apache2 restart
################################################
# Firewall Configuration #
################################################
# Enable firewall
sudo ufw enable
# Allow HTTPS access
sudo ufw allow https
#MySQL Guacamole Script
CREATE DATABASE guacamole;
CREATE USER 'guacamole'@'localhost' IDENTIFIED BY 'greenrt';
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole.* TO 'guacamole'@'localhost';
FLUSH PRIVILEGES;
quit
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port: 4822
# Auth provider class (authenticates user/pass combination, needed if using the provided login screen)
#auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider
#basic-user-mapping: /etc/guacamole/user-mapping.xml
# Auth provider class
auth-provider: net.sourceforge.guacamole.net.auth.mysql.MySQLAuthenticationProvider
# MySQL properties
mysql-hostname: localhost
mysql-port: 3306
mysql-database: guacamole
mysql-username: guacamole
mysql-password: greenrt
lib-directory: /var/lib/guacamole/classpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment