Skip to content

Commit 8c9e1f3

Browse files
committed
Revised 1.5.1
Installs Guac v1.5.1. All manual scripts scripts now customise with install variables at install. Backup SMTP working. Many tidy ups with flow and menus, clearer readme notes for further customisation and editing
1 parent 29b2a63 commit 8c9e1f3

12 files changed

+393
-279
lines changed

1-setup.sh

Lines changed: 169 additions & 131 deletions
Large diffs are not rendered by default.

2-install-guacamole.sh

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,36 @@
88
# pls see https://github.com/MysticRyuujin/guac-install for more
99
#######################################################################################################################
1010

11+
# Prepare text output colours
12+
GREY='\033[0;37m'
13+
DGREY='\033[0;90m'
14+
GREYB='\033[1;37m'
15+
RED='\033[0;31m'
16+
LRED='\033[0;91m'
17+
GREEN='\033[0;32m'
18+
LGREEN='\033[0;92m'
19+
YELLOW='\033[0;33m'
20+
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'
27+
NC='\033[0m' #No Colour
28+
1129
clear
1230

31+
#Script branding header
32+
echo
33+
echo -e "${GREYB}Itiligent Jump Server Appliance Setup."
34+
echo -e " ${LGREEN}Powered by Guacamole"
35+
36+
echo
37+
echo
38+
echo -e "Beginning Guacamole setup...${GREY}"
39+
echo
40+
1341
# Pre-seed MySQL install values
1442
if [ "${INSTALL_MYSQL}" = true ]; then
1543
debconf-set-selections <<< "mysql-server mysql-server/root_password password ${MYSQL_ROOT_PWD}"
@@ -26,11 +54,10 @@ if [ "${INSTALL_MYSQL}" = true ]; then
2654
fi
2755

2856
# Don't do annoying prompts during apt installs
29-
echo
3057
echo -e "${GREY}Updating base Linux OS..."
31-
export DEBIAN_FRONTEND=noninteractive &>> ${LOG_LOCATION}
32-
sudo apt-get update &>> ${LOG_LOCATION}
33-
sudo apt-get upgrade -y &>> ${LOG_LOCATION}
58+
export DEBIAN_FRONTEND=noninteractive
59+
sudo apt-get update -qq &>> ${LOG_LOCATION}
60+
sudo apt-get upgrade -qq -y &>> ${LOG_LOCATION}
3461
if [ $? -ne 0 ]; then
3562
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
3663
exit 1
@@ -41,10 +68,9 @@ fi
4168
# Install Guacamole build dependencies.
4269
echo
4370
echo -e "${GREY}Installing dependencies required for building Guacamole, this might take a few minutes..."
44-
apt-get -y install ${JPEGTURBO} ${LIBPNG} ufw htop pwgen wget crudini build-essential libcairo2-dev libtool-bin uuid-dev libavcodec-dev libavformat-dev libavutil-dev \
71+
apt-get -qq -y install ${JPEGTURBO} ${LIBPNG} ufw htop pwgen wget crudini build-essential libcairo2-dev libtool-bin uuid-dev libavcodec-dev libavformat-dev libavutil-dev \
4572
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev \
46-
libvorbis-dev libwebp-dev ghostscript \
47-
${MYSQL} ${TOMCAT_VERSION} &>> ${LOG_LOCATION}
73+
libvorbis-dev libwebp-dev ghostscript ${MYSQL} ${TOMCAT_VERSION} &>> ${LOG_LOCATION}
4874
if [ $? -ne 0 ]; then
4975
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
5076
exit 1
@@ -56,10 +82,10 @@ fi
5682
echo
5783
echo -e "${GREY}Setting up SMTP for backup alerts (requires SMTP relay be permitted from this server's IP address)..."
5884
echo "postfix postfix/mailname string ${EMAIL_DOMAIN} | debconf-set-selections" &>> ${LOG_LOCATION}
59-
DEBIAN_FRONTEND="noninteractive" apt-get install postfix -y &>> ${LOG_LOCATION}
60-
apt-get install mailutils -y &>> ${LOG_LOCATION}
61-
sed -i 's/inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf &>> ${LOG_LOCATION}
62-
service postfix restart &>> ${LOG_LOCATION}
85+
DEBIAN_FRONTEND="noninteractive" apt-get install postfix -qq -y &>> ${LOG_LOCATION}
86+
apt-get install mailutils -qq -y &>> ${LOG_LOCATION}
87+
sed -i 's/inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf
88+
service postfix restart
6389
if [ $? -ne 0 ]; then
6490
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
6591
exit 1
@@ -150,7 +176,6 @@ if [ $? -ne 0 ]; then
150176
fi
151177
echo -e "${LGREEN}Downloaded mysql-connector-java-${MYSQLJCON}.tar.gz${GREY}"
152178

153-
echo
154179
echo -e "${LGREEN}Source download complete.${GREY}"
155180

156181
# Option to pause script here as we might want to make final tweaks to source code just before compiling
@@ -181,7 +206,7 @@ echo -e "${GREY}Compiling Guacamole-Server from source with with GCC $( gcc --ve
181206
export CFLAGS="-Wno-error"
182207

183208
# Configure Guacamole Server source
184-
./configure --with-systemd-dir=/etc/systemd/system &>> ${LOG_LOCATION}
209+
./configure --with-systemd-dir=/etc/systemd/system &>> ${LOG_LOCATION}
185210
if [ $? -ne 0 ]; then
186211
echo "Failed to configure guacamole-server"
187212
echo "Trying again with --enable-allow-freerdp-snapshots"
@@ -227,7 +252,13 @@ ln -sf /etc/guacamole/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/
227252
# Move MySQL connector/j files
228253
echo -e "${GREY}Moving mysql-connector-java-${MYSQLJCON}.jar (/etc/guacamole/lib/mysql-connector-java.jar)..."
229254
mv -f mysql-connector-java-${MYSQLJCON}/mysql-connector-java-${MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar
230-
echo
255+
if [ $? -ne 0 ]; then
256+
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
257+
exit 1
258+
else
259+
echo -e "${LGREEN}OK${GREY}"
260+
echo
261+
fi
231262

232263
# Move TOTP files
233264
if [ "${INSTALL_TOTP}" = true ]; then
@@ -467,7 +498,6 @@ if [ $? -ne 0 ]; then
467498
exit 1
468499
else
469500
echo -e "${LGREEN}OK${GREY}"
470-
echo
471501
fi
472502

473503
# Done

3-install-nginx.sh

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,35 @@
77
# August 2023
88
#######################################################################################################################
99

10+
# Prepare text output colours
11+
GREY='\033[0;37m'
12+
DGREY='\033[0;90m'
13+
GREYB='\033[1;37m'
14+
RED='\033[0;31m'
15+
LRED='\033[0;91m'
16+
GREEN='\033[0;32m'
17+
LGREEN='\033[0;92m'
18+
YELLOW='\033[0;33m'
19+
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'
26+
NC='\033[0m' #No Colour
27+
28+
echo
29+
echo
30+
echo -e "${LGREEN}Installing Nginx...${DGREY}"
31+
echo
32+
1033
# Install Nginx
11-
sudo apt-get install nginx -y &>> ${LOG_LOCATION}
34+
sudo apt-get install nginx -qq -y &>> ${LOG_LOCATION}
1235

36+
echo -e "${GREY}Configuring Nginx as a proxy for Guacamole's Apache Tomcat front end...${DGREY}"
1337
# Configure /etc/nginx/sites-available/(local dns site name)
14-
cat >/etc/nginx/sites-available/$PROXY_SITE <<EOL
38+
cat <<EOF | tee /etc/nginx/sites-available/$PROXY_SITE
1539
server {
1640
listen 80 default_server;
1741
root /var/www/html;
@@ -27,10 +51,7 @@ server {
2751
access_log off;
2852
}
2953
}
30-
EOL
31-
32-
echo
33-
echo -e "${GREY}Configuring Nginx proxy to connect to Guacamole's Apache front end..."
54+
EOF
3455
if [ $? -ne 0 ]; then
3556
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
3657
exit 1
@@ -46,8 +67,9 @@ ln -s /etc/nginx/sites-available/$PROXY_SITE /etc/nginx/sites-enabled/
4667
unlink /etc/nginx/sites-enabled/default
4768

4869
# Do mandatory Nginx tweaks for logging actual client IPs through a proxy IP of 127.0.0.1 - DO NOT CHANGE COMMAND FORMATING!
70+
echo -e "${GREY}Configuring Apache Tomcat's valve to support for pass through of client IPs to Guacamole logs...${GREY}"
4971
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
50-
echo -e "${GREY}Configuring Apache Tomcat's internal proxy valve to support proxy client IP4 & IPv6 address passthough for correct logging and ACL support...${GREY}"
72+
5173
if [ $? -ne 0 ]; then
5274
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
5375
exit 1
@@ -85,13 +107,12 @@ fi
85107

86108
# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network.
87109
echo -e "${GREY}Updating firewall rules to allow only SSH and tcp 80/443..."
88-
sudo ufw default allow outgoing &>> ${LOG_LOCATION}
89-
sudo ufw default deny incoming &>> ${LOG_LOCATION}
90-
sudo ufw delete allow 8080/tcp &>> ${LOG_LOCATION}
91-
sudo ufw allow OpenSSH &>> ${LOG_LOCATION}
92-
sudo ufw allow 80/tcp &>> ${LOG_LOCATION}
93-
sudo ufw allow 443/tcp &>> ${LOG_LOCATION}
94-
echo "y" | sudo ufw enable &>> ${LOG_LOCATION}
110+
sudo ufw default allow outgoing > /dev/null 2>&1
111+
sudo ufw default deny incoming > /dev/null 2>&1
112+
sudo ufw allow OpenSSH > /dev/null 2>&1
113+
sudo ufw allow 80/tcp > /dev/null 2>&1
114+
sudo ufw allow 443/tcp > /dev/null 2>&1
115+
echo "y" | sudo ufw enable > /dev/null 2>&1
95116
if [ $? -ne 0 ]; then
96117
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
97118
exit 1
@@ -102,15 +123,14 @@ fi
102123

103124
# Reload everything
104125
echo -e "${GREY}Restaring Guacamole & Ngnix..."
105-
sudo systemctl restart $TOMCAT_VERSION &>> ${LOG_LOCATION}
106-
sudo systemctl restart guacd &>> ${LOG_LOCATION}
107-
sudo systemctl restart nginx &>> ${LOG_LOCATION}
126+
sudo systemctl restart $TOMCAT_VERSION
127+
sudo systemctl restart guacd
128+
sudo systemctl restart nginx
108129
if [ $? -ne 0 ]; then
109130
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
110131
exit 1
111132
else
112133
echo -e "${LGREEN}OK${GREY}"
113-
echo
114134
fi
115135

116136
# Done

4a-install-ssl-self-signed-nginx.sh

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,34 @@
1111
# to provide certifacate outputs correctly. Runing just as sudo will save certs to sudo's home path
1212
# sudo -E ./4a-install-ssl-self-signed-nginx.sh [your-dns-name.local] [3650]
1313

14+
# Prepare text output colours
15+
GREY='\033[0;37m'
16+
DGREY='\033[0;90m'
17+
GREYB='\033[1;37m'
18+
RED='\033[0;31m'
19+
LRED='\033[0;91m'
20+
GREEN='\033[0;32m'
21+
LGREEN='\033[0;92m'
22+
YELLOW='\033[0;33m'
23+
LYELLOW='\033[0;93m'
24+
BLUE='\033[0;34m'
25+
LBLUE='\033[0;94m'
26+
CYAN='\033[0;36m'
27+
LCYAN='\033[0;96m'
28+
MAGENTA='\033[0;35m'
29+
LMAGENTA='\033[0;95m'
30+
NC='\033[0m' #No Colour
31+
32+
echo
33+
echo
34+
echo -e "${LGREEN}Setting up self signed SSL certificates for Nginx...${GREY}"
35+
echo
36+
1437
# Hack to assist with displaying "$" symbols and " ' quotes in a (cut/pasteable) bash screen output format for Nginx configs
1538
SHOWASTEXT1='$mypwd'
1639
SHOWASTEXT2='"Cert:\LocalMachine\Root"'
1740

1841
# Discover all IPv4 interfaces addresses to bind to new SSL certficates
19-
echo
2042
echo -e "${GREY}Discovering the default route interface and DNS names to bind with the new SSL certificate..."
2143
# Dump interface info and copy this output to a temp file
2244
DUMP_IPS=$(ip -o addr show up primary scope global | while read -r num dev fam addr rest; do echo ${addr%/*}; done)
@@ -38,14 +60,11 @@ if [ $? -ne 0 ]; then
3860
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
3961
exit 1
4062
else
41-
echo -e "${GREEN}OK${GREY}"
63+
echo -e "${LGREEN}OK${GREY}"
4264
echo
4365
fi
4466
45-
echo
46-
echo -e "${GREY}New self signed SSL certificate attributes are shown below...${GREY}"
47-
echo -e "${DGREY}"
48-
67+
echo -e "${GREY}New self signed SSL certificate attributes are shown below...${DGREY}"
4968
# Display the new SSL cert parameters. Prompt for change if required
5069
cat <<EOF | tee -a $TMP_DIR/cert_attributes.txt
5170
[req]
@@ -86,13 +105,6 @@ DIR_SSL_KEY="/etc/nginx/ssl/private"
86105
SSLNAME=$1
87106
SSLDAYS=$2
88107
89-
if [[ $SSLDAYS == "" ]]; then
90-
$SSLDAYS = 3650
91-
fi
92-
93-
echo "Creating a new Certificate ..."
94-
openssl req -x509 -nodes -newkey rsa:2048 -keyout $SSLNAME.key -out $SSLNAME.crt -days $SSLDAYS -config $TMP_DIR/cert_attributes.txt
95-
96108
# Make directories to place SSL Certificate if they don't exist
97109
if [[ ! -d $DIR_SSL_KEY ]]; then
98110
sudo mkdir -p $DIR_SSL_KEY
@@ -102,19 +114,34 @@ if [[ ! -d $DIR_SSL_CERT ]]; then
102114
sudo mkdir -p $DIR_SSL_CERT
103115
fi
104116
117+
if [[ $SSLDAYS == "" ]]; then
118+
$SSLDAYS = 3650
119+
fi
120+
121+
echo
122+
echo "{$GREY}Creating a new Nginx SSL Certificate ..."
123+
openssl req -x509 -nodes -newkey rsa:2048 -keyout $SSLNAME.key -out $SSLNAME.crt -days $SSLDAYS -config $TMP_DIR/cert_attributes.txt
124+
if [ $? -ne 0 ]; then
125+
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
126+
exit 1
127+
else
128+
echo -e "${LGREEN}OK${GREY}"
129+
echo
130+
fi
131+
105132
# Place SSL Certificate within defined path
106133
sudo cp $SSLNAME.key $DIR_SSL_KEY/$SSLNAME.key
107134
sudo cp $SSLNAME.crt $DIR_SSL_CERT/$SSLNAME.crt
108135
109136
# Create a PFX formatted key for easier import to Windows hosts and change permissions to enable copying elsewhere
137+
echo -e "${GREY}Creating client certificates for Windows & Linux...${GREY}"
110138
sudo openssl pkcs12 -export -out $SSLNAME.pfx -inkey $SSLNAME.key -in $SSLNAME.crt -password pass:1234
111139
sudo chmod 0774 $SSLNAME.pfx
112-
echo -e "${GREY}Creating a selection of self signed certificates for Nginx and Windows/Linux browser clients...${GREY}"
113140
if [ $? -ne 0 ]; then
114141
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
115142
exit 1
116143
else
117-
echo -e "${GREEN}OK${GREY}"
144+
echo -e "${LGREEN}OK${GREY}"
118145
echo
119146
fi
120147
@@ -125,12 +152,14 @@ if [ $? -ne 0 ]; then
125152
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
126153
exit 1
127154
else
128-
echo -e "${GREEN}OK${GREY}"
155+
echo -e "${LGREEN}OK${GREY}"
129156
echo
130157
fi
131158
132159
# Update Nginx config to accept the new certificates
133-
cat > /etc/nginx/sites-available/$PROXY_SITE <<EOL | > /dev/null
160+
echo -e "${GREY}Configuring Nginx proxy to use self signed SSL certificates and setting up automatic HTTP to HTTPS redirect...${DGREY}"
161+
#cat > /etc/nginx/sites-available/$PROXY_SITE <<EOL | > /dev/null
162+
cat <<EOF | tee /etc/nginx/sites-available/$PROXY_SITE
134163
server {
135164
#listen 80 default_server;
136165
root /var/www/html;
@@ -167,31 +196,30 @@ server {
167196
access_log off;
168197
}
169198
}
170-
EOL
171-
172-
echo -e "${GREY}Configuring Nginx proxy to use self signed SSL certificates and setting up automatic HTTP to HTTPS redirect...${GREY}"
199+
EOF
173200
if [ $? -ne 0 ]; then
174201
echo -e "${RED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
175202
exit 1
176203
else
177-
echo -e "${GREEN}OK${GREY}"
204+
echo -e "${LGREEN}OK${GREY}"
178205
echo
179206
fi
180207
208+
181209
printf "${GREY}+-------------------------------------------------------------------------------------------------------------
182-
${GREEN}+ WINDOWS CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY}
210+
${LGREEN}+ WINDOWS CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY}
183211
+
184-
+ 1. In ${DOWNLOAD_DIR} is a Windows friendly version of the new certificate ${LYELLOW}$SSLNAME.pfx${GREY}
212+
+ 1. In ${DOWNLOAD_DIR} is a new Windows friendly version of the new certificate ${LYELLOW}$SSLNAME.pfx${GREY}
185213
+ 2. Copy this .pfx file to a location accessible by Windows.
186-
+ 3. Import the PFX file into your Windows client with the below Powershell commands (as administrator):
214+
+ 3. Import the PFX file into your Windows client with the below Powershell commands (as Administrator):
187215
\n"
188216
echo -e "${SHOWASTEXT1} = ConvertTo-SecureString -String "1234" -Force -AsPlainText"
189217
echo -e "Import-pfxCertificate -FilePath $SSLNAME.pfx -Password "${SHOWASTEXT1}" -CertStoreLocation "${SHOWASTEXT2}""
190218
echo -e "(Clear your browser cache and restart your browser to test.)"
191219
printf "${GREY}+-------------------------------------------------------------------------------------------------------------
192-
${GREEN}+ LINUX CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY}
220+
${LGREEN}+ LINUX CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY}
193221
+
194-
+ 1. In In ${DOWNLOAD_DIR} is also the Linux native OpenSSL certificate ${LYELLOW}$SSLNAME.crt${GREY}
222+
+ 1. In ${DOWNLOAD_DIR} is a new Linux native OpenSSL certificate ${LYELLOW}$SSLNAME.crt${GREY}
195223
+ 2. Copy this file to a location accessible by Linux.
196224
+ 3. Import the CRT file into your Linux client certificate store with the below command (as sudo):
197225
\n"
@@ -212,7 +240,6 @@ if [ $? -ne 0 ]; then
212240
exit 1
213241
else
214242
echo -e "${LGREEN}OK${GREY}"
215-
echo
216243
fi
217244
218245
# Done

0 commit comments

Comments
 (0)