Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. VERSION="0.9.12"
  4. SERVER=$(curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq --raw-output '.preferred|rtrimstr("/")')
  5.  
  6. # Grab a password for MySQL Root
  7. read -s -p "Enter the password that will be used for MySQL Root: " mysqlrootpassword
  8. debconf-set-selections <<< "mysql-server mysql-server/root_password password $mysqlrootpassword"
  9. debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $mysqlrootpassword"
  10.  
  11. # Grab a password for Guacamole Database User Account
  12. read -s -p "Enter the password that will be used for the Guacamole database: " guacdbuserpassword
  13.  
  14. # Install Features
  15. apt-get update
  16. apt-get -y install build-essential libcairo2-dev libjpeg-turbo8-dev libpng12-dev libossp-uuid-dev libavcodec-dev libavutil-dev \
  17. libswscale-dev libfreerdp-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libpulse-dev libssl-dev \
  18. libvorbis-dev libwebp-dev mysql-server mysql-client mysql-common mysql-utilities tomcat9 freerdp ghostscript jq wget curl
  19.  
  20. # If Apt-Get fails to run completely the rest of this isn't going to work...
  21. if [ $? != 0 ]
  22. then
  23. echo "apt-get failed to install all required dependencies. Are you on Ubuntu 16.04 LTS?"
  24. exit
  25. fi
  26.  
  27. # Add GUACAMOLE_HOME to Tomcat9 ENV
  28. echo "" >> /etc/default/tomcat9
  29. echo "# GUACAMOLE EVN VARIABLE" >> /etc/default/tomcat9
  30. echo "GUACAMOLE_HOME=/etc/guacamole" >> /etc/default/tomcat9
  31.  
  32. # Download Guacample Files
  33. wget ${SERVER}/incubator/guacamole/${VERSION}-incubating/source/guacamole-server-${VERSION}-incubating.tar.gz
  34. wget ${SERVER}/incubator/guacamole/${VERSION}-incubating/binary/guacamole-${VERSION}-incubating.war
  35. wget ${SERVER}/incubator/guacamole/${VERSION}-incubating/binary/guacamole-auth-jdbc-${VERSION}-incubating.tar.gz
  36. wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.41.tar.gz
  37.  
  38. # Extract Guacamole Files
  39. tar -xzf guacamole-server-${VERSION}-incubating.tar.gz
  40. tar -xzf guacamole-auth-jdbc-${VERSION}-incubating.tar.gz
  41. tar -xzf mysql-connector-java-5.1.41.tar.gz
  42.  
  43. # MAKE DIRECTORIES
  44. mkdir /etc/guacamole
  45. mkdir /etc/guacamole/lib
  46. mkdir /etc/guacamole/extensions
  47.  
  48. # Install GUACD
  49. cd guacamole-server-${VERSION}-incubating
  50. ./configure --with-init-dir=/etc/init.d
  51. make
  52. make install
  53. ldconfig
  54. systemctl enable guacd
  55. cd ..
  56.  
  57. # Move files to correct locations
  58. mv guacamole-${VERSION}-incubating.war /etc/guacamole/guacamole.war
  59. ln -s /etc/guacamole/guacamole.war /var/lib/tomcat9/webapps/
  60. ln -s /usr/local/lib/freerdp/* /usr/lib/x86_64-linux-gnu/freerdp/.
  61. cp mysql-connector-java-5.1.41/mysql-connector-java-5.1.41-bin.jar /etc/guacamole/lib/
  62. cp guacamole-auth-jdbc-${VERSION}-incubating/mysql/guacamole-auth-jdbc-mysql-${VERSION}-incubating.jar /etc/guacamole/extensions/
  63.  
  64. # Configure guacamole.properties
  65. echo "mysql-hostname: localhost" >> /etc/guacamole/guacamole.properties
  66. echo "mysql-port: 3306" >> /etc/guacamole/guacamole.properties
  67. echo "mysql-database: guacamole_db" >> /etc/guacamole/guacamole.properties
  68. echo "mysql-username: guacamole_user" >> /etc/guacamole/guacamole.properties
  69. echo "mysql-password: $guacdbuserpassword" >> /etc/guacamole/guacamole.properties
  70. rm -rf /usr/share/tomcat9/.guacamole
  71. ln -s /etc/guacamole /usr/share/tomcat9/.guacamole
  72.  
  73. # restart tomcat
  74. service tomcat9 restart
  75.  
  76. # Create guacamole_db and grant guacamole_user permissions to it
  77.  
  78. # SQL Code
  79. SQLCODE="
  80. create database guacamole_db;
  81. create user 'guacamole_user'@'localhost' identified by \"$guacdbuserpassword\";
  82. GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'localhost';
  83. flush privileges;"
  84.  
  85. # Execute SQL Code
  86. echo $SQLCODE | mysql -u root -p$mysqlrootpassword
  87.  
  88. # Add Guacamole Schema to newly created database
  89. cat guacamole-auth-jdbc-${VERSION}-incubating/mysql/schema/*.sql | mysql -u root -p$mysqlrootpassword guacamole_db
  90.  
  91. # Cleanup
  92. rm -rf guacamole-*
  93. rm -rf mysql-connector-java-5.1.41*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement