Skip to content

Commit 5032e5b

Browse files
committed
v1.5.1.2
add scripts improved, backup gaucd before nginx, standalone install of ssl for existing nginx, allow space in sql passwords, added upgrade script, improved tomcat self detection, simplified how SSL scrips detect local settings, many tidy ups
1 parent 6d27072 commit 5032e5b

13 files changed

+612
-287
lines changed

1-setup.sh

Lines changed: 117 additions & 102 deletions
Large diffs are not rendered by default.

2-install-guacamole.sh

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,10 @@
1212
GREY='\033[0;37m'
1313
DGREY='\033[0;90m'
1414
GREYB='\033[1;37m'
15-
RED='\033[0;31m'
1615
LRED='\033[0;91m'
17-
GREEN='\033[0;32m'
1816
LGREEN='\033[0;92m'
19-
YELLOW='\033[0;33m'
2017
LYELLOW='\033[0;93m'
21-
BLUE='\033[0;34m'
22-
LBLUE='\033[0;94m'
23-
CYAN='\033[0;36m'
24-
LCYAN='\033[0;96m'
25-
MAGENTA='\033[0;35m'
26-
LMAGENTA='\033[0;95m'
2718
NC='\033[0m' #No Colour
28-
2919
clear
3020

3121
#Script branding header
@@ -59,7 +49,7 @@ export DEBIAN_FRONTEND=noninteractive
5949
sudo apt-get update -qq &>> ${LOG_LOCATION}
6050
sudo apt-get upgrade -qq -y &>> ${LOG_LOCATION}
6151
if [ $? -ne 0 ]; then
62-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
52+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
6353
exit 1
6454
else
6555
echo -e "${LGREEN}OK${GREY}"
@@ -72,18 +62,18 @@ apt-get -qq -y install ${JPEGTURBO} ${LIBPNG} ufw htop pwgen wget crudini build-
7262
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev \
7363
libvorbis-dev libwebp-dev ghostscript ${MYSQL} ${TOMCAT_VERSION} &>> ${LOG_LOCATION}
7464
if [ $? -ne 0 ]; then
75-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
65+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
7666
exit 1
7767
else
7868
echo -e "${LGREEN}OK${GREY}"
7969
fi
8070

8171
# Install Postfix with default settings for smtp email relay
8272
echo
83-
echo -e "${GREY}Installing SMTP email for backup email notifications, for SMTP realy with Office365, see separate configuration script..."
73+
echo -e "${GREY}Installing SMTP email for backup email notifications, see separate SMTP relay configuration script..."
8474
DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y &>> ${LOG_LOCATION}
8575
if [ $? -ne 0 ]; then
86-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
76+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
8777
exit 1
8878
else
8979
echo -e "${LGREEN}OK${GREY}"
@@ -95,7 +85,7 @@ echo
9585
echo -e "${GREY}Downloading Guacamole source files..."
9686
wget -q --show-progress -O guacamole-server-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz
9787
if [ $? -ne 0 ]; then
98-
echo -e "${RED}Failed to download guacamole-server-${GUAC_VERSION}.tar.gz" 1>&2
88+
echo -e "${LRED}Failed to download guacamole-server-${GUAC_VERSION}.tar.gz" 1>&2
9989
echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
10090
exit 1
10191
else
@@ -106,7 +96,7 @@ echo -e "${LGREEN}Downloaded guacamole-server-${GUAC_VERSION}.tar.gz${GREY}"
10696
# Download Guacamole Client
10797
wget -q --show-progress -O guacamole-${GUAC_VERSION}.war ${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war
10898
if [ $? -ne 0 ]; then
109-
echo -e "${RED}Failed to download guacamole-${GUAC_VERSION}.war" 1>&2
99+
echo -e "${LRED}Failed to download guacamole-${GUAC_VERSION}.war" 1>&2
110100
echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war${GREY}"
111101
exit 1
112102
fi
@@ -115,7 +105,7 @@ echo -e "${LGREEN}Downloaded guacamole-${GUAC_VERSION}.war${GREY}"
115105
# Download Guacamole authentication extensions
116106
wget -q --show-progress -O guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz
117107
if [ $? -ne 0 ]; then
118-
echo -e "${RED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
108+
echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2
119109
echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz"
120110
exit 1
121111
else
@@ -127,7 +117,7 @@ echo -e "${LGREEN}Downloaded guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz${GREY}"
127117
if [ "${INSTALL_TOTP}" = true ]; then
128118
wget -q --show-progress -O guacamole-auth-totp-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz
129119
if [ $? -ne 0 ]; then
130-
echo -e "${RED}Failed to download guacamole-auth-totp-${GUAC_VERSION}.tar.gz" 1>&2
120+
echo -e "${LRED}Failed to download guacamole-auth-totp-${GUAC_VERSION}.tar.gz" 1>&2
131121
echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz"
132122
exit 1
133123
else
@@ -140,7 +130,7 @@ fi
140130
if [ "${INSTALL_DUO}" = true ]; then
141131
wget -q --show-progress -O guacamole-auth-duo-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz
142132
if [ $? -ne 0 ]; then
143-
echo -e "${RED}Failed to download guacamole-auth-duo-${GUAC_VERSION}.tar.gz" 1>&2
133+
echo -e "${LRED}Failed to download guacamole-auth-duo-${GUAC_VERSION}.tar.gz" 1>&2
144134
echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz"
145135
exit 1
146136
else
@@ -153,7 +143,7 @@ fi
153143
if [ "${INSTALL_LDAP}" = true ]; then
154144
wget -q --show-progress -O guacamole-auth-ldap-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz
155145
if [ $? -ne 0 ]; then
156-
echo -e "${RED}Failed to download guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" 1>&2
146+
echo -e "${LRED}Failed to download guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" 1>&2
157147
echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz"
158148
exit 1
159149
else
@@ -165,7 +155,7 @@ fi
165155
# Download MySQL connector/j
166156
wget -q --show-progress -O mysql-connector-java-${MYSQLJCON}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MYSQLJCON}.tar.gz
167157
if [ $? -ne 0 ]; then
168-
echo -e "${RED}Failed to download mysql-connector-java-${MYSQLJCON}.tar.gz" 1>&2
158+
echo -e "${LRED}Failed to download mysql-connector-java-${MYSQLJCON}.tar.gz" 1>&2
169159
echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MYSQLJCON}}.tar.gz${GREY}"
170160
exit 1
171161
else
@@ -220,7 +210,7 @@ fi
220210
echo -e "${GREY}Running Make and building the Guacamole-Server application..."
221211
make &>> ${LOG_LOCATION}
222212
if [ $? -ne 0 ]; then
223-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
213+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
224214
exit 1
225215
else
226216
echo -e "${LGREEN}OK${GREY}"
@@ -230,7 +220,7 @@ fi
230220
echo -e "${GREY}Installing Guacamole-Server..."
231221
make install &>> ${LOG_LOCATION}
232222
if [ $? -ne 0 ]; then
233-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
223+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
234224
exit 1
235225
else
236226
echo -e "${LGREEN}OK${GREY}"
@@ -250,7 +240,7 @@ ln -sf /etc/guacamole/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/
250240
echo -e "${GREY}Moving mysql-connector-java-${MYSQLJCON}.jar (/etc/guacamole/lib/mysql-connector-java.jar)..."
251241
mv -f mysql-connector-java-${MYSQLJCON}/mysql-connector-java-${MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
252242
if [ $? -ne 0 ]; then
253-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
243+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
254244
exit 1
255245
else
256246
echo -e "${LGREEN}OK${GREY}"
@@ -296,11 +286,11 @@ if [ "${INSTALL_DUO}" = true ]; then
296286
echo -e "${YELLOW}Duo is installed, it will need to be configured via guacamole.properties${GREY}"
297287
fi
298288

299-
echo -e "${GREY}Applying branded Guacamole login page and favicons."
289+
echo -e "${GREY}Applying branded Guacamole login page and favicons..."
300290
# For details on how to brand Guacamole, see https://github.com/Zer0CoolX/guacamole-customize-loginscreen-extension
301291
sudo mv branding.jar /etc/guacamole/extensions
302292
if [ $? -ne 0 ]; then
303-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
293+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
304294
exit 1
305295
else
306296
echo -e "${LGREEN}OK${GREY}"
@@ -311,7 +301,7 @@ fi
311301
echo -e "${GREY}Restarting Tomcat service & enable at boot..."
312302
service ${TOMCAT_VERSION} restart
313303
if [ $? -ne 0 ]; then
314-
echo -e "${RED}Failed${GREY}" 1>&2
304+
echo -e "${LRED}Failed${GREY}" 1>&2
315305
exit 1
316306
else
317307
echo -e "${LGREEN}OK${GREY}"
@@ -329,7 +319,7 @@ if [ "${INSTALL_MYSQL}" = true ]; then
329319
service mysql restart
330320
fi
331321
if [ $? -ne 0 ]; then
332-
echo -e "${RED}Failed${GREY}" 1>&2
322+
echo -e "${LRED}Failed${GREY}" 1>&2
333323
exit 1
334324
else
335325
echo -e "${LGREEN}OK${GREY}"
@@ -375,7 +365,7 @@ fi
375365
fi
376366
fi
377367
if [ $? -ne 0 ]; then
378-
echo -e "${RED}Failed${GREY}" 1>&2
368+
echo -e "${LRED}Failed${GREY}" 1>&2
379369
exit 1
380370
else
381371
echo -e "${LGREEN}OK${GREY}"
@@ -398,8 +388,8 @@ SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='${GUAC_DB
398388
# Execute SQL code
399389
MYSQL_RESULT=$( echo ${SQLCODE} | mysql -u root -D information_schema -h ${MYSQL_HOST} -P ${MYSQL_PORT} )
400390
if [[ $MYSQL_RESULT != "" ]]; then
401-
echo -e "${RED}It appears there is already a MySQL database (${GUAC_DB}) on ${MYSQL_HOST}${GREY}" 1>&2
402-
echo -e "${RED}Try: mysql -e 'DROP DATABASE ${GUAC_DB}'${GREY}" 1>&2
391+
echo -e "${LRED}It appears there is already a MySQL database (${GUAC_DB}) on ${MYSQL_HOST}${GREY}" 1>&2
392+
echo -e "${LRED}Try: mysql -e 'DROP DATABASE ${GUAC_DB}'${GREY}" 1>&2
403393
#exit 1
404394
else
405395
echo -e "${LGREEN}OK${GREY}"
@@ -414,8 +404,8 @@ SELECT COUNT(*) FROM mysql.user WHERE user = '${GUAC_USER}';"
414404
# Execute SQL code
415405
MYSQL_RESULT=$( echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} | grep '0' )
416406
if [[ $MYSQL_RESULT == "" ]]; then
417-
echo -e "${RED}It appears there is already a MySQL user (${GUAC_USER}) on ${MYSQL_HOST}${GREY}" 1>&2
418-
echo -e "${RED}Try: mysql -e \"DROP USER '${GUAC_USER}'@'${GUAC_USERHost}'; FLUSH PRIVILEGES;\"${GREY}" 1>&2
407+
echo -e "${LRED}It appears there is already a MySQL user (${GUAC_USER}) on ${MYSQL_HOST}${GREY}" 1>&2
408+
echo -e "${LRED}Try: mysql -e \"DROP USER '${GUAC_USER}'@'${GUAC_USERHost}'; FLUSH PRIVILEGES;\"${GREY}" 1>&2
419409
#exit 1
420410
else
421411
echo -e "${LGREEN}OK${GREY}"
@@ -437,7 +427,7 @@ echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT}
437427
echo -e "${GREY}Adding database tables..."
438428
cat guacamole-auth-jdbc-${GUAC_VERSION}/mysql/schema/*.sql | mysql -u root -D ${GUAC_DB} -h ${MYSQL_HOST} -P ${MYSQL_PORT}
439429
if [ $? -ne 0 ]; then
440-
echo -e "${RED}Failed${GREY}" 1>&2
430+
echo -e "${LRED}Failed${GREY}" 1>&2
441431
exit 1
442432
else
443433
echo -e "${LGREEN}OK${GREY}"
@@ -452,7 +442,7 @@ bind_host = 0.0.0.0
452442
bind_port = 4822
453443
EOF
454444
if [ $? -ne 0 ]; then
455-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
445+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
456446
exit 1
457447
else
458448
echo -e "${LGREEN}OK${GREY}"
@@ -465,7 +455,7 @@ systemctl enable guacd
465455
service guacd stop 2>/dev/null
466456
service guacd start
467457
if [ $? -ne 0 ]; then
468-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
458+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
469459
exit 1
470460
else
471461
echo -e "${LGREEN}OK${GREY}"
@@ -478,7 +468,7 @@ rm -rf guacamole-*
478468
rm -rf mysql-connector-java-*
479469
unset MYSQL_PWD
480470
if [ $? -ne 0 ]; then
481-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
471+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
482472
exit 1
483473
else
484474
echo -e "${LGREEN}OK${GREY}"
@@ -488,10 +478,10 @@ fi
488478
# Apply Secure MySQL installation settings
489479
if [ "${SECURE_MYSQL}" = true ]; then
490480
echo -e "${GREY}Applying mysql_secure_installation settings...${GREY}"
491-
printf "${MYSQL_ROOT_PWD}\n n\n n\n y\n y\n y\n y\n y\n" | mysql_secure_installation -u root --password="${MYSQL_ROOT_PWD}" &>> ${LOG_LOCATION}
481+
printf "${MYSQL_ROOT_PWD}\n n\n n\n y\n y\n y\n y\n y\n" | sudo mysql_secure_installation &>> ${LOG_LOCATION}
492482
fi
493483
if [ $? -ne 0 ]; then
494-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
484+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
495485
exit 1
496486
else
497487
echo -e "${LGREEN}OK${GREY}"

3-install-nginx.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@
1111
GREY='\033[0;37m'
1212
DGREY='\033[0;90m'
1313
GREYB='\033[1;37m'
14-
RED='\033[0;31m'
1514
LRED='\033[0;91m'
16-
GREEN='\033[0;32m'
1715
LGREEN='\033[0;92m'
18-
YELLOW='\033[0;33m'
1916
LYELLOW='\033[0;93m'
20-
BLUE='\033[0;34m'
21-
LBLUE='\033[0;94m'
22-
CYAN='\033[0;36m'
23-
LCYAN='\033[0;96m'
24-
MAGENTA='\033[0;35m'
25-
LMAGENTA='\033[0;95m'
2617
NC='\033[0m' #No Colour
2718

2819
echo
@@ -53,7 +44,7 @@ server {
5344
}
5445
EOF
5546
if [ $? -ne 0 ]; then
56-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
47+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
5748
exit 1
5849
else
5950
echo -e "${LGREEN}OK${GREY}"
@@ -70,7 +61,7 @@ unlink /etc/nginx/sites-enabled/default
7061
echo -e "${GREY}Configuring Apache Tomcat valve for pass through of client IPs to Guacamole logs...${GREY}"
7162
sudo sed -i '/pattern="%h %l %u %t &quot;%r&quot; %s %b"/a \ <!-- Allow host IP to pass through to guacamole.-->\n <Valve className="org.apache.catalina.valves.RemoteIpValve"\n internalProxies="127\.0\.0\.1|0:0:0:0:0:0:0:1"\n remoteIpHeader="x-forwarded-for"\n remoteIpProxiesHeader="x-forwarded-by"\n protocolHeader="x-forwarded-proto" />' /etc/$TOMCAT_VERSION/server.xml
7263
if [ $? -ne 0 ]; then
73-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
64+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
7465
exit 1
7566
else
7667
echo -e "${LGREEN}OK${GREY}"
@@ -82,7 +73,7 @@ sudo sed -i '/client_max_body_size/d' /etc/nginx/nginx.conf # remove this line i
8273
sudo sed -i "/Basic Settings/a \ client_max_body_size 100000000M;" /etc/nginx/nginx.conf # Add the larger file transfer size
8374
echo -e "${GREY}Boosting Nginx's 'maximum body size' parameter to support file transfers > 100 TB through the proxy...${GREY}"
8475
if [ $? -ne 0 ]; then
85-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
76+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
8677
exit 1
8778
else
8879
echo -e "${LGREEN}OK${GREY}"
@@ -91,13 +82,14 @@ fi
9182

9283
# Bind guacd to localhost and force all Guacamole connections via reverse proxy
9384
echo -e "${GREY}Binding guacd to 127.0.0.1 port 4822..."
85+
cp /etc/guacamole/guacd.conf /etc/guacamole/guacd.conf.bak
9486
cat > /etc/guacamole/guacd.conf <<- "EOF"
9587
[server]
9688
bind_host = 127.0.0.1
9789
bind_port = 4822
9890
EOF
9991
if [ $? -ne 0 ]; then
100-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
92+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
10193
exit 1
10294
else
10395
echo -e "${LGREEN}OK${GREY}"
@@ -113,7 +105,7 @@ sudo ufw allow 80/tcp > /dev/null 2>&1
113105
sudo ufw allow 443/tcp > /dev/null 2>&1
114106
echo "y" | sudo ufw enable > /dev/null 2>&1
115107
if [ $? -ne 0 ]; then
116-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
108+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
117109
exit 1
118110
else
119111
echo -e "${LGREEN}OK${GREY}"
@@ -126,7 +118,7 @@ sudo systemctl restart $TOMCAT_VERSION
126118
sudo systemctl restart guacd
127119
sudo systemctl restart nginx
128120
if [ $? -ne 0 ]; then
129-
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
121+
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
130122
exit 1
131123
else
132124
echo -e "${LGREEN}OK${GREY}"

0 commit comments

Comments
 (0)