dockertomcatdocker-composeguacamole

Docker apache guacamole - GUACAMOLE_HOME wont change


I use apache guacamole on docker-compose, and it seems that it is impossible to edit tomcat HTML files. I really need to delete the user "home" button from control panel (ctrl + alt+ shift)

I have tried adding new extension but i cant because when i set GUACAMOLE_HOME to "/guacamole-home" where i created a .jar of new extension its always setting it to the default "/root/.guacamole".

How can I make this work? even if there's another way to edit the client.html in guacamole on another way

guacamole:
                image: guacamole/guacamole:latest
                depends_on:
                      - guacd
                      - postgres_gqm
                volumes:
                        - /root/api/program.jar:/opt/guacamole/program.jar
                        - /root/api/guacamole-home:/guacamole-home
                environment:
                        - "enable-environment-properties=true"
                        - "GUACD_HOSTNAME=guacd"
                        - "POSTGRES_DATABASE=guacamole_db"
                        - "POSTGRES_HOSTNAME=postgres_gqm"
                        - "POSTGRES_PASSWORD=pass"
                        - "POSTGRES_USER=guacamole_user"
                        - "GUACD_LOG_LEVEL=debug"
                        - "GUACAMOLE_HOME=/guacamole-home"
                links:
                     - guacd
                ports:
                     - 8080/tcp
                restart: always

Solution

  • I managed to change tomcat HTML files on guacamole using an extension but not in the way docs suggested.

    First, I copied this files from container guacamole to host :

    docker cp <containerid>:/usr/local/tomcat /root/myhome
    docker cp <containerid>:/opt/guacamole/bin/start.sh /root/myhome
    

    Then When i Have the files I can edit the client.html that is under tomcat/webapps/guacamole/app/client/templates/client.html on my local host.

    So the way I made the extension is first you go to the start.sh script that I copied on localhost and add this row to this lines number:

    238:    ln -s /opt/guacamole/program.jar "$GUACAMOLE_EXT"
    389:    ln -s /opt/guacamole/program.jar "$GUACAMOLE_EXT" 
    

    should be here on the start.sh:

    # Add required .jar files to GUACAMOLE_LIB and GUACAMOLE_EXT
    ln -s /opt/guacamole/postgresql/postgresql-*.jar "$GUACAMOLE_LIB"
    ln -s /opt/guacamole/postgresql/guacamole-auth-*.jar "$GUACAMOLE_EXT"
    ln -s /opt/guacamole/program.jar "$GUACAMOLE_EXT" #ADDED
    

    and here:

    # Add required .jar files to GUACAMOLE_LIB and GUACAMOLE_EXT
    ln -s /opt/guacamole/mysql/mysql-connector-*.jar "$GUACAMOLE_LIB"
    ln -s /opt/guacamole/mysql/guacamole-auth-*.jar "$GUACAMOLE_EXT"
    ln -s /opt/guacamole/program.jar "$GUACAMOLE_EXT" #ADDED
    

    Now, we need to make the extention and the changes we want to the HTML and JS: in localhost:

    mkdir myExt
    cd myExt
    

    vi guac-manifest.json #creating the guac-manifest.json

    {   "guacamoleVersion" : "*",
    
        "name"      : "B-Override",
        "namespace" : "b-override",
    
        "html" : [ "client.html" ],
        "js": ["clientController.js"]
    }
    

    I wanted to change client.html and clientController.js (it doesn't matter if you replace the names of the original files, i choose not to replace the original names in the guac-manifest.json.

    I wanted to remove from user panel menu (ctrl+alt+shift) the connection dropdown + the options to logout or go to home so i copied the original client.html from the tomcat file we copied to localhost:

    cp ../tomcat/webapps/guacamole/app/client/templates/client.html .
    

    and also:

    cp ../tomcat//webapps/guacamole/app/client/controllers/clientController.js .
    

    Because i wanted to remove the home and logout button also from the popup that guacamole gives when the vm is off.(reconnect - home - logout)

    Now,

    I edited the files i just copied to myExt:

    vi client.html
    

    I add to the top of the file this :

    <meta name="replace-children" content=".menu .menu-content .header">
    

    And it replace the parts in the HTML that i want , i can remove from the file the parts that i don't edit and it will only replace in the original file the class i add in the content

    little example:

    <meta name="replace-children" content=".menu .menu-content .header">
        <div class="menu" ng-class="{open: menu.shown}" id="guac-menu">
            <div class="menu-content" ng-if="menu.shown">
    
                <!-- Stationary header -->
                <div class="header">
                    <h2 class="connection-select-menu" ng-show="rootConnectionGroups">
                        <guac-menu menu-title="client.name" interactive="true">
    

    You can that the classes on the code that i wanted to replace i added to content with a "." in front of it (that is how i understand on how to replace the parts, i know it is related to css files but that way made it easier for me to understand)

    in the js that i wanted to modify i didn't deleted the parts that i don't need to change as it doesn't works the same, i went to "action = " and deleted the HOME and LOGGOUT option and saves it like that, no need anything on the file head like HTML.

    now that the extension is ready we need to make it as a jar file + volume the start.sh to guacamole container:

    first we need to install this to have the jar option: (ubuntu)

    apt install default-jdk openjdk-11-jdk-headless fastjar openjdk-8-jdk-headless
    

    then we go out of the myExt dir :

    cd ..
    
    jar cvf program.jar -C myExt .
    

    now we go to docker-compose.yml and adding the volumes:

    guacamole:
            image: guacamole/guacamole:latest
            depends_on:
                  - guacd
                  - postgres_gqm
            volumes:
                    - /root/myhome/start.sh:/opt/guacamole/bin/start.sh #ADDED
                    - /root/myhome/program.jar:/opt/guacamole/program.jar #ADDED
            environment:
                    - "GUACD_HOSTNAME=guacd"
                    - "POSTGRES_DATABASE=guacamole_db"
                    - "POSTGRES_HOSTNAME=postgres_gqm"
                    - "POSTGRES_PASSWORD=PassWrdGQM"
                    - "POSTGRES_USER=guacamole_user"
                    - "GUACD_LOG_LEVEL=debug"
            links:
                 - guacd
            ports:
                 - 8080/tcp
            restart: always
    

    now :

    docker-compose down
    docker-compose up -d ; docker-compose logs -f --tail=10 guacamole 
    

    and look for the extension load :

    guacamole_1       | 09:50:10.683 [localhost-startStop-1] INFO  o.a.g.extension.ExtensionModule - Extension "B-Override" loaded.
    

    If you see that you made a mistake you can always go back and try again by deleting the /root/myhome/program.jar from localhost, go back to myEXT re-copy client.html file or edit it, closing it again as jar and docker-compose down + up.