mirror of
https://github.com/MysticRyuujin/guac-install.git
synced 2023-10-10 13:36:56 +02:00
Improve stability (#116)
I don't have time to test all of this lol but it appears to be in order...and much appreciated.
This commit is contained in:
parent
4be76a7777
commit
4ce4410dec
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if user is root or sudo
|
||||||
|
if ! [ $(id -u) = 0 ]; then echo "Please run this script as sudo or root"; exit 1 ; fi
|
||||||
|
|
||||||
# Version number of Guacamole to install
|
# Version number of Guacamole to install
|
||||||
GUACVERSION="1.1.0"
|
GUACVERSION="1.1.0"
|
||||||
|
|
||||||
@ -23,7 +26,7 @@ if [ -n "$mysqlpwd" ] && [ -n "$guacpwd" ]; then
|
|||||||
mysqlrootpassword=$mysqlpwd
|
mysqlrootpassword=$mysqlpwd
|
||||||
guacdbuserpassword=$guacpwd
|
guacdbuserpassword=$guacpwd
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -s -p "Enter a MySQL ROOT Password: " mysqlrootpassword
|
read -s -p "Enter a MySQL ROOT Password: " mysqlrootpassword
|
||||||
@ -48,7 +51,7 @@ else
|
|||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Install Stuff
|
# Install Stuff
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install docker-ce mysql-client wget
|
apt-get -y install docker-ce mysql-client wget
|
||||||
|
|
||||||
@ -75,9 +78,9 @@ sleep 30
|
|||||||
# Create the Guacamole database and the user account
|
# Create the Guacamole database and the user account
|
||||||
# SQL Code
|
# SQL Code
|
||||||
SQLCODE="
|
SQLCODE="
|
||||||
create database guacamole_db;
|
create database guacamole_db;
|
||||||
create user 'guacamole_user'@'%' identified by '$guacdbuserpassword';
|
create user 'guacamole_user'@'%' identified by '$guacdbuserpassword';
|
||||||
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'%';
|
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'%';
|
||||||
flush privileges;"
|
flush privileges;"
|
||||||
|
|
||||||
# Execute SQL Code
|
# Execute SQL Code
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if user is root or sudo
|
||||||
|
if ! [ $(id -u) = 0 ]; then echo "Please run this script as sudo or root"; exit 1 ; fi
|
||||||
|
|
||||||
# Version number of Guacamole to install
|
# Version number of Guacamole to install
|
||||||
GUACVERSION="1.1.0"
|
GUACVERSION="1.1.0"
|
||||||
|
|
||||||
# Ubuntu and Debian have different names of the libjpeg-turbo library for some reason...
|
# Different version of Ubuntu and Debian have different package names...
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
if [[ "${NAME}" == "Ubuntu" ]]
|
if [[ "${NAME}" == "Ubuntu" ]]; then
|
||||||
then
|
# Ubuntu > 18.04 does not include universe repo by default
|
||||||
|
# Add the "Universe" repo, don't update
|
||||||
|
add-apt-repository -yn universe
|
||||||
|
# Set package names depending on version
|
||||||
JPEGTURBO="libjpeg-turbo8-dev"
|
JPEGTURBO="libjpeg-turbo8-dev"
|
||||||
if [[ "${VERSION_ID}" == "16.04" ]]
|
if [[ "${VERSION_ID}" == "16.04" ]]
|
||||||
then
|
then
|
||||||
@ -14,30 +20,28 @@ then
|
|||||||
else
|
else
|
||||||
LIBPNG="libpng-dev"
|
LIBPNG="libpng-dev"
|
||||||
fi
|
fi
|
||||||
elif [[ "${NAME}" == *"Debian"* ]]
|
elif [[ "${NAME}" == *"Debian"* ]] || [[ "${NAME}" == *"Raspbian GNU/Linux"* ]] || [[ "${NAME}" == *"Kali GNU/Linux"* ]]; then
|
||||||
then
|
|
||||||
JPEGTURBO="libjpeg62-turbo-dev"
|
JPEGTURBO="libjpeg62-turbo-dev"
|
||||||
if [[ "${PRETTY_NAME}" == *"stretch"* ]]
|
if [[ "${PRETTY_NAME}" == *"stretch"* ]] || [[ "${PRETTY_NAME}" == *"buster"* ]] || [[ "${PRETTY_NAME}" == *"Kali GNU/Linux Rolling"* ]]; then
|
||||||
then
|
|
||||||
LIBPNG="libpng-dev"
|
LIBPNG="libpng-dev"
|
||||||
else
|
else
|
||||||
LIBPNG="libpng12-dev"
|
LIBPNG="libpng12-dev"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Unsupported Distro - Ubuntu or Debian Only"
|
echo "Unsupported Distro - Ubuntu, Debian, Kali or Raspbian Only"
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Server Features
|
# Install Server Features
|
||||||
apt update
|
apt-get -qq update
|
||||||
apt -y install build-essential libcairo2-dev ${JPEGTURBO} ${LIBPNG} libossp-uuid-dev libavcodec-dev libavutil-dev \
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get -y install build-essential libcairo2-dev ${JPEGTURBO} ${LIBPNG} libossp-uuid-dev libavcodec-dev libavutil-dev \
|
||||||
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libpulse-dev libssl-dev \
|
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libpulse-dev libssl-dev \
|
||||||
libvorbis-dev libwebp-dev jq curl wget libtool-bin libwebsockets-dev
|
libvorbis-dev libwebp-dev libwebsockets-dev wget libtool-bin
|
||||||
|
|
||||||
# If apt fails to run completely the rest of this isn't going to work...
|
# If apt fails to run completely the rest of this isn't going to work...
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]; then
|
||||||
then
|
echo "apt-get failed to install all required dependencies."
|
||||||
echo "apt failed to install all required dependencies."
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -50,15 +54,15 @@ if [ $? -ne 0 ]; then
|
|||||||
echo "Failed to download guacamole-server-${GUACVERSION}.tar.gz"
|
echo "Failed to download guacamole-server-${GUACVERSION}.tar.gz"
|
||||||
echo "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz"
|
echo "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz"
|
||||||
exit
|
exit
|
||||||
|
else
|
||||||
|
# Extract Guacamole Files
|
||||||
|
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract Guacamole Files
|
|
||||||
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
|
|
||||||
|
|
||||||
# Make Directories
|
# Make Directories
|
||||||
mkdir /etc/guacamole
|
mkdir -p /etc/guacamole
|
||||||
|
|
||||||
# Install guacd
|
# Install guacd (Guacamole-server)
|
||||||
cd guacamole-server-${GUACVERSION}
|
cd guacamole-server-${GUACVERSION}
|
||||||
./configure --with-init-dir=/etc/init.d
|
./configure --with-init-dir=/etc/init.d
|
||||||
make
|
make
|
||||||
@ -73,8 +77,8 @@ echo "bind_host = 0.0.0.0" >> /etc/guacamole/guacd.conf
|
|||||||
echo "bind_port = 4822" >> /etc/guacamole/guacd.conf
|
echo "bind_port = 4822" >> /etc/guacamole/guacd.conf
|
||||||
|
|
||||||
# Configure startup
|
# Configure startup
|
||||||
systemctl enable guacd
|
|
||||||
systemctl start guacd
|
systemctl start guacd
|
||||||
|
systemctl enable guacd
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -rf guacamole-*
|
rm -rf guacamole-*
|
||||||
|
198
guac-install.sh
198
guac-install.sh
@ -83,17 +83,11 @@ while [ "$1" != "" ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# We can't install TOTP and Duo at the same time...
|
if [[ -z "$installTOTP" ]] && [[ "$installDuo" != true ]]; then
|
||||||
if [[ ! -z $installTOTP ]] && [[ ! -z $installDuo ]]; then
|
|
||||||
echo "${RED}The script does not support installing TOTP and Duo at the same time.${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $installTOTP ]] && [[ -z $installDuo ]]; then
|
|
||||||
# Prompt the user if they would like to install TOTP MFA, default of no
|
# Prompt the user if they would like to install TOTP MFA, default of no
|
||||||
echo -e -n "${CYAN}Would you like to install TOTP? (y/N): ${NC}"
|
echo -e -n "${CYAN}MFA: Would you like to install TOTP? (y/N): ${NC}"
|
||||||
read PROMPT
|
read PROMPT
|
||||||
if [[ $PROMPT =~ ^[Yy]$ ]]; then
|
if [[ $PROMPT =~ ^[Yy]$ ]]; then
|
||||||
installTOTP=true
|
installTOTP=true
|
||||||
installDuo=false
|
installDuo=false
|
||||||
else
|
else
|
||||||
@ -101,9 +95,9 @@ if [[ -z $installTOTP ]] && [[ -z $installDuo ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $installDuo ]] && [[ -z $installTOTP ]]; then
|
if [[ -z "$installDuo" ]] && [[ "$installTOTP" != true ]]; then
|
||||||
# Prompt the user if they would like to install Duo MFA, default of no
|
# Prompt the user if they would like to install Duo MFA, default of no
|
||||||
echo -e -n "${CYAN}Would you like to install Duo (configuration values must be set after install in guacamole.properties)? (y/N): ${NC}"
|
echo -e -n "${CYAN}MFA: Would you like to install Duo (configuration values must be set after install in /etc/guacamole/guacamole.properties)? (y/N): ${NC}"
|
||||||
read PROMPT
|
read PROMPT
|
||||||
if [[ $PROMPT =~ ^[Yy]$ ]]; then
|
if [[ $PROMPT =~ ^[Yy]$ ]]; then
|
||||||
installDuo=true
|
installDuo=true
|
||||||
@ -113,9 +107,16 @@ if [[ -z $installDuo ]] && [[ -z $installTOTP ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# We can't install TOTP and Duo at the same time...
|
||||||
|
if [[ "$installTOTP" = true ]] && [ "$installDuo" = true ]; then
|
||||||
|
echo -e "${RED}MFA: The script does not support installing TOTP and Duo at the same time.${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
if [[ -z $installMySQL ]]; then
|
if [[ -z $installMySQL ]]; then
|
||||||
# Prompt the user to see if they would like to install MySQL, default of yes
|
# Prompt the user to see if they would like to install MySQL, default of yes
|
||||||
echo -e "MySQL is required for installation, if you're using a remote MySQL Server select 'N/n'"
|
echo "MySQL is required for installation, if you're using a remote MySQL Server select 'n'"
|
||||||
echo -e -n "${CYAN}Would you like to install MySQL? (Y/n): ${NC}"
|
echo -e -n "${CYAN}Would you like to install MySQL? (Y/n): ${NC}"
|
||||||
read PROMPT
|
read PROMPT
|
||||||
if [[ $PROMPT =~ ^[Nn]$ ]]; then
|
if [[ $PROMPT =~ ^[Nn]$ ]]; then
|
||||||
@ -133,37 +134,6 @@ if [ "$installMySQL" = false ]; then
|
|||||||
read -p "Enter Guacamole user [guacamole_user]: " guacUser
|
read -p "Enter Guacamole user [guacamole_user]: " guacUser
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get MySQL Root password and Guacamole User password
|
|
||||||
echo
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -s -p "Enter a MySQL ROOT Password: " mysqlRootPwd
|
|
||||||
echo
|
|
||||||
read -s -p "Confirm MySQL ROOT Password: " PROMPT2
|
|
||||||
echo
|
|
||||||
[ "$mysqlRootPwd" = "$PROMPT2" ] && break
|
|
||||||
echo "Passwords don't match. Please try again."
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -s -p "Enter a Guacamole User Database Password: " guacPwd
|
|
||||||
echo
|
|
||||||
read -s -p "Confirm Guacamole User Database Password: " PROMPT2
|
|
||||||
echo
|
|
||||||
[ "$guacPwd" = "$PROMPT2" ] && break
|
|
||||||
echo "Passwords don't match. Please try again."
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
|
|
||||||
if [ "$installMySQL" = true ]; then
|
|
||||||
# Seed MySQL install values
|
|
||||||
debconf-set-selections <<< "mysql-server mysql-server/root_password password $mysqlRootPwd"
|
|
||||||
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $mysqlRootPwd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking if mysql host given
|
# Checking if mysql host given
|
||||||
if [ -z "$mysqlHost" ]; then
|
if [ -z "$mysqlHost" ]; then
|
||||||
mysqlHost="localhost"
|
mysqlHost="localhost"
|
||||||
@ -184,10 +154,40 @@ if [ -z "$guacDb" ]; then
|
|||||||
guacDb="guacamole_db"
|
guacDb="guacamole_db"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ubuntu > 18.04 does not include universe repo by default
|
# Get MySQL "Root" and "Guacamole User" password
|
||||||
|
while true; do
|
||||||
|
echo
|
||||||
|
read -s -p "Enter ${mysqlHost}'s MySQL root password: " mysqlRootPwd
|
||||||
|
echo
|
||||||
|
read -s -p "Confirm ${mysqlHost}'s MySQL root password: " PROMPT2
|
||||||
|
echo
|
||||||
|
[ "$mysqlRootPwd" = "$PROMPT2" ] && break
|
||||||
|
echo "Passwords don't match. Please try again."
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo -e "${BLUE}A new MySQL user will be created (${guacUser})${NC}"
|
||||||
|
read -s -p "Enter ${mysqlHost}'s MySQL guacamole user password: " guacPwd
|
||||||
|
echo
|
||||||
|
read -s -p "Confirm ${mysqlHost}'s MySQL guacamole user password: " PROMPT2
|
||||||
|
echo
|
||||||
|
[ "$guacPwd" = "$PROMPT2" ] && break
|
||||||
|
echo "Passwords don't match. Please try again."
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ "$installMySQL" = true ]; then
|
||||||
|
# Seed MySQL install values
|
||||||
|
debconf-set-selections <<< "mysql-server mysql-server/root_password password $mysqlRootPwd"
|
||||||
|
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $mysqlRootPwd"
|
||||||
|
fi
|
||||||
|
|
||||||
# Different version of Ubuntu and Debian have different package names...
|
# Different version of Ubuntu and Debian have different package names...
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
if [[ "${NAME}" == "Ubuntu" ]]; then
|
if [[ "${NAME}" == "Ubuntu" ]]; then
|
||||||
|
# Ubuntu > 18.04 does not include universe repo by default
|
||||||
# Add the "Universe" repo, don't update
|
# Add the "Universe" repo, don't update
|
||||||
add-apt-repository -yn universe
|
add-apt-repository -yn universe
|
||||||
# Set package names depending on version
|
# Set package names depending on version
|
||||||
@ -221,7 +221,7 @@ elif [[ "${NAME}" == *"Debian"* ]] || [[ "${NAME}" == *"Raspbian GNU/Linux"* ]]
|
|||||||
MYSQL="default-mysql-client"
|
MYSQL="default-mysql-client"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Unsupported Distro - Ubuntu, Debian, or Raspbian Only"
|
echo "Unsupported Distro - Ubuntu, Debian, Kali or Raspbian Only"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -236,6 +236,7 @@ else
|
|||||||
LIBJAVA=""
|
LIBJAVA=""
|
||||||
echo -e "${YELLOW}libmysql-java not available. Will download ${MCJVER} and install manually${NC}"
|
echo -e "${YELLOW}libmysql-java not available. Will download ${MCJVER} and install manually${NC}"
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
# tomcat9 is the latest version
|
# tomcat9 is the latest version
|
||||||
# tomcat8.0 is end of life, but tomcat8.5 is current
|
# tomcat8.0 is end of life, but tomcat8.5 is current
|
||||||
@ -252,15 +253,19 @@ fi
|
|||||||
#TOMCAT=""
|
#TOMCAT=""
|
||||||
|
|
||||||
# Install features
|
# Install features
|
||||||
echo -e "${BLUE}Installing dependencies. This might take a few minutes...${NC}"
|
echo -e "${BLUE}Installing packages. This might take a few minutes...${NC}"
|
||||||
|
|
||||||
|
# Don't prompt during install
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Required packages
|
||||||
apt-get -y install build-essential libcairo2-dev ${JPEGTURBO} ${LIBPNG} libossp-uuid-dev libavcodec-dev libavutil-dev \
|
apt-get -y install build-essential libcairo2-dev ${JPEGTURBO} ${LIBPNG} libossp-uuid-dev libavcodec-dev libavutil-dev \
|
||||||
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libpulse-dev libssl-dev \
|
libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libpulse-dev libssl-dev \
|
||||||
libvorbis-dev libwebp-dev ${MYSQL} ${LIBJAVA} ${TOMCAT} freerdp2-x11 libtool-bin libwebsockets-dev \
|
libvorbis-dev libwebp-dev libwebsockets-dev wget \
|
||||||
ghostscript wget dpkg-dev &>> ${LOG}
|
freerdp2-x11 libtool-bin ghostscript dpkg-dev \
|
||||||
|
${MYSQL} ${LIBJAVA} ${TOMCAT} &>> ${LOG}
|
||||||
|
|
||||||
|
# If apt fails to run completely the rest of this isn't going to work...
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed. See ${LOG}${NC}"
|
echo -e "${RED}Failed. See ${LOG}${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
@ -270,7 +275,7 @@ fi
|
|||||||
|
|
||||||
# Set SERVER to be the preferred download server from the Apache CDN
|
# Set SERVER to be the preferred download server from the Apache CDN
|
||||||
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"
|
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"
|
||||||
echo -e "${BLUE}Downloading Files...${NC}"
|
echo -e "${BLUE}Downloading files...${NC}"
|
||||||
|
|
||||||
# Download Guacamole Server
|
# Download Guacamole Server
|
||||||
wget -q --show-progress -O guacamole-server-${GUACVERSION}.tar.gz ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
|
wget -q --show-progress -O guacamole-server-${GUACVERSION}.tar.gz ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
|
||||||
@ -279,6 +284,7 @@ if [ $? -ne 0 ]; then
|
|||||||
echo -e "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz${NC}"
|
echo -e "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
# Extract Guacamole Files
|
||||||
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
|
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
|
||||||
fi
|
fi
|
||||||
echo -e "${GREEN}Downloaded guacamole-server-${GUACVERSION}.tar.gz${NC}"
|
echo -e "${GREEN}Downloaded guacamole-server-${GUACVERSION}.tar.gz${NC}"
|
||||||
@ -344,19 +350,20 @@ if [[ -z $JAVALIB ]]; then
|
|||||||
fi
|
fi
|
||||||
echo -e "${GREEN}Downloaded mysql-connector-java-${MCJVER}.tar.gz${NC}"
|
echo -e "${GREEN}Downloaded mysql-connector-java-${MCJVER}.tar.gz${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}Downloading complete.${NC}"
|
echo -e "${GREEN}Downloading complete.${NC}"
|
||||||
|
echo
|
||||||
|
|
||||||
# Make directories
|
# Make directories
|
||||||
|
rm -rf /etc/guacamole/extensions
|
||||||
mkdir -p /etc/guacamole/lib
|
mkdir -p /etc/guacamole/lib
|
||||||
mkdir -p /etc/guacamole/extensions
|
mkdir -p /etc/guacamole/extensions
|
||||||
|
|
||||||
# Install guacd
|
# Install guacd (Guacamole-server)
|
||||||
cd guacamole-server-${GUACVERSION}
|
cd guacamole-server-${GUACVERSION}
|
||||||
|
|
||||||
echo -e "${BLUE}Building Guacamole with GCC $(gcc --version | head -n1 | grep -oP '\)\K.*' | awk '{print $1}') ${NC}"
|
echo -e "${BLUE}Building Guacamole-Server with GCC $(gcc --version | head -n1 | grep -oP '\)\K.*' | awk '{print $1}') ${NC}"
|
||||||
|
|
||||||
echo -e "${BLUE}Configuring. This might take a minute...${NC}"
|
echo -e "${BLUE}Configuring Guacamole-Server. This might take a minute...${NC}"
|
||||||
./configure --with-init-dir=/etc/init.d &>> ${LOG}
|
./configure --with-init-dir=/etc/init.d &>> ${LOG}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed. See ${LOG}${NC}"
|
echo -e "${RED}Failed. See ${LOG}${NC}"
|
||||||
@ -365,7 +372,7 @@ else
|
|||||||
echo -e "${GREEN}OK${NC}"
|
echo -e "${GREEN}OK${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${BLUE}Running Make. This might take a few minutes...${NC}"
|
echo -e "${BLUE}Running Make on Guacamole-Server. This might take a few minutes...${NC}"
|
||||||
make &>> ${LOG}
|
make &>> ${LOG}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed. See ${LOG}${NC}"
|
echo -e "${RED}Failed. See ${LOG}${NC}"
|
||||||
@ -374,7 +381,7 @@ else
|
|||||||
echo -e "${GREEN}OK${NC}"
|
echo -e "${GREEN}OK${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${BLUE}Running Make Install...${NC}"
|
echo -e "${BLUE}Running Make Install on Guacamole-Server...${NC}"
|
||||||
make install &>> ${LOG}
|
make install &>> ${LOG}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed. See ${LOG}${NC}"
|
echo -e "${RED}Failed. See ${LOG}${NC}"
|
||||||
@ -382,12 +389,11 @@ if [ $? -ne 0 ]; then
|
|||||||
else
|
else
|
||||||
echo -e "${GREEN}OK${NC}"
|
echo -e "${GREEN}OK${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ldconfig
|
ldconfig
|
||||||
systemctl enable guacd
|
echo
|
||||||
cd ..
|
|
||||||
|
|
||||||
# Move files to correct locations
|
# Move files to correct locations (guacamole-client & Guacamole authentication extensions)
|
||||||
|
cd ..
|
||||||
mv guacamole-${GUACVERSION}.war /etc/guacamole/guacamole.war
|
mv guacamole-${GUACVERSION}.war /etc/guacamole/guacamole.war
|
||||||
mv guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/
|
mv guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/
|
||||||
|
|
||||||
@ -430,8 +436,7 @@ if [ "$installDuo" = true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# restart tomcat
|
# restart tomcat
|
||||||
echo -e "${BLUE}Restarting tomcat...${NC}"
|
echo -e "${BLUE}Restarting tomcat service & enable at boot...${NC}"
|
||||||
|
|
||||||
service ${TOMCAT} restart
|
service ${TOMCAT} restart
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed${NC}"
|
echo -e "${RED}Failed${NC}"
|
||||||
@ -439,6 +444,24 @@ if [ $? -ne 0 ]; then
|
|||||||
else
|
else
|
||||||
echo -e "${GREEN}OK${NC}"
|
echo -e "${GREEN}OK${NC}"
|
||||||
fi
|
fi
|
||||||
|
# Start at boot
|
||||||
|
systemctl enable ${TOMCAT}
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ "$installMySQL" = true ]; then
|
||||||
|
# restart mysql
|
||||||
|
echo -e "${BLUE}Restarting MySQL service & enable at boot...${NC}"
|
||||||
|
service mysql restart
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Failed${NC}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}OK${NC}"
|
||||||
|
fi
|
||||||
|
# Start at boot
|
||||||
|
systemctl enable mysql
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# restart mysql
|
# restart mysql
|
||||||
@ -462,19 +485,51 @@ if [[ "$mysqlHost" != "localhost" ]]; then
|
|||||||
echo -e "${YELLOW}MySQL Guacamole user is set to accept login from any host, please change this for security reasons if possible.${NC}"
|
echo -e "${YELLOW}MySQL Guacamole user is set to accept login from any host, please change this for security reasons if possible.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set MySQL password
|
||||||
|
export MYSQL_PWD=${mysqlRootPwd}
|
||||||
|
|
||||||
|
# Check for $guacDb already being there
|
||||||
|
echo -e "${BLUE}Checking MySQL for existing database (${guacDb})${NC}"
|
||||||
SQLCODE="
|
SQLCODE="
|
||||||
create database ${guacDb};
|
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='${guacDb}';"
|
||||||
|
|
||||||
|
# Execute SQL code
|
||||||
|
MYSQL_RESULT=$( echo ${SQLCODE} | mysql -u root -D information_schema -h ${mysqlHost} -P ${mysqlPort} )
|
||||||
|
if [[ $MYSQL_RESULT != "" ]]; then
|
||||||
|
echo -e "${RED}It appears there is already a MySQL database (${guacDb}) on ${mysqlHost}${NC}"
|
||||||
|
echo -e "${RED}Try: mysql -e 'drop database ${guacDb}'${NC}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}OK${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for $guacUser already being there
|
||||||
|
echo -e "${BLUE}Checking MySQL for existing user (${guacUser})${NC}"
|
||||||
|
SQLCODE="
|
||||||
|
SELECT COUNT(*) FROM mysql.user WHERE user = '${guacUser}';"
|
||||||
|
|
||||||
|
# Execute SQL code
|
||||||
|
MYSQL_RESULT=$( echo ${SQLCODE} | mysql -u root -h ${mysqlHost} -P ${mysqlPort} | grep '0' )
|
||||||
|
if [[ $MYSQL_RESULT == "" ]]; then
|
||||||
|
echo -e "${RED}It appears there is already a MySQL user (${guacUser}) on ${mysqlHost}${NC}"
|
||||||
|
echo -e "${RED}Try: mysql -e \"DROP USER '${guacUser}'@'${guacUserHost}';\"${NC}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}OK${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create database & user, then set permissions
|
||||||
|
SQLCODE="
|
||||||
|
CREATE DATABASE IF NOT EXISTS ${guacDb};
|
||||||
create user if not exists '${guacUser}'@'${guacUserHost}' identified by \"${guacPwd}\";
|
create user if not exists '${guacUser}'@'${guacUserHost}' identified by \"${guacPwd}\";
|
||||||
GRANT SELECT,INSERT,UPDATE,DELETE ON ${guacDb}.* TO '${guacUser}'@'${guacUserHost}';
|
GRANT SELECT,INSERT,UPDATE,DELETE ON ${guacDb}.* TO '${guacUser}'@'${guacUserHost}';
|
||||||
flush privileges;"
|
flush privileges;"
|
||||||
|
|
||||||
export MYSQL_PWD=${mysqlRootPwd}
|
|
||||||
|
|
||||||
# Execute SQL code
|
# Execute SQL code
|
||||||
echo ${SQLCODE} | mysql -u root -h ${mysqlHost} -P ${mysqlPort}
|
echo ${SQLCODE} | mysql -u root -h ${mysqlHost} -P ${mysqlPort}
|
||||||
|
|
||||||
# Add Guacamole schema to newly created database
|
# Add Guacamole schema to newly created database
|
||||||
echo -e "Adding db tables..."
|
echo -e "${BLUE}Adding database tables...${NC}"
|
||||||
cat guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/*.sql | mysql -u root -D ${guacDb} -h ${mysqlHost} -P ${mysqlPort}
|
cat guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/*.sql | mysql -u root -D ${guacDb} -h ${mysqlHost} -P ${mysqlPort}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed${NC}"
|
echo -e "${RED}Failed${NC}"
|
||||||
@ -482,21 +537,24 @@ if [ $? -ne 0 ]; then
|
|||||||
else
|
else
|
||||||
echo -e "${GREEN}OK${NC}"
|
echo -e "${GREEN}OK${NC}"
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
# Ensure guacd is started
|
# Ensure guacd is started
|
||||||
echo -e "${BLUE}Starting guacamole...${NC}"
|
echo -e "${BLUE}Starting guacamole service & enable at boot...${NC}"
|
||||||
service guacd start
|
service guacd start
|
||||||
|
systemctl enable guacd
|
||||||
|
echo
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
echo -e "${BLUE}Cleanup install files...${NC}"
|
echo -e "${BLUE}Cleanup install files...${NC}"
|
||||||
rm -rf guacamole-*
|
rm -rf guacamole-*
|
||||||
rm -rf mysql-connector-java-*
|
rm -rf mysql-connector-java-*
|
||||||
|
|
||||||
unset MYSQL_PWD
|
unset MYSQL_PWD
|
||||||
|
echo
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
echo -e "${BLUE}Installation Complete\nhttp://localhost:8080/guacamole/\nDefault login guacadmin:guacadmin\nBe sure to change the password.${NC}"
|
echo -e "${BLUE}Installation Complete\n- Visit: http://localhost:8080/guacamole/\n- Default login (username/password): guacadmin/guacadmin\n***Be sure to change the password***.${NC}"
|
||||||
|
|
||||||
if [[ ! -z $installDuo ]]; then
|
if [ "$installDuo" = true ]; then
|
||||||
echo -e "${YELLOW}Don't forget to configure Duo in guacamole.properties. You will not be able to login otherwise.\nhttps://guacamole.apache.org/doc/${GUACVERSION}/gug/duo-auth.html${NC}"
|
echo -e "${YELLOW}\nDon't forget to configure Duo in guacamole.properties. You will not be able to login otherwise.\nhttps://guacamole.apache.org/doc/${GUACVERSION}/gug/duo-auth.html${NC}"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user