From fbb5da4c309488995fafc94ba93e8b736853486d Mon Sep 17 00:00:00 2001
From: Itiligent <94789708+itiligent@users.noreply.github.com>
Date: Sun, 10 Sep 2023 16:44:33 +1000
Subject: [PATCH] shfmt clean up
---
2-install-guacamole.sh | 810 +++++++++---------
3-install-nginx.sh | 40 +-
4a-install-tls-self-signed-nginx.sh | 54 +-
4b-install-tls-letsencrypt-nginx.sh | 46 +-
.../install-mysql-backend-only.sh | 247 +++---
.../upgrade-mysql-backend-only.sh | 61 +-
guac-management/backup-guac.sh | 28 +-
guac-management/refresh-tls-self-signed.sh | 44 +-
guac-management/upgrade-guac.sh | 308 ++++---
guac-optional-features/add-auth-duo.sh | 6 +-
guac-optional-features/add-auth-ldap.sh | 18 +-
guac-optional-features/add-auth-totp.sh | 6 +-
guac-optional-features/add-fail2ban.sh | 226 ++---
guac-optional-features/add-smtp-relay-o365.sh | 26 +-
guac-optional-features/add-tls-guac-daemon.sh | 7 +-
.../add-xtra-histrecstor.sh | 20 +-
.../add-xtra-quickconnect.sh | 6 +-
17 files changed, 972 insertions(+), 981 deletions(-)
diff --git a/2-install-guacamole.sh b/2-install-guacamole.sh
index 8892c38..b2bec3c 100644
--- a/2-install-guacamole.sh
+++ b/2-install-guacamole.sh
@@ -17,188 +17,188 @@ NC='\033[0m' #No Colour
# Choose a specific MySQL version e.g. 11.1.2 See https://mariadb.org/mariadb/all-releases/ for available versions.
if [ -z "${MYSQL_VERSION}" ]; then
- # Use Linux distro default version.
- MYSQLPKG="default-mysql-server default-mysql-client mysql-common"
- DB_CMD="mysql" # mysql command is depricated
- else
- # Use official mariadb.org repo
- MYSQLPKG="mariadb-server mariadb-client mariadb-common"
- DB_CMD="mariadb" # mysql command is depricated on newer versions
+ # Use Linux distro default version.
+ MYSQLPKG="default-mysql-server default-mysql-client mysql-common"
+ DB_CMD="mysql" # mysql command is depricated
+else
+ # Use official mariadb.org repo
+ MYSQLPKG="mariadb-server mariadb-client mariadb-common"
+ DB_CMD="mariadb" # mysql command is depricated on newer versions
fi
# Pre-seed MySQL root password values for Linux Distro default packages only
if [ "${INSTALL_MYSQL}" = true ] && [ -z "${MYSQL_VERSION}" ]; then
- debconf-set-selections <<<"mysql-server mysql-server/root_password password ${MYSQL_ROOT_PWD}"
- debconf-set-selections <<<"mysql-server mysql-server/root_password_again password ${MYSQL_ROOT_PWD}"
+ debconf-set-selections <<<"mysql-server mysql-server/root_password password ${MYSQL_ROOT_PWD}"
+ debconf-set-selections <<<"mysql-server mysql-server/root_password_again password ${MYSQL_ROOT_PWD}"
fi
# Update everything but don't do the annoying prompts during apt installs
echo -e "${GREY}Updating base Linux OS..."
- export DEBIAN_FRONTEND=noninteractive
- apt-get update -qq &>>${INSTALL_LOG}
- apt-get upgrade -qq -y &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+export DEBIAN_FRONTEND=noninteractive
+apt-get update -qq &>>${INSTALL_LOG}
+apt-get upgrade -qq -y &>>${INSTALL_LOG}
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Install Guacamole build dependencies.
if [ -n "${MYSQL_VERSION}" ]; then
- echo -e "${GREY}Adding the official MariaDB repository and installing version ${MYSQL_VERSION}..."
- # Add the Official MariaDB repo.
- apt-get -qq -y install curl gnupg2 &>>${INSTALL_LOG}
- curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup &>>${INSTALL_LOG}
- bash mariadb_repo_setup --mariadb-server-version=$MYSQL_VERSION &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Adding the official MariaDB repository and installing version ${MYSQL_VERSION}..."
+ # Add the Official MariaDB repo.
+ apt-get -qq -y install curl gnupg2 &>>${INSTALL_LOG}
+ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup &>>${INSTALL_LOG}
+ bash mariadb_repo_setup --mariadb-server-version=$MYSQL_VERSION &>>${INSTALL_LOG}
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
echo -e "${GREY}Installing dependencies required for building Guacamole, this might take a few minutes..."
apt-get -qq -y install ${MYSQLPKG} ${TOMCAT_VERSION} ${JPEGTURBO} ${LIBPNG} ufw pwgen wget expect \
- build-essential libcairo2-dev libtool-bin 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 ghostscript &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ build-essential libcairo2-dev libtool-bin 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 ghostscript &>>${INSTALL_LOG}
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Install Postfix with default settings for smtp email relay
echo -e "${GREY}Installing Postfix MTA for backup email notifications and alerts, see separate SMTP relay configuration script..."
- DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- systemctl restart postfix
- echo -e "${LGREEN}OK${GREY}"
- echo
+DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y &>>${INSTALL_LOG}
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ systemctl restart postfix
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Download Guacamole Server
echo -e "${GREY}Downloading Guacamole source files..."
- wget -q --show-progress -O guacamole-server-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-server-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
- exit 1
- else
- tar -xzf guacamole-server-${GUAC_VERSION}.tar.gz
- echo -e "${LGREEN}Downloaded guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
+wget -q --show-progress -O guacamole-server-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-server-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
+ exit 1
+else
+ tar -xzf guacamole-server-${GUAC_VERSION}.tar.gz
+ echo -e "${LGREEN}Downloaded guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
fi
# Download Guacamole Client
wget -q --show-progress -O guacamole-${GUAC_VERSION}.war ${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-${GUAC_VERSION}.war" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war${GREY}"
- exit 1
- else
- echo -e "${LGREEN}Downloaded guacamole-${GUAC_VERSION}.war (Guacamole client)${GREY}"
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-${GUAC_VERSION}.war" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war${GREY}"
+ exit 1
+else
+ echo -e "${LGREEN}Downloaded guacamole-${GUAC_VERSION}.war (Guacamole client)${GREY}"
fi
# Download MySQL connector/j
wget -q --show-progress -O mysql-connector-j-${MYSQLJCON}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${MYSQLJCON}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download mysql-connector-j-${MYSQLJCON}.tar.gz" 1>&2
- echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${MYSQLJCON}}.tar.gz${GREY}"
- exit 1
- else
- tar -xzf mysql-connector-j-${MYSQLJCON}.tar.gz
- echo -e "${LGREEN}Downloaded mysql-connector-j-${MYSQLJCON}.tar.gz${GREY}"
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download mysql-connector-j-${MYSQLJCON}.tar.gz" 1>&2
+ echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${MYSQLJCON}}.tar.gz${GREY}"
+ exit 1
+else
+ tar -xzf mysql-connector-j-${MYSQLJCON}.tar.gz
+ echo -e "${LGREEN}Downloaded mysql-connector-j-${MYSQLJCON}.tar.gz${GREY}"
fi
# Download Guacamole authentication extensions
wget -q --show-progress -O guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
- echo -e "${LGREEN}Downloaded guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz${GREY}"
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz"
+ exit 1
+else
+ tar -xzf guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
+ echo -e "${LGREEN}Downloaded guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz${GREY}"
fi
# Download TOTP extension
if [ "${INSTALL_TOTP}" = true ]; then
- wget -q --show-progress -O guacamole-auth-totp-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-totp-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-auth-totp-${GUAC_VERSION}.tar.gz
- rm -f add-auth-totp.sh
- echo -e "${LGREEN}Downloaded guacamole-auth-totp-${GUAC_VERSION}.tar.gz${GREY}"
- fi
+ wget -q --show-progress -O guacamole-auth-totp-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-totp-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz"
+ exit 1
+ else
+ tar -xzf guacamole-auth-totp-${GUAC_VERSION}.tar.gz
+ rm -f add-auth-totp.sh
+ echo -e "${LGREEN}Downloaded guacamole-auth-totp-${GUAC_VERSION}.tar.gz${GREY}"
+ fi
fi
# Download DUO extension
if [ "${INSTALL_DUO}" = true ]; then
- wget -q --show-progress -O guacamole-auth-duo-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-duo-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-auth-duo-${GUAC_VERSION}.tar.gz
- rm -f add-auth-duo.sh
- echo -e "${LGREEN}Downloaded guacamole-auth-duo-${GUAC_VERSION}.tar.gz${GREY}"
- fi
+ wget -q --show-progress -O guacamole-auth-duo-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-duo-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz"
+ exit 1
+ else
+ tar -xzf guacamole-auth-duo-${GUAC_VERSION}.tar.gz
+ rm -f add-auth-duo.sh
+ echo -e "${LGREEN}Downloaded guacamole-auth-duo-${GUAC_VERSION}.tar.gz${GREY}"
+ fi
fi
# Download LDAP extension
if [ "${INSTALL_LDAP}" = true ]; then
- wget -q --show-progress -O guacamole-auth-ldap-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-auth-ldap-${GUAC_VERSION}.tar.gz
- rm -f add-auth-ldap.sh
- echo -e "${LGREEN}Downloaded guacamole-auth-ldap-${GUAC_VERSION}.tar.gz${GREY}"
- fi
+ wget -q --show-progress -O guacamole-auth-ldap-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz"
+ exit 1
+ else
+ tar -xzf guacamole-auth-ldap-${GUAC_VERSION}.tar.gz
+ rm -f add-auth-ldap.sh
+ echo -e "${LGREEN}Downloaded guacamole-auth-ldap-${GUAC_VERSION}.tar.gz${GREY}"
+ fi
fi
# Download Guacamole quick-connect extension
if [ "${INSTALL_QCONNECT}" = true ]; then
- wget -q --show-progress -O guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz
- rm -f add-xtra-quickconnect.sh
- echo -e "${LGREEN}Downloaded guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz${GREY}"
- fi
+ wget -q --show-progress -O guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz"
+ exit 1
+ else
+ tar -xzf guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz
+ rm -f add-xtra-quickconnect.sh
+ echo -e "${LGREEN}Downloaded guacamole-auth-quickconnect-${GUAC_VERSION}.tar.gz${GREY}"
+ fi
fi
# Download Guacamole history recording storage extension
if [ "${INSTALL_HISTREC}" = true ]; then
- wget -q --show-progress -O guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz
+ wget -q --show-progress -O guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz"
- exit 1
- else
- tar -xzf guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz
- rm -f add-xtra-histrecstor.sh
- echo -e "${LGREEN}Downloaded guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz${GREY}"
- fi
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz"
+ exit 1
+ else
+ tar -xzf guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz
+ rm -f add-xtra-histrecstor.sh
+ echo -e "${LGREEN}Downloaded guacamole-history-recording-storage-${GUAC_VERSION}.tar.gz${GREY}"
+ fi
fi
echo -e "Source download complete.${GREY}"
@@ -235,36 +235,36 @@ export CFLAGS="-Wno-error"
# Configure Guacamole Server source
./configure --with-systemd-dir=/etc/systemd/system &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo "Failed to configure guacamole-server"
- echo "Trying again with --enable-allow-freerdp-snapshots"
- ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots
- if [ $? -ne 0 ]; then
- echo "Failed to configure guacamole-server - again"
- exit
- fi
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo "Failed to configure guacamole-server"
+ echo "Trying again with --enable-allow-freerdp-snapshots"
+ ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots
+ if [ $? -ne 0 ]; then
+ echo "Failed to configure guacamole-server - again"
+ exit
+ fi
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
echo -e "${GREY}Running make and building the Guacamole-Server application..."
make &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
echo -e "${GREY}Installing Guacamole-Server..."
make install &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Update the shared library cache
@@ -273,39 +273,39 @@ ldconfig
# Move Guacamole client and authentication extensions to their correct install locations
cd ..
echo -e "${GREY}Moving guacamole-${GUAC_VERSION}.war (/etc/guacamole/extensions/)..."
- mv -f guacamole-${GUAC_VERSION}.war /etc/guacamole/guacamole.war
- chmod 664 /etc/guacamole/guacamole.war
- # Create a symbolic link for Tomcat
- ln -sf /etc/guacamole/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/ &>>${INSTALL_LOG}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+mv -f guacamole-${GUAC_VERSION}.war /etc/guacamole/guacamole.war
+chmod 664 /etc/guacamole/guacamole.war
+# Create a symbolic link for Tomcat
+ln -sf /etc/guacamole/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/ &>>${INSTALL_LOG}
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
echo -e "${GREY}Moving guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-auth-jdbc-${GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+mv -f guacamole-auth-jdbc-${GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+chmod 664 /etc/guacamole/extensions/guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Move MySQL connector/j files
echo -e "${GREY}Moving mysql-connector-j-${MYSQLJCON}.jar (/etc/guacamole/lib/mysql-connector-java.jar)..."
- mv -f mysql-connector-j-${MYSQLJCON}/mysql-connector-j-${MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
- chmod 664 /etc/guacamole/lib/mysql-connector-java.jar
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+mv -f mysql-connector-j-${MYSQLJCON}/mysql-connector-j-${MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
+chmod 664 /etc/guacamole/lib/mysql-connector-java.jar
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Configure guacamole.properties file
@@ -319,117 +319,117 @@ echo "mysql-password: ${GUAC_PWD}" >>/etc/guacamole/guacamole.properties
# Move TOTP files
if [ "${INSTALL_TOTP}" = true ]; then
- echo -e "${GREY}Moving guacamole-auth-totp-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-auth-totp-${GUAC_VERSION}/guacamole-auth-totp-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-totp-${GUAC_VERSION}.jar
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Moving guacamole-auth-totp-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
+ mv -f guacamole-auth-totp-${GUAC_VERSION}/guacamole-auth-totp-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-totp-${GUAC_VERSION}.jar
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Move Duo files
if [ "${INSTALL_DUO}" = true ]; then
- echo -e "${GREY}Moving guacamole-auth-duo-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-auth-duo-${GUAC_VERSION}/guacamole-auth-duo-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-duo-${GUAC_VERSION}.jar
- echo "#duo-api-hostname: " >>/etc/guacamole/guacamole.properties
- echo "#duo-integration-key: " >>/etc/guacamole/guacamole.properties
- echo "#duo-secret-key: " >>/etc/guacamole/guacamole.properties
- echo "#duo-application-key: " >>/etc/guacamole/guacamole.properties
- echo -e "Duo auth is installed, it will need to be configured via guacamole.properties"
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Moving guacamole-auth-duo-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
+ mv -f guacamole-auth-duo-${GUAC_VERSION}/guacamole-auth-duo-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-duo-${GUAC_VERSION}.jar
+ echo "#duo-api-hostname: " >>/etc/guacamole/guacamole.properties
+ echo "#duo-integration-key: " >>/etc/guacamole/guacamole.properties
+ echo "#duo-secret-key: " >>/etc/guacamole/guacamole.properties
+ echo "#duo-application-key: " >>/etc/guacamole/guacamole.properties
+ echo -e "Duo auth is installed, it will need to be configured via guacamole.properties"
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Move LDAP files
if [ "${INSTALL_LDAP}" = true ]; then
- echo -e "${GREY}Moving guacamole-auth-ldap-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-auth-ldap-${GUAC_VERSION}/guacamole-auth-ldap-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-ldap-${GUAC_VERSION}.jar
- echo "#If you have issues with LDAP, check the formatting is exactly as below or you will despair!" >>/etc/guacamole/guacamole.properties
- echo "#Be extra careful with spaces at line ends or with windows line feeds." >>/etc/guacamole/guacamole.properties
- echo "#ldap-hostname: dc1.yourdomain.com dc2.yourdomain.com" >>/etc/guacamole/guacamole.properties
- echo "#ldap-port: 389" >>/etc/guacamole/guacamole.properties
- echo "#ldap-username-attribute: sAMAccountName" >>/etc/guacamole/guacamole.properties
- echo "#ldap-encryption-method: none" >>/etc/guacamole/guacamole.properties
- echo "#ldap-search-bind-dn: ad-account@yourdomain.com" >>/etc/guacamole/guacamole.properties
- echo "#ldap-search-bind-password: ad-account-password" >>/etc/guacamole/guacamole.properties
- echo "#ldap-config-base-dn: dc=domain,dc=com" >>/etc/guacamole/guacamole.properties
- echo "#ldap-user-base-dn: OU=SomeOU,DC=domain,DC=com" >>/etc/guacamole/guacamole.properties
- echo "#ldap-user-search-filter:(objectClass=user)(!(objectCategory=computer))" >>/etc/guacamole/guacamole.properties
- echo "#ldap-max-search-results:200" >>/etc/guacamole/guacamole.properties
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Moving guacamole-auth-ldap-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
+ mv -f guacamole-auth-ldap-${GUAC_VERSION}/guacamole-auth-ldap-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-ldap-${GUAC_VERSION}.jar
+ echo "#If you have issues with LDAP, check the formatting is exactly as below or you will despair!" >>/etc/guacamole/guacamole.properties
+ echo "#Be extra careful with spaces at line ends or with windows line feeds." >>/etc/guacamole/guacamole.properties
+ echo "#ldap-hostname: dc1.yourdomain.com dc2.yourdomain.com" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-port: 389" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-username-attribute: sAMAccountName" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-encryption-method: none" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-search-bind-dn: ad-account@yourdomain.com" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-search-bind-password: ad-account-password" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-config-base-dn: dc=domain,dc=com" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-user-base-dn: OU=SomeOU,DC=domain,DC=com" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-user-search-filter:(objectClass=user)(!(objectCategory=computer))" >>/etc/guacamole/guacamole.properties
+ echo "#ldap-max-search-results:200" >>/etc/guacamole/guacamole.properties
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Move quick-connect extension files
if [ "${INSTALL_QCONNECT}" = true ]; then
- echo -e "${GREY}Moving guacamole-auth-quickconnect-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-auth-quickconnect-${GUAC_VERSION}/guacamole-auth-quickconnect-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-quickconnect-${GUAC_VERSION}.jar
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Moving guacamole-auth-quickconnect-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
+ mv -f guacamole-auth-quickconnect-${GUAC_VERSION}/guacamole-auth-quickconnect-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-quickconnect-${GUAC_VERSION}.jar
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Move history recording storage extension files
if [ "${INSTALL_HISTREC}" = true ]; then
- echo -e "${GREY}Moving guacamole-history-recording-storage-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
- mv -f guacamole-history-recording-storage-${GUAC_VERSION}/guacamole-history-recording-storage-${GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-history-recording-storage-${GUAC_VERSION}.jar
- #Setup the default recording path
- mkdir -p ${HISTREC_PATH}
- chown daemon:tomcat ${HISTREC_PATH}
- chmod 2750 ${HISTREC_PATH}
- echo "recording-search-path: ${HISTREC_PATH}" >>/etc/guacamole/guacamole.properties
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Moving guacamole-history-recording-storage-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..."
+ mv -f guacamole-history-recording-storage-${GUAC_VERSION}/guacamole-history-recording-storage-${GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-history-recording-storage-${GUAC_VERSION}.jar
+ #Setup the default recording path
+ mkdir -p ${HISTREC_PATH}
+ chown daemon:tomcat ${HISTREC_PATH}
+ chmod 2750 ${HISTREC_PATH}
+ echo "recording-search-path: ${HISTREC_PATH}" >>/etc/guacamole/guacamole.properties
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Apply a branded interface and dark theme. You may delete this file and restart guacd & tomcat for the default console
echo -e "${GREY}Setting the Guacamole console to a (customisable) dark mode themed template..."
- mv branding.jar /etc/guacamole/extensions
- chmod 664 /etc/guacamole/extensions/branding.jar
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+mv branding.jar /etc/guacamole/extensions
+chmod 664 /etc/guacamole/extensions/branding.jar
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Restart Tomcat
echo -e "${GREY}Restarting Tomcat service & enable at boot..."
systemctl restart ${TOMCAT_VERSION}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Set Tomcat to start at boot
@@ -437,110 +437,110 @@ systemctl enable ${TOMCAT_VERSION}
echo
if [ "${INSTALL_MYSQL}" = true ]; then
-# Set MySQL password
-export MYSQL_PWD=${MYSQL_ROOT_PWD}
+ # Set MySQL password
+ export MYSQL_PWD=${MYSQL_ROOT_PWD}
-# Set the root password without a reliance on debconf.
-echo -e "${GREY}Setting MySQL root password..."
-SQLCODE="
+ # Set the root password without a reliance on debconf.
+ echo -e "${GREY}Setting MySQL root password..."
+ SQLCODE="
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PWD';"
-echo ${SQLCODE} | $DB_CMD -u root
-if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
-fi
+ echo ${SQLCODE} | $DB_CMD -u root
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
-# Find the location of the MySQL or MariaDB config files. (Add to this list for more potential candidates.)
-for x in /etc/mysql/mariadb.conf.d/50-server.cnf \
- /etc/mysql/mysql.conf.d/mysqld.cnf \
- /etc/mysql/my.cnf; do
- # Check inside each candidate to see if a [mysqld] or [mariadbd] section exists, assign $x the correct filename.
- if [ -e "${x}" ]; then
- if grep -qE '^\[(mysqld|mariadbd)\]$' "${x}"; then
- mysqlconfig="${x}"
- # Reduce any duplicated section names, then sanitise the [ ] special characters for sed below)
- config_section=$(grep -m 1 -E '^\[(mysqld|mariadbd)\]$' "${x}" | sed 's/\[\(.*\)\]/\1/')
- break
- fi
- fi
-done
+ # Find the location of the MySQL or MariaDB config files. (Add to this list for more potential candidates.)
+ for x in /etc/mysql/mariadb.conf.d/50-server.cnf \
+ /etc/mysql/mysql.conf.d/mysqld.cnf \
+ /etc/mysql/my.cnf; do
+ # Check inside each candidate to see if a [mysqld] or [mariadbd] section exists, assign $x the correct filename.
+ if [ -e "${x}" ]; then
+ if grep -qE '^\[(mysqld|mariadbd)\]$' "${x}"; then
+ mysqlconfig="${x}"
+ # Reduce any duplicated section names, then sanitise the [ ] special characters for sed below)
+ config_section=$(grep -m 1 -E '^\[(mysqld|mariadbd)\]$' "${x}" | sed 's/\[\(.*\)\]/\1/')
+ break
+ fi
+ fi
+ done
-# Set the MySQL Timezone
-if [ -z "${mysqlconfig}" ]; then
- echo -e "${GREY}Couldn't detect MySQL config file - you will need to manually configure database timezone settings"
-else
- # Is there already a timzeone value configured?
- if grep -q "^default_time_zone[[:space:]]=" "${mysqlconfig}"; then
- echo -e "MySQL database timezone defined in ${mysqlconfig}"
- else
- timezone=${DB_TZ}
- if [ -z "${DB_TZ}" ]; then
- echo -e "Couldn't find system timezone, using UTC$"
- timezone="UTC"
- fi
- echo -e "Setting MySQL database timezone as ${timezone}${GREY}"
- mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | ${DB_CMD} -u root -D mysql -p${MYSQL_ROOT_PWD}
- # Add the timzone value to the sanitsed server file section name.
- sed -i -e "/^\[${config_section}\]/a default_time_zone = ${timezone}" "${mysqlconfig}"
- fi
- fi
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
-fi
+ # Set the MySQL Timezone
+ if [ -z "${mysqlconfig}" ]; then
+ echo -e "${GREY}Couldn't detect MySQL config file - you will need to manually configure database timezone settings"
+ else
+ # Is there already a timzeone value configured?
+ if grep -q "^default_time_zone[[:space:]]=" "${mysqlconfig}"; then
+ echo -e "MySQL database timezone defined in ${mysqlconfig}"
+ else
+ timezone=${DB_TZ}
+ if [ -z "${DB_TZ}" ]; then
+ echo -e "Couldn't find system timezone, using UTC$"
+ timezone="UTC"
+ fi
+ echo -e "Setting MySQL database timezone as ${timezone}${GREY}"
+ mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | ${DB_CMD} -u root -D mysql -p${MYSQL_ROOT_PWD}
+ # Add the timzone value to the sanitsed server file section name.
+ sed -i -e "/^\[${config_section}\]/a default_time_zone = ${timezone}" "${mysqlconfig}"
+ fi
+ fi
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
-# This should stay as localhost in most local MySQL install situations. This setting determine from WHERE the new ${GUAC_USER}
-# will be able to login to the database (either specific remote IPs or localhost only.)
-# However this setting can be quick and hacky way to build a backend guacamole database server for use behind another guac application server
-# (albeit with the full application suite installed). To do this, set GUAC_USERHost="%" for login access from all IPs, or e.g. 192.168.1.% for an IP range.
-# You will also need to set the MySQL binding away from the default 127.0.0.1 to 0.0.0.0 or a specific external facing network interface to allow remote login.
-if [ "${MYSQL_HOST}" != "localhost" ]; then
- GUAC_USERHost="%"
- echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from any host, you may wish to limit this to specific IPs.${GREY}"
- else
- GUAC_USERHost="localhost"
-fi
+ # This should stay as localhost in most local MySQL install situations. This setting determine from WHERE the new ${GUAC_USER}
+ # will be able to login to the database (either specific remote IPs or localhost only.)
+ # However this setting can be quick and hacky way to build a backend guacamole database server for use behind another guac application server
+ # (albeit with the full application suite installed). To do this, set GUAC_USERHost="%" for login access from all IPs, or e.g. 192.168.1.% for an IP range.
+ # You will also need to set the MySQL binding away from the default 127.0.0.1 to 0.0.0.0 or a specific external facing network interface to allow remote login.
+ if [ "${MYSQL_HOST}" != "localhost" ]; then
+ GUAC_USERHost="%"
+ echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from any host, you may wish to limit this to specific IPs.${GREY}"
+ else
+ GUAC_USERHost="localhost"
+ fi
-# Execute SQL code to create the Guacamole database
-echo -e "${GREY}Creating the Guacamole database..."
-SQLCODE="
+ # Execute SQL code to create the Guacamole database
+ echo -e "${GREY}Creating the Guacamole database..."
+ SQLCODE="
DROP DATABASE IF EXISTS ${GUAC_DB};
CREATE DATABASE IF NOT EXISTS ${GUAC_DB};
CREATE USER IF NOT EXISTS '${GUAC_USER}'@'${GUAC_USERHost}' IDENTIFIED BY \"${GUAC_PWD}\";
GRANT SELECT,INSERT,UPDATE,DELETE ON ${GUAC_DB}.* TO '${GUAC_USER}'@'${GUAC_USERHost}';
FLUSH PRIVILEGES;"
-echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT}
-if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
-fi
+ echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT}
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
-# Add Guacamole schema to newly created database
-echo -e "${GREY}Adding database tables..."
-cat guacamole-auth-jdbc-${GUAC_VERSION}/mysql/schema/*.sql | $DB_CMD -u root -D ${GUAC_DB} -p${MYSQL_ROOT_PWD}
-if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
-fi
+ # Add Guacamole schema to newly created database
+ echo -e "${GREY}Adding database tables..."
+ cat guacamole-auth-jdbc-${GUAC_VERSION}/mysql/schema/*.sql | $DB_CMD -u root -D ${GUAC_DB} -p${MYSQL_ROOT_PWD}
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Apply Secure MySQL installation settings
if [ "${SECURE_MYSQL}" = true ] && [ "${INSTALL_MYSQL}" = true ]; then
- echo -e "${GREY}Applying mysql_secure_installation settings...${DGREY}"
- SECURE_MYSQL=$(expect -c "
+ echo -e "${GREY}Applying mysql_secure_installation settings...${DGREY}"
+ SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
@@ -559,44 +559,44 @@ expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
")
- echo "$SECURE_MYSQL"
-if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo "$SECURE_MYSQL"
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Restart MySQL service
if [ "${INSTALL_MYSQL}" = true ]; then
- echo -e "${GREY}Restarting MySQL service & enable at boot..."
- # Set MySQl to start at boot
- systemctl enable mysql
- systemctl restart mysql
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Restarting MySQL service & enable at boot..."
+ # Set MySQl to start at boot
+ systemctl enable mysql
+ systemctl restart mysql
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Create guacd.conf and locahost IP binding.
echo -e "${GREY}Binding guacd to 127.0.0.1 port 4822..."
cat >/etc/guacamole/guacd.conf <<-"EOF"
-[server]
-bind_host = 127.0.0.1
-bind_port = 4822
+ [server]
+ bind_host = 127.0.0.1
+ bind_port = 4822
EOF
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Ensure guacd is started
@@ -605,27 +605,27 @@ systemctl enable guacd
systemctl stop guacd 2>/dev/null
systemctl start guacd
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
if [ "${CHANGE_ROOT}" = true ]; then
- echo -e "${GREY}Shortening the Guacamole root url and setting up redirect...${DGREY}"
- systemctl stop ${TOMCAT_VERSION}
- mv /var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.html index.html.old
- touch /var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.jsp
- echo "<% response.sendRedirect(\"/guacamole\");%>" >>/var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.jsp
- systemctl start ${TOMCAT_VERSION}
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo -e "${GREY}Shortening the Guacamole root url and setting up redirect...${DGREY}"
+ systemctl stop ${TOMCAT_VERSION}
+ mv /var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.html index.html.old
+ touch /var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.jsp
+ echo "<% response.sendRedirect(\"/guacamole\");%>" >>/var/lib/${TOMCAT_VERSION}/webapps/ROOT/index.jsp
+ systemctl start ${TOMCAT_VERSION}
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
echo -e "${GREY}Updating firewall rules to allow only SSH and tcp 8080..."
@@ -637,11 +637,11 @@ echo "y" | sudo ufw enable >/dev/null 2>&1
# Reduce firewall logging noise
sudo ufw logging off >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Cleanup
@@ -650,20 +650,20 @@ rm -rf guacamole-*
rm -rf mysql-connector-j-*
rm -rf mariadb_repo_setup
if [ "${INSTALL_NGINX}" = false ]; then
- rm -rf 3-install-nginx.sh
- rm -f 4a-install-tls-self-signed-nginx.sh
- rm -rf 4b-install-tls-letsencrypt-nginx.sh
- rm -f refresh-tls-self-signed.sh
+ rm -rf 3-install-nginx.sh
+ rm -f 4a-install-tls-self-signed-nginx.sh
+ rm -rf 4b-install-tls-letsencrypt-nginx.sh
+ rm -f refresh-tls-self-signed.sh
fi
unset MYSQL_PWD
apt-get -y remove expect &>>${INSTALL_LOG}
apt-get -y autoremove &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Done
diff --git a/3-install-nginx.sh b/3-install-nginx.sh
index 3a56772..96eebc0 100644
--- a/3-install-nginx.sh
+++ b/3-install-nginx.sh
@@ -44,15 +44,15 @@ server {
}
EOF
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Force nginx to require tls1.2 and above
-sudo sed -i -e '/ssl_protocols/s/^/#/' /etc/nginx/nginx.conf
+sudo sed -i -e '/ssl_protocols/s/^/#/' /etc/nginx/nginx.conf
sudo sed -i "/SSL Settings/a \ ssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE" /etc/nginx/nginx.conf
# Symlink from sites-available to sites-enabled
@@ -65,11 +65,11 @@ unlink /etc/nginx/sites-enabled/default
echo -e "${GREY}Configuring Apache Tomcat valve for pass through of client IPs to Guacamole logs...${GREY}"
sudo sed -i '/pattern="%h %l %u %t "%r" %s %b"/a \ \n ' /etc/$TOMCAT_VERSION/server.xml
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Allow large file transfers through Nginx
@@ -77,11 +77,11 @@ sudo sed -i '/client_max_body_size/d' /etc/nginx/nginx.conf
sudo sed -i "/Basic Settings/a \ client_max_body_size 100000000M;" /etc/nginx/nginx.conf # Add the larger file transfer size
echo -e "${GREY}Boosting Nginx's 'maximum body size' parameter to allow large file transfers...${GREY}"
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network.
@@ -93,11 +93,11 @@ sudo ufw allow 80/tcp >/dev/null 2>&1
sudo ufw delete allow 8080/tcp >/dev/null 2>&1
echo "y" | sudo ufw enable >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Reload everything
@@ -106,10 +106,10 @@ sudo systemctl restart $TOMCAT_VERSION
sudo systemctl restart guacd
sudo systemctl restart nginx
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
+ echo -e "${LGREEN}OK${GREY}"
fi
# Done
diff --git a/4a-install-tls-self-signed-nginx.sh b/4a-install-tls-self-signed-nginx.sh
index 8e2fc6a..e4046b4 100644
--- a/4a-install-tls-self-signed-nginx.sh
+++ b/4a-install-tls-self-signed-nginx.sh
@@ -31,11 +31,11 @@ DIR_SSL_KEY="/etc/nginx/ssl/private"
# Make directories to place TLS Certificate if they don't exist
if [[ ! -d $DIR_SSL_KEY ]]; then
- sudo mkdir -p $DIR_SSL_KEY
+ sudo mkdir -p $DIR_SSL_KEY
fi
if [[ ! -d $DIR_SSL_CERT ]]; then
- sudo mkdir -p $DIR_SSL_CERT
+ sudo mkdir -p $DIR_SSL_CERT
fi
# Discover IPv4 interface
@@ -72,11 +72,11 @@ echo
echo "{$GREY}Creating a new Nginx TLS Certificate..."
openssl req -x509 -nodes -newkey rsa:2048 -keyout $TLSNAME.key -out $TLSNAME.crt -days $TLSDAYS -config $TMP_DIR/cert_attributes.txt
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Place TLS Certificate into the defined application path
@@ -87,15 +87,15 @@ sudo cp $TLSNAME.crt $DIR_SSL_CERT/$TLSNAME.crt
echo -e "${GREY}Converting client certificates for Windows & Linux...${GREY}"
sudo openssl pkcs12 -export -out $TLSNAME.pfx -inkey $TLSNAME.key -in $TLSNAME.crt -password pass:1234
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Change of permissions so certs can be copied via WinSCP.
-sudo chown $SUDO_USER:root $TLSNAME.pfx
+sudo chown $SUDO_USER:root $TLSNAME.pfx
sudo chown $SUDO_USER:root $TLSNAME.crt
sudo chown $SUDO_USER:root $TLSNAME.key
@@ -103,11 +103,11 @@ sudo chown $SUDO_USER:root $TLSNAME.key
echo -e "${GREY}Backing up previous Nginx proxy to $DOWNLOAD_DIR/$TLSNAME-nginx.bak"
cp /etc/nginx/sites-enabled/${TLSNAME} $DOWNLOAD_DIR/${TLSNAME}-nginx.bak
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Update Nginx config to accept the new certificates
@@ -151,11 +151,11 @@ server {
}
EOF
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network.
@@ -167,11 +167,11 @@ sudo ufw allow 80/tcp >/dev/null 2>&1
sudo ufw allow 443/tcp >/dev/null 2>&1
echo "y" | sudo ufw enable >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Reload everything
@@ -180,11 +180,11 @@ sudo systemctl restart $TOMCAT_VERSION
sudo systemctl restart guacd
sudo systemctl restart nginx
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Hack to assist with displaying "$" symbols and " ' quotes in a (cut/paste-able) bash screen output format
diff --git a/4b-install-tls-letsencrypt-nginx.sh b/4b-install-tls-letsencrypt-nginx.sh
index c9f678c..1a814e9 100644
--- a/4b-install-tls-letsencrypt-nginx.sh
+++ b/4b-install-tls-letsencrypt-nginx.sh
@@ -30,11 +30,11 @@ echo
echo -e "${GREY}Backing up previous Nginx proxy to $DOWNLOAD_DIR/$PROXY_SITE-nginx.bak"
cp /etc/nginx/sites-enabled/${PROXY_SITE} $DOWNLOAD_DIR/${PROXY_SITE}-nginx.bak
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Configure Nginx to accept the new certificates
@@ -58,11 +58,11 @@ server {
}
EOL
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network.
@@ -74,11 +74,11 @@ sudo ufw allow 80/tcp >/dev/null 2>&1
sudo ufw allow 443/tcp >/dev/null 2>&1
echo "y" | sudo ufw enable >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Bounce Nginx to reload the new Nginx config so certbot config can continue
@@ -89,11 +89,11 @@ certbot --nginx -n -d $LE_DNS_NAME --email $LE_EMAIL --agree-tos --redirect --hs
echo -e
echo -e "${GREY}Let's Encrypt successfully installed, but check for any errors above (DNS & firewall are the usual culprits).${GREY}"
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Select a random daily time to schedule a daily check for Let's Encrypt certificates due to expire in next 30 days.
@@ -111,11 +111,11 @@ echo "${MINUTE} ${HOUR} * * * /usr/bin/certbot renew --quiet --pre-hook 'systemc
crontab cron_1
rm cron_1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Reload everything once again
@@ -124,10 +124,10 @@ sudo systemctl restart $TOMCAT_VERSION
sudo systemctl restart guacd
sudo systemctl restart nginx
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
+ echo -e "${LGREEN}OK${GREY}"
fi
# Done
diff --git a/guac-enterprise-build/install-mysql-backend-only.sh b/guac-enterprise-build/install-mysql-backend-only.sh
index b2fa207..6a914ce 100644
--- a/guac-enterprise-build/install-mysql-backend-only.sh
+++ b/guac-enterprise-build/install-mysql-backend-only.sh
@@ -11,7 +11,6 @@
# Layer 2 = GUAC SERVER & APPLICATION - use the main setup script, and select remote MYSQL DB option.
# Layer 3 = FRONT END REV PROXY (Potentially load balanced & HA) - approach TBA
-
#######################################################################################################################
# Script pre-flight checks and settings ###############################################################################
#######################################################################################################################
@@ -29,20 +28,19 @@ NC='\033[0m' #No Colour
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
# Check to see if any previous version of build/install files exist, if so stop and check to be safe.
if [ "$(find . -maxdepth 1 \( -name 'guacamole-*' -o -name 'mysql-connector-j-*' \))" != "" ]; then
- echo
- echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
- echo
- exit 1
+ echo
+ echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
+ echo
+ exit 1
fi
-
#######################################################################################################################
# Initial environment setup ###########################################################################################
#######################################################################################################################
@@ -73,21 +71,20 @@ echo -e " ${LGREEN}Powered by Itiligent"
echo
echo
-
#######################################################################################################################
# Setup options. ######################################################################################################
#######################################################################################################################
-BACKEND_MYSQL="true" # True: Allow $GUAC_USER remote login. False or "": Limits $GUAC_USER to localhost only login.
-FRONTEND_NET="" # "" = allow login from any IP or wildcards e.g. 192.168.1.% (Needs BACKEND_SQL="true", else ignored)
-MYSQL_BIND_ADDR="0.0.0.0" # Bind MySQL to this IP. (127.0.0.1, a specific IP or 0.0.0.0 for all interfaces)
-SECURE_MYSQL="true" # Apply the mysql secure configuration tool (true/false)
-MYSQL_PORT="3306" # Default is 3306
-GUAC_DB="guacamole_db" # Default is guacamole_db
-GUAC_USER="guacamole_user" # Default is guacamole_user
-GUAC_PWD="test" # Requires an entry
-MYSQL_ROOT_PWD="test" # Requires an entry.
-DB_TZ=$(cat /etc/timezone) # Typically system default (cat /etc/timezone) or change to "UTC" if required.
+BACKEND_MYSQL="true" # True: Allow $GUAC_USER remote login. False or "": Limits $GUAC_USER to localhost only login.
+FRONTEND_NET="" # "" = allow login from any IP or wildcards e.g. 192.168.1.% (Needs BACKEND_SQL="true", else ignored)
+MYSQL_BIND_ADDR="0.0.0.0" # Bind MySQL to this IP. (127.0.0.1, a specific IP or 0.0.0.0 for all interfaces)
+SECURE_MYSQL="true" # Apply the mysql secure configuration tool (true/false)
+MYSQL_PORT="3306" # Default is 3306
+GUAC_DB="guacamole_db" # Default is guacamole_db
+GUAC_USER="guacamole_user" # Default is guacamole_user
+GUAC_PWD="test" # Requires an entry
+MYSQL_ROOT_PWD="test" # Requires an entry.
+DB_TZ=$(cat /etc/timezone) # Typically system default (cat /etc/timezone) or change to "UTC" if required.
# For a remotely accessed back end DB instance, keep this script set to BACKEND_MYSQL="true".
# Other options are fairly straight forward. For a typical back end server only the $FRONTEND_NET and $MYSQL_BIND_ADDR
@@ -97,7 +94,6 @@ DB_TZ=$(cat /etc/timezone) # Typically system default (cat /etc/timezone) or ch
# To install a new MySQL database on the same server as the Guacamole application, set BACKEND_MYSQL="false" &
# MYSQL_BIND_ADDR="127.0.0.1". See bottom of this script for some remaining DB migration actions.
-
#######################################################################################################################
# Start install actions ##############################################################################################
#######################################################################################################################
@@ -105,13 +101,13 @@ DB_TZ=$(cat /etc/timezone) # Typically system default (cat /etc/timezone) or ch
# Choose a specific MySQL version e.g. 11.1.2 See https://mariadb.org/mariadb/all-releases/ for available versions.
MYSQL_VERSION="" # Blank "" forces distro default MySQL packages.
if [ -z "${MYSQL_VERSION}" ]; then
- # Use Linux distro default version.
- MYSQLPKG="default-mysql-server default-mysql-client mysql-common"
- DB_CMD="mysql" # mysql command is depricated
- else
- # Use official mariadb.org repo
- MYSQLPKG="mariadb-server mariadb-client mariadb-common"
- DB_CMD="mariadb" # mysql command is depricated on newer versions
+ # Use Linux distro default version.
+ MYSQLPKG="default-mysql-server default-mysql-client mysql-common"
+ DB_CMD="mysql" # mysql command is depricated
+else
+ # Use official mariadb.org repo
+ MYSQLPKG="mariadb-server mariadb-client mariadb-common"
+ DB_CMD="mariadb" # mysql command is depricated on newer versions
fi
# Update everything but don't do the annoying prompts during apt installs
@@ -120,31 +116,31 @@ export DEBIAN_FRONTEND=noninteractive
apt-get update -qq &>>${INSTALL_LOG}
apt-get upgrade -qq -y &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
cd $DOWNLOAD_DIR
# Add the official MariaDB repo
if [ -n "${MYSQL_VERSION}" ]; then
- apt-get -qq -y install curl gnupg2 &>>${INSTALL_LOG}
- curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup &>>${INSTALL_LOG}
- bash mariadb_repo_setup --mariadb-server-version=$MYSQL_VERSION &>>${INSTALL_LOG}
+ apt-get -qq -y install curl gnupg2 &>>${INSTALL_LOG}
+ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup &>>${INSTALL_LOG}
+ bash mariadb_repo_setup --mariadb-server-version=$MYSQL_VERSION &>>${INSTALL_LOG}
fi
# Download and extract the Guacamole SQL authentication extension containing the database schema
echo -e "${GREY}Downloading Guacamole database source files..."
wget -q --show-progress -O guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz"
- exit 1
+ echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz"
+ exit 1
else
- tar -xzf guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
+ tar -xzf guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
fi
echo -e "${LGREEN}Downloaded guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz${GREY}"
@@ -152,11 +148,11 @@ echo
echo -e "${GREY}Installing MySQL packages..."
apt-get -qq -y install ${MYSQLPKG} &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Set the root password without a reliance on debconf.
@@ -166,88 +162,88 @@ FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PWD';"
echo ${SQLCODE} | $DB_CMD -u root
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Find the location of the MySQL or MariaDB config files. (Add to this list for more potential candidates.)
for x in /etc/mysql/mariadb.conf.d/50-server.cnf \
- /etc/mysql/mysql.conf.d/mysqld.cnf \
- /etc/mysql/my.cnf; do
- # Check inside each candidate to see if a [mysqld] or [mariadbd] section exists, assign $x the correct filename.
- if [ -e "${x}" ]; then
- if grep -qE '^\[(mysqld|mariadbd)\]$' "${x}"; then
- mysqlconfig="${x}"
- # Reduce any duplicated section names, then sanitise the [ ] special characters for sed below)
- config_section=$(grep -m 1 -E '^\[(mysqld|mariadbd)\]$' "${x}" | sed 's/\[\(.*\)\]/\1/')
- break
- fi
- fi
+ /etc/mysql/mysql.conf.d/mysqld.cnf \
+ /etc/mysql/my.cnf; do
+ # Check inside each candidate to see if a [mysqld] or [mariadbd] section exists, assign $x the correct filename.
+ if [ -e "${x}" ]; then
+ if grep -qE '^\[(mysqld|mariadbd)\]$' "${x}"; then
+ mysqlconfig="${x}"
+ # Reduce any duplicated section names, then sanitise the [ ] special characters for sed below)
+ config_section=$(grep -m 1 -E '^\[(mysqld|mariadbd)\]$' "${x}" | sed 's/\[\(.*\)\]/\1/')
+ break
+ fi
+ fi
done
# Set the MySQL Timezone
if [ -z "${mysqlconfig}" ]; then
- echo -e "${GREY}Couldn't detect MySQL config file - you will need to manually configure database timezone settings"
+ echo -e "${GREY}Couldn't detect MySQL config file - you will need to manually configure database timezone settings"
else
- # Is there already a timzeone value configured?
- if grep -q "^default_time_zone[[:space:]]=" "${mysqlconfig}"; then
- echo -e "MySQL database timezone defined in ${mysqlconfig}"
- else
- timezone=${DB_TZ}
- if [ -z "${DB_TZ}" ]; then
- echo -e "Couldn't find system timezone, using UTC$"
- timezone="UTC"
- fi
- echo -e "Setting MySQL database timezone as ${timezone}${GREY}"
- mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | ${DB_CMD} -u root -D mysql -p${MYSQL_ROOT_PWD}
- # Add the timzone value to the sanitsed server file section name.
- sed -i -e "/^\[${config_section}\]/a default_time_zone = ${timezone}" "${mysqlconfig}"
- fi
+ # Is there already a timzeone value configured?
+ if grep -q "^default_time_zone[[:space:]]=" "${mysqlconfig}"; then
+ echo -e "MySQL database timezone defined in ${mysqlconfig}"
+ else
+ timezone=${DB_TZ}
+ if [ -z "${DB_TZ}" ]; then
+ echo -e "Couldn't find system timezone, using UTC$"
+ timezone="UTC"
+ fi
+ echo -e "Setting MySQL database timezone as ${timezone}${GREY}"
+ mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | ${DB_CMD} -u root -D mysql -p${MYSQL_ROOT_PWD}
+ # Add the timzone value to the sanitsed server file section name.
+ sed -i -e "/^\[${config_section}\]/a default_time_zone = ${timezone}" "${mysqlconfig}"
+ fi
fi
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Set the MySQL binding IP address to whatever the setup variable is set to.
echo -e "${GREY}Setting MySQL IP address binding to ${MYSQL_BIND_ADDR}..."
sed -i "s/^bind-address[[:space:]]*=[[:space:]]*.*/bind-address = ${MYSQL_BIND_ADDR}/g" ${mysqlconfig}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Establish the appropriate form of Guacamole user account access (remote or localhost login permissions)
echo -e "${GREY}Setting up database access parameters for the Guacamole user ..."
if [ "${BACKEND_MYSQL}" = true ] && [ -z "${FRONTEND_NET}" ]; then
- echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from any host, you may wish to limit this to specific IPs.${GREY}"
- # e.g. RENAME USER '${GUAC_USER}'@'%' TO '${GUAC_USER}'@'xx.xx.xx.%';"
- GUAC_USERHost="%" # Allow all IPs
- elif [ "${BACKEND_MYSQL}" = true ] && [ -n "${FRONTEND_NET}" ]; then
- echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from ${FRONTEND_NET}.${GREY}"
- GUAC_USERHost="${FRONTEND_NET}" # Apply the given range
- elif [ "${BACKEND_MYSQL}" = false ] || [ -z "${BACKEND_MYSQL}" ]; then
- echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from localhost only.${GREY}"
- GUAC_USERHost=localhost # Assume a localhost only install
- else
- echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from localhost only.${GREY}"
- GUAC_USERHost=localhost # Assume a localhost only install
+ echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from any host, you may wish to limit this to specific IPs.${GREY}"
+ # e.g. RENAME USER '${GUAC_USER}'@'%' TO '${GUAC_USER}'@'xx.xx.xx.%';"
+ GUAC_USERHost="%" # Allow all IPs
+elif [ "${BACKEND_MYSQL}" = true ] && [ -n "${FRONTEND_NET}" ]; then
+ echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from ${FRONTEND_NET}.${GREY}"
+ GUAC_USERHost="${FRONTEND_NET}" # Apply the given range
+elif [ "${BACKEND_MYSQL}" = false ] || [ -z "${BACKEND_MYSQL}" ]; then
+ echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from localhost only.${GREY}"
+ GUAC_USERHost=localhost # Assume a localhost only install
+else
+ echo -e "${LYELLOW}${GUAC_USER} is set to accept db logins from localhost only.${GREY}"
+ GUAC_USERHost=localhost # Assume a localhost only install
fi
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Create the new Guacamole database
@@ -261,29 +257,29 @@ FLUSH PRIVILEGES;"
# Execute SQL code
echo ${SQLCODE} | $DB_CMD -u root -D mysql -p${MYSQL_ROOT_PWD}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Add Guacamole's schema code to newly created database
echo -e "${GREY}Adding the Guacamole database schema..."
cat guacamole-auth-jdbc-${GUAC_VERSION}/mysql/schema/*.sql | $DB_CMD -u root -D ${GUAC_DB} -p${MYSQL_ROOT_PWD}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Apply Secure MySQL installation settings
if [ "${SECURE_MYSQL}" = true ]; then
-apt-get -qq -y install expect &>>${INSTALL_LOG}
- echo -e "${GREY}Applying mysql_secure_installation settings...${DGREY}"
- SECURE_MYSQL=$(expect -c "
+ apt-get -qq -y install expect &>>${INSTALL_LOG}
+ echo -e "${GREY}Applying mysql_secure_installation settings...${DGREY}"
+ SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
@@ -302,14 +298,14 @@ expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
")
- echo "$SECURE_MYSQL"
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
- else
- echo -e "${LGREEN}OK${GREY}"
- echo
- fi
+ echo "$SECURE_MYSQL"
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Restart & enable MySQL service at boot
@@ -317,11 +313,11 @@ echo -e "${GREY}Restarting MySQL service & enable at boot..."
systemctl enable mysql
systemctl restart mysql
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Cleanup
@@ -330,11 +326,11 @@ apt-get -y remove expect &>>${INSTALL_LOG}
apt-get -y autoremove &>>${INSTALL_LOG}
rm -rf guacamole-*
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Done
@@ -342,7 +338,6 @@ echo
printf "${LGREEN}Guacamole ${GUAC_VERSION} MySQL backend install complete! \n${NC}"
echo -e ${NC}
-
#######################################################################################################################
# Additional migration steps for adding MySQL to an existing Guacamole application server
#######################################################################################################################
@@ -368,4 +363,4 @@ echo -e ${NC}
#echo "mysql-port: ${MYSQL_PORT}" >>/etc/guacamole/guacamole.properties
#echo "mysql-database: ${GUAC_DB}" >>/etc/guacamole/guacamole.properties
#echo "mysql-username: ${GUAC_USER}" >>/etc/guacamole/guacamole.properties
-#echo "mysql-password: ${GUAC_PWD}" >>/etc/guacamole/guacamole.properties
\ No newline at end of file
+#echo "mysql-password: ${GUAC_PWD}" >>/etc/guacamole/guacamole.properties
diff --git a/guac-enterprise-build/upgrade-mysql-backend-only.sh b/guac-enterprise-build/upgrade-mysql-backend-only.sh
index 1219ca0..201b803 100644
--- a/guac-enterprise-build/upgrade-mysql-backend-only.sh
+++ b/guac-enterprise-build/upgrade-mysql-backend-only.sh
@@ -6,7 +6,7 @@
# April 2023
#######################################################################################################################
-# The Guacamole schema have not been updated since late 2021, suggesting that its now quite mature and there will be
+# The Guacamole schema have not been updated since late 2021, suggesting that its now quite mature and there will be
# little need to use this, but just in case. Update the database packages separately via apt.
#######################################################################################################################
@@ -26,20 +26,19 @@ NC='\033[0m' #No Colour
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
# Check to see if any previous version of build/install files exist, if so stop and check to be safe.
if [ "$(find . -maxdepth 1 \( -name 'guacamole-*' -o -name 'mysql-connector-j-*' \))" != "" ]; then
- echo
- echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
- echo
- exit 1
+ echo
+ echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
+ echo
+ exit 1
fi
-
#######################################################################################################################
# Initial environment setup ###########################################################################################
#######################################################################################################################
@@ -84,11 +83,11 @@ echo
# Download and extract the Guacamole SQL authentication extension containing the database schema
wget -q --show-progress -O guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
+ echo -e "${LRED}Failed to download guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
else
- tar -xzf guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
+ tar -xzf guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
fi
echo
@@ -98,42 +97,42 @@ UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/schema/upgra
# Compare SQL Upgrage Files against old version, apply upgrades as needed
for FILE in ${UPGRADEFILES[@]}; do
- FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)')
- if [[ $(echo -e "${FILEVERSION}\n${OLD_GUAC_VERSION}" | sort -V | head -n1) == ${OLD_GUAC_VERSION} && ${FILEVERSION} != ${OLD_GUAC_VERSION} ]]; then
- echo "Patching ${GUAC_DB} with ${FILE}"
- mariadb -u root -D ${GUAC_DB} -p${MYSQL_ROOT_PWD} >${INSTALL_LOG}
- fi
+ FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)')
+ if [[ $(echo -e "${FILEVERSION}\n${OLD_GUAC_VERSION}" | sort -V | head -n1) == ${OLD_GUAC_VERSION} && ${FILEVERSION} != ${OLD_GUAC_VERSION} ]]; then
+ echo "Patching ${GUAC_DB} with ${FILE}"
+ mariadb -u root -D ${GUAC_DB} -p${MYSQL_ROOT_PWD} >${INSTALL_LOG}
+ fi
done
if [ $? -ne 0 ]; then
- echo -e "${LRED}SQL upgrade failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}SQL upgrade failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Restart MySQL service
echo -e "${GREY}Restarting MySQL service..."
systemctl restart mysql
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Cleanup
echo -e "${GREY}Clean up install files...${GREY}"
rm -rf guacamole-*
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Done
printf "${LGREEN}Guacamole ${NEW_GUAC_VERSION} schema upgrade complete - check log for details! \n${NC}"
-echo -e ${NC}
\ No newline at end of file
+echo -e ${NC}
diff --git a/guac-management/backup-guac.sh b/guac-management/backup-guac.sh
index 141f353..97e506b 100644
--- a/guac-management/backup-guac.sh
+++ b/guac-management/backup-guac.sh
@@ -39,28 +39,28 @@ echo -e "${LGREEN}Backup started for database - ${GUAC_DB}"
echo
mysqldump -h ${MYSQL_HOST} \
- -P ${MYSQL_PORT} \
- -u ${GUAC_USER} \
- -p"${GUAC_PWD}" \
- ${GUAC_DB} \
- --single-transaction --quick --lock-tables=false >${DB_BACKUP_DIR}${GUAC_DB}-${TODAY}.sql
+ -P ${MYSQL_PORT} \
+ -u ${GUAC_USER} \
+ -p"${GUAC_PWD}" \
+ ${GUAC_DB} \
+ --single-transaction --quick --lock-tables=false >${DB_BACKUP_DIR}${GUAC_DB}-${TODAY}.sql
SQLFILE=${DB_BACKUP_DIR}${GUAC_DB}-${TODAY}.sql
if [ $? -ne 0 ]; then
- echo -e "${LRED}Backup failed.${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Backup failed.${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}Backup completed ok.${GREY}"
- echo
+ echo -e "${LGREEN}Backup completed ok.${GREY}"
+ echo
fi
gzip -f ${SQLFILE}
# Error check and email alerts
if [ $? -ne 0 ]; then
- echo -e "${LRED}Backup failed.${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Backup failed.${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}${GUAC_DB} backup was successfully copied to ${DB_BACKUP_DIR}"
- #mailx -s "Guacamomle Database Backup Success" ${BACKUP_EMAIL}
- echo "${GUAC_DB} backup was successfully copied to $DB_BACKUP_DIR" | mailx -s "Guacamole backup " ${BACKUP_EMAIL}
+ echo -e "${LGREEN}${GUAC_DB} backup was successfully copied to ${DB_BACKUP_DIR}"
+ #mailx -s "Guacamomle Database Backup Success" ${BACKUP_EMAIL}
+ echo "${GUAC_DB} backup was successfully copied to $DB_BACKUP_DIR" | mailx -s "Guacamole backup " ${BACKUP_EMAIL}
fi
echo -e ${NC}
diff --git a/guac-management/refresh-tls-self-signed.sh b/guac-management/refresh-tls-self-signed.sh
index aca03d1..219055f 100644
--- a/guac-management/refresh-tls-self-signed.sh
+++ b/guac-management/refresh-tls-self-signed.sh
@@ -24,10 +24,10 @@ NC='\033[0m' #No Colour
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
- echo
- exit 1
+ echo
+ echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
+ echo
+ exit 1
fi
echo
@@ -61,19 +61,19 @@ CERT_DAYS=
DEFAULT_IP=
# Assume the values used by the guacamole installer if the script is run without any command line options
-if [ -z "$1" ] | [ -z "$2" ] | [ -z "$3" ] ; then
-TLSNAME=$PROXY_SITE
-TLSDAYS=$CERT_DAYS
-TLSIP=$DEFAULT_IP
+if [ -z "$1" ] | [ -z "$2" ] | [ -z "$3" ]; then
+ TLSNAME=$PROXY_SITE
+ TLSDAYS=$CERT_DAYS
+ TLSIP=$DEFAULT_IP
fi
# Make directories to place TLS Certificate if they don't exist
if [[ ! -d $DIR_SSL_KEY ]]; then
- sudo mkdir -p $DIR_SSL_KEY
+ sudo mkdir -p $DIR_SSL_KEY
fi
if [[ ! -d $DIR_SSL_CERT ]]; then
- sudo mkdir -p $DIR_SSL_CERT
+ sudo mkdir -p $DIR_SSL_CERT
fi
echo -e "${GREY}New self signed TLS certificate attributes are shown below...${DGREY}"
@@ -108,11 +108,11 @@ echo
echo "{$GREY}Creating a new TLS Certificate..."
openssl req -x509 -nodes -newkey rsa:2048 -keyout $TLSNAME.key -out $TLSNAME.crt -days $TLSDAYS -config cert_attributes.txt
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed.${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed.${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Place TLS Certificate into the defined application path
@@ -123,11 +123,11 @@ cp $TLSNAME.crt $DIR_SSL_CERT/$TLSNAME.crt
echo -e "${GREY}Converting client certificates for Windows & Linux...${GREY}"
openssl pkcs12 -export -out $TLSNAME.pfx -inkey $TLSNAME.key -in $TLSNAME.crt -password pass:1234
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed.${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed.${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Change of permissions so certs can be copied via WinSCP.
@@ -140,11 +140,11 @@ systemctl restart $TOMCAT
systemctl restart guacd
systemctl restart nginx
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed.${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed.${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Hack to assist with displaying "$" symbols and " ' quotes in a (cut/paste-able) bash screen output format
diff --git a/guac-management/upgrade-guac.sh b/guac-management/upgrade-guac.sh
index 261bf52..495f46e 100644
--- a/guac-management/upgrade-guac.sh
+++ b/guac-management/upgrade-guac.sh
@@ -23,20 +23,19 @@ NC='\033[0m' #No Colour
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LRED}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
# Check to see if any previous version of build/install files exist, if so stop and check to be safe.
if [ "$(find . -maxdepth 1 \( -name 'guacamole-*' -o -name 'mysql-connector-j-*' \))" != "" ]; then
- echo
- echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
- echo
- exit 1
+ echo
+ echo -e "${LRED}Possible previous install files detected. Please review and remove old guacamole install files before proceeding.${GREY}" 1>&2
+ echo
+ exit 1
fi
-
#######################################################################################################################
# Initial environment setup ###########################################################################################
#######################################################################################################################
@@ -82,7 +81,6 @@ echo -e "${GREYB}Guacamole VDI & Jump Server Appliance UPGRADE."
echo -e " ${LGREEN}Powered by Itiligent"
echo
-
#######################################################################################################################
# Start upgrade actions ##############################################################################################
#######################################################################################################################
@@ -99,51 +97,51 @@ echo
echo -e "${GREY}Downloading updated Guacamole source files and beginning Guacamole ${OLD_GUAC_VERSION} to ${NEW_GUAC_VERSION} upgrade..."
wget -q --show-progress -O guacamole-${NEW_GUAC_VERSION}.war ${GUAC_SOURCE_LINK}/binary/guacamole-${NEW_GUAC_VERSION}.war
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-${NEW_GUAC_VERSION}.war" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${NEW_GUAC_VERSION}.war${GREY}"
- exit 1
+ echo -e "${LRED}Failed to download guacamole-${NEW_GUAC_VERSION}.war" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${NEW_GUAC_VERSION}.war${GREY}"
+ exit 1
else
- rm /etc/guacamole/guacamole.war
- mv -f guacamole-${NEW_GUAC_VERSION}.war /etc/guacamole/guacamole.war
- chmod 664 /etc/guacamole/guacamole.war
+ rm /etc/guacamole/guacamole.war
+ mv -f guacamole-${NEW_GUAC_VERSION}.war /etc/guacamole/guacamole.war
+ chmod 664 /etc/guacamole/guacamole.war
fi
echo -e "${LGREEN}Upgraded Guacamole client to version ${NEW_GUAC_VERSION}${GREY}"
# Download and upgrade Guacamole SQL authentication extension
wget -q --show-progress -O guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
+ echo -e "${LRED}Failed to download guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
else
- tar -xzf guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
- rm /etc/guacamole/extensions/guacamole-auth-jdbc-*.jar
- mv -f guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/
- chmod 664 /etc/guacamole/extensions/guacamole-auth-jdbc-mysql-${NEW_GUAC_VERSION}.jar
+ tar -xzf guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz
+ rm /etc/guacamole/extensions/guacamole-auth-jdbc-*.jar
+ mv -f guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-jdbc-mysql-${NEW_GUAC_VERSION}.jar
fi
echo -e "${LGREEN}Upgraded Guacamole SQL jdbc to version ${NEW_GUAC_VERSION}${GREY}"
# Download MySQL connector/j
wget -q --show-progress -O mysql-connector-j-${NEW_MYSQLJCON}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${NEW_MYSQLJCON}.tar.gz
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download mysql-connector-j-${NEW_MYSQLJCON}.tar.gz" 1>&2
- echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${NEW_MYSQLJCON}}.tar.gz${GREY}"
- exit 1
+ echo -e "${LRED}Failed to download mysql-connector-j-${NEW_MYSQLJCON}.tar.gz" 1>&2
+ echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${NEW_MYSQLJCON}}.tar.gz${GREY}"
+ exit 1
else
- tar -xzf mysql-connector-j-${NEW_MYSQLJCON}.tar.gz
- rm /etc/guacamole/lib/mysql-connector-java.jar
- mv -f mysql-connector-j-${NEW_MYSQLJCON}/mysql-connector-j-${NEW_MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
+ tar -xzf mysql-connector-j-${NEW_MYSQLJCON}.tar.gz
+ rm /etc/guacamole/lib/mysql-connector-java.jar
+ mv -f mysql-connector-j-${NEW_MYSQLJCON}/mysql-connector-j-${NEW_MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
fi
echo -e "${LGREEN}Upgraded MySQL connector/j to ${NEW_MYSQLJCON}${GREY}"
# Download Guacamole Server
wget -q --show-progress -O guacamole-server-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${NEW_GUAC_VERSION}.tar.gz
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-server-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${NEW_GUAC_VERSION}.tar.gz${GREY}"
- exit 1
+ echo -e "${LRED}Failed to download guacamole-server-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${NEW_GUAC_VERSION}.tar.gz${GREY}"
+ exit 1
else
- tar -xzf guacamole-server-${NEW_GUAC_VERSION}.tar.gz
+ tar -xzf guacamole-server-${NEW_GUAC_VERSION}.tar.gz
fi
echo -e "${LGREEN}Downloaded guacamole-server-${NEW_GUAC_VERSION}.tar.gz${GREY}"
@@ -156,162 +154,162 @@ export CFLAGS="-Wno-error"
# Configure Guacamole Server source
./configure --with-systemd-dir=/etc/systemd/system &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo "Failed to configure guacamole-server"
- echo "Trying again with --enable-allow-freerdp-snapshots"
- ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots
- if [ $? -ne 0 ]; then
- echo "Failed to configure guacamole-server - again"
- exit
- fi
+ echo "Failed to configure guacamole-server"
+ echo "Trying again with --enable-allow-freerdp-snapshots"
+ ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots
+ if [ $? -ne 0 ]; then
+ echo "Failed to configure guacamole-server - again"
+ exit
+ fi
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
echo -e "${GREY}Running make and building the upgraded Guacamole-Server application..."
make &>>${INSTALL_LOG}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
echo -e "${GREY}Installing the upgraded Guacamole-Server..."
make install &>>${INSTALL_LOG}
ldconfig
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
cd ..
# Don't run the SQL upgrade commands if original setup option was set to remote MySQL instance. - Use separate DB update script.
if [ "${INSTALL_MYSQL}" = true ]; then
-# Get list of SQL Upgrade Files
-echo -e "${GREY}Upgrading MySQL Schema..."
-UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/schema/upgrade/ | sort -V))
+ # Get list of SQL Upgrade Files
+ echo -e "${GREY}Upgrading MySQL Schema..."
+ UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/schema/upgrade/ | sort -V))
-# Compare SQL Upgrage Files against old version, apply upgrades as needed
-for FILE in ${UPGRADEFILES[@]}; do
- FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)')
- if [[ $(echo -e "${FILEVERSION}\n${OLD_GUAC_VERSION}" | sort -V | head -n1) == ${OLD_GUAC_VERSION} && ${FILEVERSION} != ${OLD_GUAC_VERSION} ]]; then
- echo "Patching ${GUAC_DB} with ${FILE}"
- mysql -u root -D ${GUAC_DB} -h ${MYSQL_HOST} -P ${MYSQL_PORT} >${INSTALL_LOG}
- fi
-done
-if [ $? -ne 0 ]; then
- echo -e "${LRED}SQL upgrade failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
-else
- echo -e "${LGREEN}OK${GREY}"
- echo
-fi
+ # Compare SQL Upgrage Files against old version, apply upgrades as needed
+ for FILE in ${UPGRADEFILES[@]}; do
+ FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)')
+ if [[ $(echo -e "${FILEVERSION}\n${OLD_GUAC_VERSION}" | sort -V | head -n1) == ${OLD_GUAC_VERSION} && ${FILEVERSION} != ${OLD_GUAC_VERSION} ]]; then
+ echo "Patching ${GUAC_DB} with ${FILE}"
+ mysql -u root -D ${GUAC_DB} -h ${MYSQL_HOST} -P ${MYSQL_PORT} >${INSTALL_LOG}
+ fi
+ done
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}SQL upgrade failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
+ else
+ echo -e "${LGREEN}OK${GREY}"
+ echo
+ fi
fi
# Check for TOTP extension and upgrade if found
for file in /etc/guacamole/extensions/guacamole-auth-totp*.jar; do
- if [[ -f $file ]]; then
- echo -e "${LGREEN}TOTP authentication extension was found, upgrading...${GREY}"
- rm /etc/guacamole/extensions/guacamole-auth-totp*.jar &>>${INSTALL_LOG}
- wget -q --show-progress -O guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
- fi
- tar -xzf guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
- mv -f guacamole-auth-totp-${NEW_GUAC_VERSION}/guacamole-auth-totp-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
- chmod 664 /etc/guacamole/extensions/guacamole-auth-totp-${NEW_GUAC_VERSION}.jar
- echo -e "${LGREEN}Upgraded TOTP extension to version ${NEW_GUAC_VERSION}${GREY}"
- echo
- break
- fi
+ if [[ -f $file ]]; then
+ echo -e "${LGREEN}TOTP authentication extension was found, upgrading...${GREY}"
+ rm /etc/guacamole/extensions/guacamole-auth-totp*.jar &>>${INSTALL_LOG}
+ wget -q --show-progress -O guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
+ fi
+ tar -xzf guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
+ mv -f guacamole-auth-totp-${NEW_GUAC_VERSION}/guacamole-auth-totp-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-totp-${NEW_GUAC_VERSION}.jar
+ echo -e "${LGREEN}Upgraded TOTP extension to version ${NEW_GUAC_VERSION}${GREY}"
+ echo
+ break
+ fi
done
# Check for DUO extension and upgrade if found
for file in /etc/guacamole/extensions/guacamole-auth-duo*.jar; do
- if [[ -f $file ]]; then
- echo -e "${LGREEN}DUO authentication extension was found, upgrading...${GREY}"
- rm /etc/guacamole/extensions/guacamole-auth-duo*.jar &>>${INSTALL_LOG}
- wget -q --show-progress -O guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
- fi
- tar -xzf guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
- mv -f guacamole-auth-duo-${NEW_GUAC_VERSION}/guacamole-auth-duo-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
- chmod 664 /etc/guacamole/extensions/guacamole-auth-duo-${NEW_GUAC_VERSION}.jar
- echo -e "${LGREEN}Upgraded DUO extension to version ${NEW_GUAC_VERSION}${GREY}"
- echo
- break
- fi
+ if [[ -f $file ]]; then
+ echo -e "${LGREEN}DUO authentication extension was found, upgrading...${GREY}"
+ rm /etc/guacamole/extensions/guacamole-auth-duo*.jar &>>${INSTALL_LOG}
+ wget -q --show-progress -O guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
+ fi
+ tar -xzf guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
+ mv -f guacamole-auth-duo-${NEW_GUAC_VERSION}/guacamole-auth-duo-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-duo-${NEW_GUAC_VERSION}.jar
+ echo -e "${LGREEN}Upgraded DUO extension to version ${NEW_GUAC_VERSION}${GREY}"
+ echo
+ break
+ fi
done
# Check for LDAP extension and upgrade if found
for file in /etc/guacamole/extensions/guacamole-auth-ldap*.jar; do
- if [[ -f $file ]]; then
- echo -e "${LGREEN}LDAP authentication extension was found, upgrading...${GREY}"
- rm /etc/guacamole/extensions/guacamole-auth-ldap*.jar &>>${INSTALL_LOG}
- wget -q --show-progress -O guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
- fi
- tar -xzf guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
- mv -f guacamole-auth-ldap-${NEW_GUAC_VERSION}/guacamole-auth-ldap-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
- chmod 664 /etc/guacamole/extensions/guacamole-auth-ldap-${NEW_GUAC_VERSION}.jar
- echo -e "${LGREEN}Upgraded LDAP extension to version ${NEW_GUAC_VERSION}${GREY}"
- echo
- break
- fi
+ if [[ -f $file ]]; then
+ echo -e "${LGREEN}LDAP authentication extension was found, upgrading...${GREY}"
+ rm /etc/guacamole/extensions/guacamole-auth-ldap*.jar &>>${INSTALL_LOG}
+ wget -q --show-progress -O guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
+ fi
+ tar -xzf guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
+ mv -f guacamole-auth-ldap-${NEW_GUAC_VERSION}/guacamole-auth-ldap-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-ldap-${NEW_GUAC_VERSION}.jar
+ echo -e "${LGREEN}Upgraded LDAP extension to version ${NEW_GUAC_VERSION}${GREY}"
+ echo
+ break
+ fi
done
# Check for Quick Connection extension and upgrade if found
for file in /etc/guacamole/extensions/guacamole-auth-quickconnect*.jar; do
- if [[ -f $file ]]; then
- echo -e "${LGREEN}Quick Connect extension was found, upgrading...${GREY}"
- rm /etc/guacamole/extensions/guacamole-auth-quickconnect*.jar &>>${INSTALL_LOG}
- wget -q --show-progress -O guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
- fi
- tar -xzf guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
- mv -f guacamole-auth-quickconnect-${NEW_GUAC_VERSION}/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
- chmod 664 /etc/guacamole/extensions/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.jar
- echo -e "${LGREEN}Upgraded Quick Connect extension to version ${NEW_GUAC_VERSION}${GREY}"
- echo
- break
- fi
+ if [[ -f $file ]]; then
+ echo -e "${LGREEN}Quick Connect extension was found, upgrading...${GREY}"
+ rm /etc/guacamole/extensions/guacamole-auth-quickconnect*.jar &>>${INSTALL_LOG}
+ wget -q --show-progress -O guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
+ fi
+ tar -xzf guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
+ mv -f guacamole-auth-quickconnect-${NEW_GUAC_VERSION}/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
+ chmod 664 /etc/guacamole/extensions/guacamole-auth-quickconnect-${NEW_GUAC_VERSION}.jar
+ echo -e "${LGREEN}Upgraded Quick Connect extension to version ${NEW_GUAC_VERSION}${GREY}"
+ echo
+ break
+ fi
done
# Check for History Recording Storage extension and upgrade if found
for file in /etc/guacamole/extensions/guacamole-history-recording-storage*.jar; do
- if [[ -f $file ]]; then
- echo -e "${LGREEN}History Recording Storage extension was found, upgrading...${GREY}"
- rm /etc/guacamole/extensions/guacamole-history-recording-storage*.jar &>>${INSTALL_LOG}
- wget -q --show-progress -O guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz
- if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed to download guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz" 1>&2
- echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz"
- exit 1
- fi
- tar -xzf guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
- mv -f guacamole-history-recording-storage-${NEW_GUAC_VERSION}/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
- chmod 664 /etc/guacamole/extensions/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.jar
- echo -e "${LGREEN}Upgraded History Recording Storage extension to version ${NEW_GUAC_VERSION}${GREY}"
- echo
- break
- fi
+ if [[ -f $file ]]; then
+ echo -e "${LGREEN}History Recording Storage extension was found, upgrading...${GREY}"
+ rm /etc/guacamole/extensions/guacamole-history-recording-storage*.jar &>>${INSTALL_LOG}
+ wget -q --show-progress -O guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz
+ if [ $? -ne 0 ]; then
+ echo -e "${LRED}Failed to download guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz" 1>&2
+ echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz"
+ exit 1
+ fi
+ tar -xzf guacamole-history-recording-storage-${NEW_GUAC_VERSION}.tar.gz &>>${INSTALL_LOG}
+ mv -f guacamole-history-recording-storage-${NEW_GUAC_VERSION}/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${INSTALL_LOG}
+ chmod 664 /etc/guacamole/extensions/guacamole-history-recording-storage-${NEW_GUAC_VERSION}.jar
+ echo -e "${LGREEN}Upgraded History Recording Storage extension to version ${NEW_GUAC_VERSION}${GREY}"
+ echo
+ break
+ fi
done
# Fix for #196 see https://github.com/MysticRyuujin/guac-install/issues/196
@@ -328,11 +326,11 @@ systemctl enable guacd
systemctl start guacd
systemctl start ${TOMCAT_VERSION}
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Cleanup
@@ -340,11 +338,11 @@ echo -e "${GREY}Clean up install files...${GREY}"
rm -rf guacamole-*
rm -rf mysql-connector-j-*
if [ $? -ne 0 ]; then
- echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Failed. See ${INSTALL_LOG}${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Done
diff --git a/guac-optional-features/add-auth-duo.sh b/guac-optional-features/add-auth-duo.sh
index 4d2a7c4..e617521 100644
--- a/guac-optional-features/add-auth-duo.sh
+++ b/guac-optional-features/add-auth-duo.sh
@@ -18,9 +18,9 @@ NC='\033[0m' #No Colour
clear
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)
GUAC_VERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT_VERSION}/webapps/guacamole/guacamole-common-js/modules/Version.js)
diff --git a/guac-optional-features/add-auth-ldap.sh b/guac-optional-features/add-auth-ldap.sh
index 2bc643a..e3e7acc 100644
--- a/guac-optional-features/add-auth-ldap.sh
+++ b/guac-optional-features/add-auth-ldap.sh
@@ -19,9 +19,9 @@ clear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)
@@ -36,13 +36,13 @@ echo
case $yn in
y) echo Beginning LDAP auth config... ;;
n)
- echo exiting...
- exit
- ;;
+ echo exiting...
+ exit
+ ;;
*)
- echo invalid response
- exit 1
- ;;
+ echo invalid response
+ exit 1
+ ;;
esac
echo
diff --git a/guac-optional-features/add-auth-totp.sh b/guac-optional-features/add-auth-totp.sh
index 2582bbf..c16a615 100644
--- a/guac-optional-features/add-auth-totp.sh
+++ b/guac-optional-features/add-auth-totp.sh
@@ -19,9 +19,9 @@ clear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)
diff --git a/guac-optional-features/add-fail2ban.sh b/guac-optional-features/add-fail2ban.sh
index fb1db6d..37a1cf9 100644
--- a/guac-optional-features/add-fail2ban.sh
+++ b/guac-optional-features/add-fail2ban.sh
@@ -19,9 +19,9 @@ clear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
# Initialise variables
@@ -43,25 +43,25 @@ rm -f /tmp/fail2ban.update
# Prompt to install fail2ban base package with no policy as yet, default of yes
if [[ -z ${FAIL2BAN_BASE} ]]; then
- echo
- echo -e -n "${LGREEN}Install Fail2ban? (base package with no policy as yet) [default y]: ${GREY}"
- read PROMPT
- if [[ ${PROMPT} =~ ^[Nn]$ ]]; then
- FAIL2BAN_BASE=false
- else
- FAIL2BAN_BASE=true
- fi
+ echo
+ echo -e -n "${LGREEN}Install Fail2ban? (base package with no policy as yet) [default y]: ${GREY}"
+ read PROMPT
+ if [[ ${PROMPT} =~ ^[Nn]$ ]]; then
+ FAIL2BAN_BASE=false
+ else
+ FAIL2BAN_BASE=true
+ fi
fi
# Prompt to install Guacamole fail2ban config defaults, default of no
if [[ -z ${FAIL2BAN_GUAC} ]] && [[ "${FAIL2BAN_BASE}" = true ]]; then
- echo -e -n "${GREY}POLICY: Apply Guacamole fail2ban security policy? (Y/n) [default y]:${GREY}"
- read PROMPT
- if [[ ${PROMPT} =~ ^[Nn]$ ]]; then
- FAIL2BAN_GUAC=false
- else
- FAIL2BAN_GUAC=true
- fi
+ echo -e -n "${GREY}POLICY: Apply Guacamole fail2ban security policy? (Y/n) [default y]:${GREY}"
+ read PROMPT
+ if [[ ${PROMPT} =~ ^[Nn]$ ]]; then
+ FAIL2BAN_GUAC=false
+ else
+ FAIL2BAN_GUAC=true
+ fi
fi
# Prompt to install Nginx fail2ban config defaults , default of no - NOT IMPLEMENTED YET
@@ -93,12 +93,12 @@ fi
# Install base fail2ban base application, and whitelist the local subnet as the starting baseline (no policy defined yet)
if [ "${FAIL2BAN_BASE}" = true ]; then
- #Update and install fail2ban (and john for management of config file updates, and not overwrite any existing settings)
- sudo apt-get update -qq >/dev/null 2>&1
- sudo apt-get install fail2ban john -qq -y >/dev/null 2>&1
+ #Update and install fail2ban (and john for management of config file updates, and not overwrite any existing settings)
+ sudo apt-get update -qq >/dev/null 2>&1
+ sudo apt-get install fail2ban john -qq -y >/dev/null 2>&1
- # Create the basic jail.local template and local subnet whitelist
- cat >/tmp/fail2ban.conf </tmp/fail2ban.conf </tmp/ip_list.txt
+ # We need to discover all interfaces to ascertain what network ranges to add to fail2ban "ignoreip" policy override defaults
+ ip -o addr show up primary scope global | while read -r num dev fam addr rest; do echo ${addr%*}; done | cat >/tmp/ip_list.txt
- # Loop the list of discovered ips and extract the subnet ID addresses for each interface
- FILE=/tmp/ip_list.txt
- LINES=$(cat $FILE)
- for LINE in $LINES; do
+ # Loop the list of discovered ips and extract the subnet ID addresses for each interface
+ FILE=/tmp/ip_list.txt
+ LINES=$(cat $FILE)
+ for LINE in $LINES; do
- tonum() {
- if [[ $LINE =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then
- addr=$(((${BASH_REMATCH[1]} << 24) + (${BASH_REMATCH[2]} << 16) + (${BASH_REMATCH[3]} << 8) + ${BASH_REMATCH[4]}))
- eval "$2=\$addr"
- fi
- }
- toaddr() {
- b1=$((($1 & 0xFF000000) >> 24))
- b2=$((($1 & 0xFF0000) >> 16))
- b3=$((($1 & 0xFF00) >> 8))
- b4=$(($1 & 0xFF))
- eval "$2=\$b1.\$b2.\$b3.\$b4"
- }
+ tonum() {
+ if [[ $LINE =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then
+ addr=$(((${BASH_REMATCH[1]} << 24) + (${BASH_REMATCH[2]} << 16) + (${BASH_REMATCH[3]} << 8) + ${BASH_REMATCH[4]}))
+ eval "$2=\$addr"
+ fi
+ }
+ toaddr() {
+ b1=$((($1 & 0xFF000000) >> 24))
+ b2=$((($1 & 0xFF0000) >> 16))
+ b3=$((($1 & 0xFF00) >> 8))
+ b4=$(($1 & 0xFF))
+ eval "$2=\$b1.\$b2.\$b3.\$b4"
+ }
- if [[ $LINE =~ ^([0-9\.]+)/([0-9]+)$ ]]; then
- # CIDR notation
- IPADDR=${BASH_REMATCH[1]}
- NETMASKLEN=${BASH_REMATCH[2]}
- PREFIX=$NETMASKLEN
- zeros=$((32 - NETMASKLEN))
- NETMASKNUM=0
- for ((i = 0; i < $zeros; i++)); do
- NETMASKNUM=$(((NETMASKNUM << 1) ^ 1))
- done
- NETMASKNUM=$((NETMASKNUM ^ 0xFFFFFFFF))
- toaddr $NETMASKNUM NETMASK
- else
- IPADDR=${1:-192.168.1.1}
- NETMASK=${2:-255.255.255.0}
- fi
+ if [[ $LINE =~ ^([0-9\.]+)/([0-9]+)$ ]]; then
+ # CIDR notation
+ IPADDR=${BASH_REMATCH[1]}
+ NETMASKLEN=${BASH_REMATCH[2]}
+ PREFIX=$NETMASKLEN
+ zeros=$((32 - NETMASKLEN))
+ NETMASKNUM=0
+ for ((i = 0; i < $zeros; i++)); do
+ NETMASKNUM=$(((NETMASKNUM << 1) ^ 1))
+ done
+ NETMASKNUM=$((NETMASKNUM ^ 0xFFFFFFFF))
+ toaddr $NETMASKNUM NETMASK
+ else
+ IPADDR=${1:-192.168.1.1}
+ NETMASK=${2:-255.255.255.0}
+ fi
- tonum $IPADDR IPADDRNUM
- tonum $NETMASK NETMASKNUM
+ tonum $IPADDR IPADDRNUM
+ tonum $NETMASK NETMASKNUM
- # The logic to calculate network and broadcast
- INVNETMASKNUM=$((0xFFFFFFFF ^ NETMASKNUM))
- NETWORKNUM=$((IPADDRNUM & NETMASKNUM))
- BROADCASTNUM=$((INVNETMASKNUM | NETWORKNUM))
+ # The logic to calculate network and broadcast
+ INVNETMASKNUM=$((0xFFFFFFFF ^ NETMASKNUM))
+ NETWORKNUM=$((IPADDRNUM & NETMASKNUM))
+ BROADCASTNUM=$((INVNETMASKNUM | NETWORKNUM))
- toaddr $NETWORKNUM NETWORK
- toaddr $BROADCASTNUM BROADCAST
+ toaddr $NETWORKNUM NETWORK
+ toaddr $BROADCASTNUM BROADCAST
- # Reverse engineer the subnet ID from the calcualted IP address and subnet prefix
- IFS=. read -r i1 i2 i3 i4 <<<"$IPADDR"
- IFS=. read -r m1 m2 m3 m4 <<<"$NETMASK"
+ # Reverse engineer the subnet ID from the calcualted IP address and subnet prefix
+ IFS=. read -r i1 i2 i3 i4 <<<"$IPADDR"
+ IFS=. read -r m1 m2 m3 m4 <<<"$NETMASK"
- # Lay out the subnet ID address as a variable
- printf -v NETADDR "%d.%d.%d.%d" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
+ # Lay out the subnet ID address as a variable
+ printf -v NETADDR "%d.%d.%d.%d" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
- #Dump out the calcualted subnet IDs to a file
- echo $NETADDR"/"$NETMASKLEN | tr '\n' ' ' | cat >>/tmp/netaddr.txt
+ #Dump out the calcualted subnet IDs to a file
+ echo $NETADDR"/"$NETMASKLEN | tr '\n' ' ' | cat >>/tmp/netaddr.txt
- done
+ done
fi
if [ "${FAIL2BAN_BASE}" = true ]; then
- # Now the above loop is done, append the single loopback address to all the discovered the subnet IDs in a single line
- sed -i 's/^/127.0.0.1\/24 /' /tmp/netaddr.txt
+ # Now the above loop is done, append the single loopback address to all the discovered the subnet IDs in a single line
+ sed -i 's/^/127.0.0.1\/24 /' /tmp/netaddr.txt
- # Finally assemble the entire syntax of the ignoreip whitelist for insertion into the base fail2ban config
- SED_IGNORE=$(echo "ignoreip = ")
- SED_NETADDR=$(cat /tmp/netaddr.txt)
- sed -i "s|ignoreip \=|${SED_IGNORE}${SED_NETADDR}|g" /tmp/fail2ban.conf
+ # Finally assemble the entire syntax of the ignoreip whitelist for insertion into the base fail2ban config
+ SED_IGNORE=$(echo "ignoreip = ")
+ SED_NETADDR=$(cat /tmp/netaddr.txt)
+ sed -i "s|ignoreip \=|${SED_IGNORE}${SED_NETADDR}|g" /tmp/fail2ban.conf
- # Move the new base fail2ban config to the jail.local file
- touch /etc/fail2ban/jail.local
+ # Move the new base fail2ban config to the jail.local file
+ touch /etc/fail2ban/jail.local
- # Apply the base config, keeping any pre-existing settings
- sudo bash -c 'cat /tmp/fail2ban.conf /etc/fail2ban/jail.local | unique /tmp/fail2ban.update ; cat /tmp/fail2ban.update > /etc/fail2ban/jail.local'
+ # Apply the base config, keeping any pre-existing settings
+ sudo bash -c 'cat /tmp/fail2ban.conf /etc/fail2ban/jail.local | unique /tmp/fail2ban.update ; cat /tmp/fail2ban.update > /etc/fail2ban/jail.local'
- # Clean up
- rm -f /tmp/fail2ban.conf
- rm -f /tmp/ip_list.txt
- rm -f /tmp/netaddr.txt
- rm -f /tmp/fail2ban.update
+ # Clean up
+ rm -f /tmp/fail2ban.conf
+ rm -f /tmp/ip_list.txt
+ rm -f /tmp/netaddr.txt
+ rm -f /tmp/fail2ban.update
- # bounce the service to reload the new config
- sudo systemctl restart fail2ban
+ # bounce the service to reload the new config
+ sudo systemctl restart fail2ban
- # Done
- echo
- echo -e "${LGREEN}Fail2ban installed...${GREY}"
- echo
+ # Done
+ echo
+ echo -e "${LGREEN}Fail2ban installed...${GREY}"
+ echo
else
- echo -e "${LGREEN}Fail2ban setup cancelled.${GREY}"
+ echo -e "${LGREEN}Fail2ban setup cancelled.${GREY}"
fi
@@ -210,8 +210,8 @@ fi
if [ "${FAIL2BAN_GUAC}" = true ]; then
-# Create the Guacamole jail.local policy template
-cat >/tmp/fail2ban.conf </tmp/fail2ban.conf < /etc/fail2ban/jail.local'
+ # Apply the new Guacamole jail config keeping any pre-existing settings
+ sudo bash -c 'cat /tmp/fail2ban.conf /etc/fail2ban/jail.local | unique /tmp/fail2ban.update ; cat /tmp/fail2ban.update > /etc/fail2ban/jail.local'
-# Backup the default Fail2ban Guacamole filter
-cp /etc/fail2ban/filter.d/guacamole.conf /etc/fail2ban/filter.d/guacamole.conf.bak
+ # Backup the default Fail2ban Guacamole filter
+ cp /etc/fail2ban/filter.d/guacamole.conf /etc/fail2ban/filter.d/guacamole.conf.bak
-# Remove the default log search regex
-sudo bash -c 'sed -e "/Authentication attempt from/ s/^#*/#/" -i /etc/fail2ban/filter.d/guacamole.conf'
+ # Remove the default log search regex
+ sudo bash -c 'sed -e "/Authentication attempt from/ s/^#*/#/" -i /etc/fail2ban/filter.d/guacamole.conf'
-# Create a new log search regex specific for tomcat logs (as a variable due to complexity of characters for sed syntax)
-REGEX='failregex = ^.*WARN o\.a\.g\.r\.auth\.AuthenticationService - Authentication attempt from for user "[^"]*" failed\.$'
-#Insert the new regex
-sed -i -e "/Authentication attempt from/a ${REGEX}" /etc/fail2ban/filter.d/guacamole.conf
+ # Create a new log search regex specific for tomcat logs (as a variable due to complexity of characters for sed syntax)
+ REGEX='failregex = ^.*WARN o\.a\.g\.r\.auth\.AuthenticationService - Authentication attempt from for user "[^"]*" failed\.$'
+ #Insert the new regex
+ sed -i -e "/Authentication attempt from/a ${REGEX}" /etc/fail2ban/filter.d/guacamole.conf
-# Done
-echo -e "${LGREEN}Guacamole security policy applied${GREY}\n- ${SED_NETADDR}are whitelisted from all IP bans.\n- To alter this whitelist, edit /etc/fail2ban/jail.local & sudo systemctl restart fail2ban \n \n This script may take a while to complete on first run..."
+ # Done
+ echo -e "${LGREEN}Guacamole security policy applied${GREY}\n- ${SED_NETADDR}are whitelisted from all IP bans.\n- To alter this whitelist, edit /etc/fail2ban/jail.local & sudo systemctl restart fail2ban \n \n This script may take a while to complete on first run..."
-# Bounce the service to reload the new config
-sudo systemctl restart fail2ban
-echo
+ # Bounce the service to reload the new config
+ sudo systemctl restart fail2ban
+ echo
fi
# Clean up
diff --git a/guac-optional-features/add-smtp-relay-o365.sh b/guac-optional-features/add-smtp-relay-o365.sh
index 4ce1fe1..477fd61 100644
--- a/guac-optional-features/add-smtp-relay-o365.sh
+++ b/guac-optional-features/add-smtp-relay-o365.sh
@@ -28,9 +28,9 @@ DOMAIN_SEARCH_SUFFIX=$(grep search /etc/resolv.conf | grep -v "#" | sed 's/'sear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
echo
@@ -42,10 +42,10 @@ echo -e "${GREY}Installing Postfix with non-interactive defaults..."
sudo apt update -qq >/dev/null 2>&1
DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo -e "${LRED}Postfix install failed. ${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Postfix install failed. ${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
+ echo -e "${LGREEN}OK${GREY}"
fi
# Get the Office365 smtp authentication credentials
@@ -80,11 +80,11 @@ smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
EOF
if [ $? -ne 0 ]; then
- echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
- echo
+ echo -e "${LGREEN}OK${GREY}"
+ echo
fi
# Setup the password file and postmap
@@ -111,10 +111,10 @@ sudo postmap /etc/postfix/generic
echo -e "${GREY}Restarting Postfix..."
sudo systemctl restart postfix
if [ $? -ne 0 ]; then
- echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2
- exit 1
+ echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2
+ exit 1
else
- echo -e "${LGREEN}OK${GREY}"
+ echo -e "${LGREEN}OK${GREY}"
fi
echo
diff --git a/guac-optional-features/add-tls-guac-daemon.sh b/guac-optional-features/add-tls-guac-daemon.sh
index 33fba84..9f06acc 100644
--- a/guac-optional-features/add-tls-guac-daemon.sh
+++ b/guac-optional-features/add-tls-guac-daemon.sh
@@ -20,9 +20,9 @@ NC='\033[0m' #No Colour
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)
@@ -97,7 +97,6 @@ chmod 644 /etc/guacamole/ssl/guacd.key
cd /etc/guacamole/ssl
keytool -importcert -alias guacd -noprompt -cacerts -storepass changeit -file guacd.crt
-
systemctl restart guacd
systemctl restart ${TOMCAT_VERSION}
diff --git a/guac-optional-features/add-xtra-histrecstor.sh b/guac-optional-features/add-xtra-histrecstor.sh
index 6b19ade..afebb17 100644
--- a/guac-optional-features/add-xtra-histrecstor.sh
+++ b/guac-optional-features/add-xtra-histrecstor.sh
@@ -19,9 +19,9 @@ clear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)
@@ -30,13 +30,13 @@ GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guac
HISTREC_PATH_DEFAULT=/var/lib/guacamole/recordings # Apache default
while true; do
- echo
- read -p "Enter recorded storage path [Enter for default ${HISTREC_PATH_DEFAULT}]: " HISTREC_PATH
- [ "${HISTREC_PATH}" = "" ] || [ "${HISTREC_PATH}" != "" ] && break
- done
- # If no custom path is given, lets assume the default path on hitting enter
- if [ -z "${HISTREC_PATH}" ]; then
- HISTREC_PATH="${HISTREC_PATH_DEFAULT}"
+ echo
+ read -p "Enter recorded storage path [Enter for default ${HISTREC_PATH_DEFAULT}]: " HISTREC_PATH
+ [ "${HISTREC_PATH}" = "" ] || [ "${HISTREC_PATH}" != "" ] && break
+done
+# If no custom path is given, lets assume the default path on hitting enter
+if [ -z "${HISTREC_PATH}" ]; then
+ HISTREC_PATH="${HISTREC_PATH_DEFAULT}"
fi
echo
diff --git a/guac-optional-features/add-xtra-quickconnect.sh b/guac-optional-features/add-xtra-quickconnect.sh
index a5d6aa7..0bcd2f7 100644
--- a/guac-optional-features/add-xtra-quickconnect.sh
+++ b/guac-optional-features/add-xtra-quickconnect.sh
@@ -19,9 +19,9 @@ clear
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then
- echo
- echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
- exit 1
+ echo
+ echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2
+ exit 1
fi
TOMCAT_VERSION=$(ls /etc/ | grep tomcat)