Guacamole Upgrade

The following script will upgrade Guacamole from 0.9.x to 0.9.14

If you would like you can download the “fully scripted” version of this like so, just have your MySQL root password ready:

wget https://raw.githubusercontent.com/MysticRyuujin/guac-install/master/guac-upgrade.sh
chmod +x guac-upgrade.sh
./guac-upgrade.sh
#!/bin/bash

# Version number of Guacamole to install
GUACVERSION="0.9.14"

# Try to get database from /etc/guacamole/guacamole.properties
DATABASE=$(grep -oP 'mysql-database:K.*' /etc/guacamole/guacamole.properties | awk '{print $1}')
MYSQL_SERVER=$(grep -oP 'mysql-hostname:K.*' /etc/guacamole/guacamole.properties | awk '{print $1}')

# Get script arguments for non-interactive mode
while [ "$1" != "" ]; do
    case $1 in
        -m | --mysqlpwd )
            shift
            mysqlpwd="$1"
            ;;
    esac
    shift
done

# Get MySQL root password
if [ -n "$mysqlpwd" ]; then
        mysqlrootpassword=$mysqlpwd
        export MYSQL_PWD=${mysqlrootpassword}
        mysql -u root -h ${MYSQL_SERVER} ${DATABASE} -e"quit" || exit
else
    echo
    while true
    do
        read -s -p "Enter MySQL ROOT Password: " mysqlrootpassword
        export MYSQL_PWD=${mysqlrootpassword}
        echo
        mysql -u root -h ${MYSQL_SERVER} ${DATABASE} -e"quit" && break
        echo
    done
    echo
fi

# Get Tomcat Version
TOMCAT=$(ls /etc/ | grep tomcat)

# Get Current Guacamole Version
OLDVERSION=$(grep -oP 'Guacamole.API_VERSION = "K[0-9.]+' /var/lib/${TOMCAT}/webapps/guacamole/guacamole-common-js/modules/Version.js)

# Set SERVER to be the preferred download server from the Apache CDN
SERVER="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUACVERSION}"

# Stop tomcat
service ${TOMCAT} stop

# Download Guacamole server
wget -O guacamole-server-${GUACVERSION}.tar.gz ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
if [ $? -ne 0 ]; then
    echo "Failed to download guacamole-server-${GUACVERSION}.tar.gz"
    echo "${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz"
    exit
fi

# Download Guacamole client
wget -O guacamole-${GUACVERSION}.war ${SERVER}/binary/guacamole-${GUACVERSION}.war
if [ $? -ne 0 ]; then
    echo "Failed to download guacamole-${GUACVERSION}.war"
    echo "${SERVER}/binary/guacamole-${GUACVERSION}.war"
    exit
fi

# Download SQL components
wget -O guacamole-auth-jdbc-${GUACVERSION}.tar.gz ${SERVER}/binary/guacamole-auth-jdbc-${GUACVERSION}.tar.gz
if [ $? -ne 0 ]; then
    echo "Failed to download guacamole-auth-jdbc-${GUACVERSION}.tar.gz"
    echo "${SERVER}/binary/guacamole-auth-jdbc-${GUACVERSION}.tar.gz"
    exit
fi

# Upgrade Guacamole Server
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
cd guacamole-server-${GUACVERSION}

# Hack for gcc-7
if [[ $(gcc --version | head -n1 | grep -oP ')K.*' | awk '{print $1}' | grep "^7" | wc -l) -gt 0 ]]
then
    apt-get -y install gcc-6
    if [ $? -ne 0 ]
    then
        echo "apt-get failed to install gcc-6"
        exit
    fi
    CC="gcc-6" ./configure --with-init-dir=/etc/init.d
    CC="gcc-6" make
    CC="gcc-6" make install
else
    ./configure --with-init-dir=/etc/init.d
    make
    make install
fi

ldconfig
systemctl enable guacd
cd ..

# Upgrade Guacamole Client
mv guacamole-${GUACVERSION}.war /etc/guacamole/guacamole.war

# Upgrade SQL Components
tar -xzf guacamole-auth-jdbc-${GUACVERSION}.tar.gz
cp guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/

# Get list of SQL Upgrade Files
UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/upgrade/ | sort -V))

# Compare SQL Upgrage Files against old version, apply upgrades as needed
for FILE in ${UPGRADEFILES[@]}
do
    FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-K[0-9.]+(?=.)')
    if [[ $(echo -e "${FILEVERSION}n${OLDVERSION}" | sort -V | head -n1) == ${OLDVERSION} && ${FILEVERSION} != ${OLDVERSION} ]]
    then
        echo "Patching ${DATABASE} with ${FILE}"
        mysql -u root -h ${MYSQL_SERVER} ${DATABASE} < guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/upgrade/${FILE}
    fi
done

# Start tomcat
service ${TOMCAT} start
service guacd start

# Cleanup
rm -rf guacamole*
unset MYSQL_PWD

39 thoughts on “Guacamole Upgrade

  1. Yet another streamlined upgrade process. This is what tech blogs are all about. Thanks for shortening outage windows!

    One question though… Is there a way to check the running Guacamole version? I want to confirm the upgrade indeed worked.

  2. I have a running Guacamole 0.9.12 (fresh install) on a Debian 8.9 (installed following the instructions given here : https://www.chasewright.com/guacamole-with-mysql-on-ubuntu/). Works great πŸ™‚ BTW, thanks for this post πŸ™‚

    Now, I’m trying to upgrade to 0.9.13 following the steps on this page, but there is no way to get it working 😦

    The login page stills says 0.9.12-incubating after the upgrade, and I find this error in catalina.out :
    13:43:49.662 [localhost-startStop-1] ERROR o.a.g.extension.ExtensionModule – Extension “guacamole-auth-jdbc-mysql-0.9.13-incubating.jar” could not be loaded: Extension “MySQL Authentication” is not compatible with this version of Guacamole.

    What am I doing wrong ? Any idea ?

    1. There are two possibilities. First, you may have done everything correctly but your browser is caching, Try clearing your cache and reloading the page. Second, if the login page says 0.9.12 it’s probably because you failed to overwrite the old guacamole.war file for some reason, at which point I’d be cautious of the entire process and probably re-run it from the start just to be safe…Given the second error message I think it’s the latter

      1. Thanks for the quick reply !

        I cleared the browser’s cache, but this didn’t change anything.

        So far, after many retries, I have found only one method to upgrade correctly :
        Using tomcat’s WebApp manager (host:8080/manager/), I stop and undeploy the guacamole webapp.
        Then, after upgrading, I must recreate the symlink in /var/lib/tomcat8/webapps/ so guacamole.war can be redeployed.
        This seems to work.

        Is there a command line way to undeploy guacamole, rather than using the WebApp manager (which could possibly be added to the upgrade script) ?

        1. You must be doing some extra stuff that I’m not doing here πŸ™‚ When 0.9.13 came out I was on 0.9.12, I ran the script directly as is and it worked. I’ve never used the WebApp manager… so I’m not sure. I would assume that if you did a symlink from the /etc/guacamole/guacamole.war file that it would be upgraded when overwritten.

        2. Maybe, yes, even if I don’t know exactly what. I don’t run the script, but run each line separately.
          Ubuntu isn’t exactly Debian, so this could possibly make a difference too…

          Just in case someone stumbles over the same problem, here is what I did :
          – install tomcat8-admin
          – add a user whith roles=”manager-gui,admin-gui,manager-script” in /etc/tomcat8/tomcat-users.xml

          # Stop guacamole
          wget “http://user:password@host:8080/manager/text/stop?path=/guacamole” -O – -q
          # Undeploy guacamole
          wget “http://user:password@host:8080/manager/text/undeploy?path=/guacamole” -O – -q

          user and password refer to the values added in /etc/tomcat8/tomcat-users.xml.

          I just added two lines to remove previous version of guacamole-auth extension and mysql-connector.

          symlink to guacamole.war needs to be recreated since it’s deleted by the undeploy script.

          That’s all πŸ™‚
          Thanks again for you help.

  3. Hi Guys – quick heads up.

    1. Run as root or run the script with sudo
    2. before you begin, do sudo apt install jq
    3. The script considers you to be on the previous version – I was on 0.9.9 so i had to comment out this part:


    # Check if there is an schema upgrade file, if there is run it (will prompt for password)
    #if [ -f "guacamole-auth-jdbc-${VERSION}-incubating/mysql/schema/upgrade/upgrade-pre-${VERSION}.sql" ]
    #then
    # mysql -u root -p guacamole_db < guacamole-auth-jdbc-${VERSION}-incubating/mysql/schema/upgrade/upgrade-pre-${VERSION}.sql
    #fi

    # Start Tomcat
    #service tomcat8 start

    # Cleanup
    #rm -rf guacamole*

    and then i manually ran the schema upgrades, because they need to be run in order. So i had to do:
    sudo mysql -u root -p guacamole_db < ./upgrade-pre-0.9.10.sql
    sudo mysql -u root -p guacamole_db < ./upgrade-pre-0.9.11.sql
    sudo mysql -u root -p guacamole_db < ./upgrade-pre-0.9.13.sql

    Then i brought up tomcat8 and finally deleted my files (did manually what the script would have done).

    Cheers!

    1. Yeah, my script assumes that you installed via the other script on my site where jq is already installed. There’s no easy way to determine the current running version of guacamole to know what SQL upgrades need to be ran. I’ve submitted a feature request to be able to run “guacd –version” or something to get it but who knows if it’ll ever be implemented.

      1. It seems that `/var/lib/tomcat8/webapps/guacamole/translations/en.json` contains currently installed version string (e.g. `”VERSION” : “0.9.11-incubating”`). I don’t know how hard it is to parse a JSON files in a bash script or how reliable this version info is, but maybe you could give it a try.
        And thanks for the script

        1. Thanks for the tip! I’ve made improvements to the script in the GitHub I’ll push with 0.9.14, I’ll update the website with more robust instructions then…

  4. Hi

    I’m trying to upgrade guacamole 0.9.10 and get the error 1049 unknown database guacamole_db

    Thanks for your help !

      1. It was your script on centos.

        I also have a 0.9.13 running but need to have ssl access. How can we enable ssl and create a certificate ?

  5. Thanks for the script, works well.

    I wanted to point out that everything worked, however, it disable the 2FA that was setup.

  6. Your script is awesome and has been very useful in getting Guac setup quickly. Only problem I’m having is that the logs are not being directed to syslog. Do you know what would need to be added to the init.d script to get that working properly?

  7. Thanks for this script! It really helped me to understand all the steps in upgrading guacamole. It worked wonderfully once I followed Andre P’s advice on manually applying each database upgrade script since I was upgrading from 0.9.9 to 0.9.13.

  8. Thanks for the script! I’m trying to update a LXC container running CentOS 7. The script seems to run without an issue, but when I see the login page it still states that I’m running 0.9.9.

    The only errors I can see are
    cp : cannot create regular file ‘/etc/guacamole/extensions/’: Not a directory
    cp: cannot create regular file ‘/etc/guacamole/lib/’: Not a directory

    guacd also reports that it was started but unable to bind socket to any address.

    Any ideas? I’ve used your script to install a fresh 0.9.14 on Debian. I would be happy to continue using this container if I can figure out how to migrate my connections over to it.

  9. Hi and thanks for the great job πŸ™‚

    By adding the following var (next after DATABASE=):
    MYSQL_SERVER=$(grep -oP ‘mysql-hostname:K.*’ /etc/guacamole/guacamole.properties | awk ‘{print $1}’)
    and changing the existing “mysql -u root” entries into “mysql -u root -h ${MYSQL_SERVER}” I was also able to update my Guacamole instance with the MySQL-DB on a remote host.
    Guacamole host OS: Debian 8.10

    Thank you again for your good job πŸ™‚

    Cheers,
    D0C

  10. Hello!

    After upgrade from 0.9.4 I’ve got an error
    “Guacamole protocol violation. Perhaps the version of guacamole-client is incompatible with this version of libguac.”

    I’m trying to connect to Xenserver over ssh tunnel with protocol vnc.

    Do you have any idia how to fix this error?

    Thank you,
    Serg

    1. What I would do is run the upgrade script again, with all of the MySQL stuff commented out…(or just go manually run the commands in a safe and observable manner). It sounds like perhaps the guacamole.war file didn’t update fully? I don’t think my script existed when 0.9.4 was released so it could have something to do with how you originally installed it…My upgrade script is designed to be compatible with my install script. So my suggestion would be to look at how you installed it originally and perhaps re-link the war file.

    2. I solved this issue.
      Trouble was in configurations params that was deprecated.
      I copied all files to GuacamoleHome dir and it is work now.

      Thanks for script.

  11. Thanks for the script, I am having issue, probably its database. can you please advise I am still on 0.9.13 after running the script, here is the section with error.

    guacd.service is not a native service, redirecting to /sbin/chkconfig.
    Executing /sbin/chkconfig guacd on
    Patching guacamole with upgrade-pre-0.9.14.sql
    ERROR 1060 (42S21) at line 24: Duplicate column name ‘connection_weight’
    Redirecting to /bin/systemctl start tomcat.service
    Starting guacd: SUCCESS

    1. That’s strange, it has to be a bug/error in the `upgrade-pre-0.9.14.sql` which comes directly from the guac team…I wonder, does it still work? It might be an error you can ignore if the rest of the sql committed successfully? I don’t know, that’s a bug for the Guacamole team, not my script πŸ™‚

    1. That’s strange, it has to be a bug/error in the `upgrade-pre-0.9.14.sql` which comes directly from the guac team…I wonder, does it still work? It might be an error you can ignore if the rest of the sql committed successfully? I don’t know, that’s a bug for the Guacamole team, not my script πŸ™‚

  12. Hi, and thanks for the script.
    I have one big problem with the script. When I run the script I will always get back to question “Enter MySQL ROOT Password:”.
    The output starts with:
    ———————————————————————————————-
    mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Usage: mysql [OPTIONS] [database]
    -?, –help Display this help and exit.
    -I, –help Synonym for -?

    ———————————————————————————————-

    If I use my password to login to MySQL it is working.
    What can be wrong?

    I have
    Ubuntu 16.04
    Guacamole 0.9.12-incubating

    /Pelle

    1. The command being ran is:
      mysql -u root -h ${MYSQL_SERVER} ${DATABASE} -e”quit”

      Where:
      DATABASE=$(grep -oP ‘mysql-database:K.*’ /etc/guacamole/guacamole.properties | awk ‘{print $1}’)
      MYSQL_SERVER=$(grep -oP ‘mysql-hostname:K.*’ /etc/guacamole/guacamole.properties | awk ‘{print $1}’)

      I’d start by investigating the correctness of those variables as they pertain to your installation…

      1. Thank you very much. Is there an another possibility to update guacamole from 0.9.13-incubating to 0.9.14 ?
        Or maybe change your script somehow?

        i’m thankfull for every help.

  13. Thanks for all.

    After upgrade my 0.9.9 to 0.9.14 cannot login guacadmin user using old credentials.
    I upgrade client too.
    But renamed client instaled based in 0.9.9 to guaca-old and cliente 0.9.14 to guaca-new
    If use http://myserver:8080/guaca-old/ – guacadmin login sucessful
    if use http://myserver:8080/guaca-new/ the same credential guadmin user/password – error login displayed (wrong password)
    Some here help-me

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.