0.9.14 fixes (#28)

* Replace VERSION with GUACVERSION
    #26 #25

* Make database name dynamic from the guacamole.properties file
    #27
This commit is contained in:
Chase Wright 2018-01-20 19:34:58 -05:00 committed by GitHub
parent c45f9a62c7
commit bcce82bbc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 47 deletions

View File

@ -79,52 +79,49 @@ libswscale-dev libfreerdp-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvnc
libvorbis-dev libwebp-dev mysql-server mysql-client mysql-common mysql-utilities ${TOMCAT} freerdp ghostscript wget dpkg-dev
# If apt fails to run completely the rest of this isn't going to work...
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "apt failed to install all required dependencies"
exit
fi
# Set SERVER to be the preferred download server from the Apache CDN
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${VERSION}"
# Quick Fix SERVER
VERSION=$GUACVERSION
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"
# Download Guacamole Server
wget -O guacamole-server-${VERSION}.tar.gz ${SERVER}/source/guacamole-server-${VERSION}.tar.gz
if [ ! -f ./guacamole-server-${VERSION}.tar.gz ]; then
echo "Failed to download guacamole-server-${VERSION}.tar.gz"
echo "${SERVER}/source/guacamole-server-${VERSION}.tar.gz"
wget -O guacamole-server-${GUACVERSION}.tar.gz ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
if [ $? -ne 0 ]; then
echo "Failed to download guacamole-server-${GUACVERSION}.tar.gz"
echo "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz"
exit
fi
# Download Guacamole Client
wget -O guacamole-${VERSION}.war ${SERVER}/binary/guacamole-${VERSION}.war
if [ ! -f ./guacamole-${VERSION}.war ]; then
echo "Failed to download guacamole-${VERSION}.war"
echo "${SERVER}/binary/guacamole-${VERSION}.war"
wget -O guacamole-${GUACVERSION}.war ${SERVER}/binary/guacamole-${GUACVERSION}.war
if [ $? -ne 0 ]; then
echo "Failed to download guacamole-${GUACVERSION}.war"
echo "${SERVER}/binary/guacamole-${GUACVERSION}.war"
exit
fi
# Download Guacamole authentication extensions
wget -O guacamole-auth-jdbc-${VERSION}.tar.gz ${SERVER}/binary/guacamole-auth-jdbc-${VERSION}.tar.gz
if [ ! -f ./guacamole-auth-jdbc-${VERSION}.tar.gz ]; then
echo "Failed to download guacamole-auth-jdbc-${VERSION}.tar.gz"
echo "${SERVER}/binary/guacamole-auth-jdbc-${VERSION}.tar.gz"
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
# Download MySQL Connector-J
wget -O mysql-connector-java-${MCJVERSION}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MCJVERSION}.tar.gz
if [ ! -f ./mysql-connector-java-${MCJVERSION}.tar.gz ]; then
if [ $? -ne 0 ]; then
echo "Failed to download mysql-connector-java-${MCJVERSION}.tar.gz"
echo "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MCJVERSION}.tar.gz"
exit
fi
# Extract Guacamole files
tar -xzf guacamole-server-${VERSION}.tar.gz
tar -xzf guacamole-auth-jdbc-${VERSION}.tar.gz
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
tar -xzf guacamole-auth-jdbc-${GUACVERSION}.tar.gz
tar -xzf mysql-connector-java-${MCJVERSION}.tar.gz
# Make directories
@ -132,7 +129,7 @@ mkdir -p /etc/guacamole/lib
mkdir -p /etc/guacamole/extensions
# Install guacd
cd guacamole-server-${VERSION}
cd guacamole-server-${GUACVERSION}
./configure --with-init-dir=/etc/init.d
make
make install
@ -144,11 +141,11 @@ cd ..
BUILD_FOLDER=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE)
# Move files to correct locations
mv guacamole-${VERSION}.war /etc/guacamole/guacamole.war
mv guacamole-${GUACVERSION}.war /etc/guacamole/guacamole.war
ln -s /etc/guacamole/guacamole.war /var/lib/${TOMCAT}/webapps/
ln -s /usr/local/lib/freerdp/guac*.so /usr/lib/${BUILD_FOLDER}/freerdp/
cp mysql-connector-java-${MCJVERSION}/mysql-connector-java-${MCJVERSION}-bin.jar /etc/guacamole/lib/
cp guacamole-auth-jdbc-${VERSION}/mysql/guacamole-auth-jdbc-mysql-${VERSION}.jar /etc/guacamole/extensions/
cp guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/
# Configure guacamole.properties
echo "mysql-hostname: localhost" >> /etc/guacamole/guacamole.properties
@ -173,7 +170,7 @@ flush privileges;"
echo $SQLCODE | mysql -u root -p$mysqlrootpassword
# Add Guacamole schema to newly created database
cat guacamole-auth-jdbc-${VERSION}/mysql/schema/*.sql | mysql -u root -p$mysqlrootpassword guacamole_db
cat guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/*.sql | mysql -u root -p$mysqlrootpassword guacamole_db
# Cleanup
rm -rf guacamole-*

View File

@ -1,5 +1,8 @@
#!/bin/bash
# Try to get database from /etc/guacamole/guacamole.properties
DATABASE=$(grep -oP 'mysql-database:\K.*' /etc/guacamole/guacamole.properties | awk '{print $1}')
# Get MySQL root password
echo
while true
@ -7,13 +10,13 @@ do
read -s -p "Enter MySQL ROOT Password: " mysqlrootpassword
export MYSQL_PWD=${mysqlrootpassword}
echo
mysql -u root guacamole_db -e"quit" && break
mysql -u root ${DATABASE} -e"quit" && break
echo
done
echo
# Version Numbers of Guacamole and MySQL Connector/J to download
VERSION="0.9.14"
GUACVERSION="0.9.14"
MCJVERSION="5.1.45"
# Get Tomcat Version
@ -23,46 +26,46 @@ TOMCAT=$(ls /etc/ | grep tomcat)
OLDVERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT}/webapps/guacamole/guacamole-common-js/modules/Version.js)
# Set SERVER to be the preferred download server from the Apache CDN
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${VERSION}"
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"
# Stop tomcat
service ${TOMCAT} stop
# Download Guacamole server
wget -O guacamole-server-${VERSION}.tar.gz ${SERVER}/source/guacamole-server-${VERSION}.tar.gz
if [ ! -f ./guacamole-server-${VERSION}.tar.gz ]; then
echo "Failed to download guacamole-server-${VERSION}.tar.gz"
echo "${SERVER}/source/guacamole-server-${VERSION}.tar.gz"
wget -O guacamole-server-${GUACVERSION}.tar.gz ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
if [ $? -ne 0 ]; then
echo "Failed to download guacamole-server-${GUACVERSION}.tar.gz"
echo "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz"
exit
fi
# Download Guacamole client
wget -O guacamole-${VERSION}.war ${SERVER}/binary/guacamole-${VERSION}.war
if [ ! -f ./guacamole-${VERSION}.war ]; then
echo "Failed to download guacamole-${VERSION}.war"
echo "${SERVER}/binary/guacamole-${VERSION}.war"
wget -O guacamole-${GUACVERSION}.war ${SERVER}/binary/guacamole-${GUACVERSION}.war
if [ $? -ne 0 ]; then
echo "Failed to download guacamole-${GUACVERSION}.war"
echo "${SERVER}/binary/guacamole-${GUACVERSION}.war"
exit
fi
# Download SQL components
wget -O guacamole-auth-jdbc-${VERSION}.tar.gz ${SERVER}/binary/guacamole-auth-jdbc-${VERSION}.tar.gz
if [ ! -f ./guacamole-auth-jdbc-${VERSION}.tar.gz ]; then
echo "Failed to download guacamole-auth-jdbc-${VERSION}.tar.gz"
echo "${SERVER}/binary/guacamole-auth-jdbc-${VERSION}.tar.gz"
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
# Download the MySQL Connector/J
wget -O mysql-connector-java-${MCJVERSION}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MCJVERSION}.tar.gz
if [ ! -f ./mysql-connector-java-${MCJVERSION}.tar.gz ]; then
if [ $? -ne 0 ]; then
echo "Failed to download mysql-connector-java-${MCJVERSION}.tar.gz"
echo "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MCJVERSION}.tar.gz"
exit
fi
# Upgrade Guacamole Server
tar -xzf guacamole-server-${VERSION}.tar.gz
cd guacamole-server-${VERSION}
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
cd guacamole-server-${GUACVERSION}
./configure --with-init-dir=/etc/init.d
make
make install
@ -71,17 +74,17 @@ systemctl enable guacd
cd ..
# Upgrade Guacamole Client
mv guacamole-${VERSION}.war /etc/guacamole/guacamole.war
mv guacamole-${GUACVERSION}.war /etc/guacamole/guacamole.war
# Upgrade SQL Components
tar -xzf guacamole-auth-jdbc-${VERSION}.tar.gz
cp guacamole-auth-jdbc-${VERSION}/mysql/guacamole-auth-jdbc-mysql-${VERSION}.jar /etc/guacamole/extensions/
tar -xzf guacamole-auth-jdbc-${GUACVERSION}.tar.gz
cp guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/
tar -xzf mysql-connector-java-${MCJVERSION}.tar.gz
cp mysql-connector-java-${MCJVERSION}/mysql-connector-java-${MCJVERSION}-bin.jar /etc/guacamole/lib/
rm -rf mysql-connector-java-${MCJVERSION}*
# Get list of SQL Upgrade Files
UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${VERSION}/mysql/schema/upgrade/ | sort -V))
UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/upgrade/ | sort -V))
# Compare SQL Upgrage Files against old version, apply upgrades as needed
for FILE in ${UPGRADEFILES[@]}
@ -89,7 +92,7 @@ do
FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)')
if [[ $(echo -e "${FILEVERSION}\n${OLDVERSION}" | sort -V | head -n1) == ${OLDVERSION} && ${FILEVERSION} != ${OLDVERSION} ]]
then
mysql -u root guacamole_db < guacamole-auth-jdbc-${VERSION}/mysql/schema/upgrade/${FILE}
mysql -u root ${DATABASE} < guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/upgrade/${FILE}
fi
done