From eec09d72401107ee432654b59699d421c03ef57e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 20 May 2016 14:43:23 -0700 Subject: [PATCH] GUACAMOLE-27: Add Docker image from old guacamole-docker repository. Update license. --- guacamole-docker/.dockerignore | 3 + guacamole-docker/.gitignore | 1 + guacamole-docker/Dockerfile | 46 +++ guacamole-docker/README.md | 123 +++++++ guacamole-docker/bin/download-guacamole.sh | 49 +++ guacamole-docker/bin/download-jdbc-auth.sh | 83 +++++ guacamole-docker/bin/download-ldap-auth.sh | 62 ++++ guacamole-docker/bin/initdb.sh | 69 ++++ guacamole-docker/bin/start.sh | 410 +++++++++++++++++++++ 9 files changed, 846 insertions(+) create mode 100644 guacamole-docker/.dockerignore create mode 100644 guacamole-docker/.gitignore create mode 100644 guacamole-docker/Dockerfile create mode 100644 guacamole-docker/README.md create mode 100755 guacamole-docker/bin/download-guacamole.sh create mode 100755 guacamole-docker/bin/download-jdbc-auth.sh create mode 100755 guacamole-docker/bin/download-ldap-auth.sh create mode 100755 guacamole-docker/bin/initdb.sh create mode 100755 guacamole-docker/bin/start.sh diff --git a/guacamole-docker/.dockerignore b/guacamole-docker/.dockerignore new file mode 100644 index 000000000..5792b764a --- /dev/null +++ b/guacamole-docker/.dockerignore @@ -0,0 +1,3 @@ +*~ +.git +.gitignore diff --git a/guacamole-docker/.gitignore b/guacamole-docker/.gitignore new file mode 100644 index 000000000..b25c15b81 --- /dev/null +++ b/guacamole-docker/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/guacamole-docker/Dockerfile b/guacamole-docker/Dockerfile new file mode 100644 index 000000000..36d39b245 --- /dev/null +++ b/guacamole-docker/Dockerfile @@ -0,0 +1,46 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# Dockerfile for guacamole-client +# + +# Start from Tomcat image +FROM tomcat:8.0.20-jre7 +MAINTAINER Michael Jumper + +# Version info +ENV \ + GUAC_VERSION=0.9.9 \ + GUAC_JDBC_VERSION=0.9.9 \ + GUAC_LDAP_VERSION=0.9.9 + +# Add configuration scripts +COPY bin /opt/guacamole/bin/ + +# Download and install latest guacamole-client and authentication +RUN \ + /opt/guacamole/bin/download-guacamole.sh "$GUAC_VERSION" /usr/local/tomcat/webapps && \ + /opt/guacamole/bin/download-jdbc-auth.sh "$GUAC_JDBC_VERSION" /opt/guacamole && \ + /opt/guacamole/bin/download-ldap-auth.sh "$GUAC_LDAP_VERSION" /opt/guacamole + +# Start Guacamole under Tomcat, listening on 0.0.0.0:8080 +EXPOSE 8080 +CMD ["/opt/guacamole/bin/start.sh" ] + diff --git a/guacamole-docker/README.md b/guacamole-docker/README.md new file mode 100644 index 000000000..1152af16e --- /dev/null +++ b/guacamole-docker/README.md @@ -0,0 +1,123 @@ +What is Apache Guacamole? +========================= + +[Apache Guacamole](http://guacamole.incubator.apache.org/) is a clientless +remote desktop gateway. It supports standard protocols like VNC and RDP. We +call it clientless because no plugins or client software are required. + +Thanks to HTML5, once Guacamole is installed on a server, all you need to +access your desktops is a web browser. + +How to use this image +===================== + +Using this image will require an existing, running Docker container with the +[guacd image](https://registry.hub.docker.com/u/glyptodon/guacd/), and another +Docker container providing either a PostgreSQL or MySQL database. + +The name of the database and all associated credentials are specified with +environment variables given when the container is created. All other +configuration information is generated from the Docker links. + +Beware that you will need to initialize the database manually. Guacamole will +not automatically create its own tables, but SQL scripts are provided to do +this. + +Once the Guacamole image is running, Guacamole will be accessible at +`http://[address of container]:8080/guacamole/`. The instructions below use the +`-p 8080:8080` option to expose this port at the level of the machine hosting +Docker, as well. + +Deploying Guacamole with PostgreSQL authentication +-------------------------------------------------- + + docker run --name some-guacamole --link some-guacd:guacd \ + --link some-postgres:postgres \ + -e POSTGRES_DATABASE=guacamole_db \ + -e POSTGRES_USER=guacamole_user \ + -e POSTGRES_PASSWORD=some_password \ + -d -p 8080:8080 glyptodon/guacamole + +Linking Guacamole to PostgreSQL requires three environment variables. If any of +these environment variables are omitted, you will receive an error message, and +the image will stop: + +1. `POSTGRES_DATABASE` - The name of the database to use for Guacamole authentication. +2. `POSTGRES_USER` - The user that Guacamole will use to connect to PostgreSQL. +3. `POSTGRES_PASSWORD` - The password that Guacamole will provide when connecting to PostgreSQL as `POSTGRES_USER`. + +### Initializing the PostgreSQL database + +If your database is not already initialized with the Guacamole schema, you will +need to do so prior to using Guacamole. A convenience script for generating the +necessary SQL to do this is included in the Guacamole image. + +To generate a SQL script which can be used to initialize a fresh PostgreSQL +database +[as documented in the Guacamole manual](http://guacamole.incubator.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-postgresql): + + docker run --rm glyptodon/guacamole /opt/guacamole/bin/initdb.sh --postgres > initdb.sql + +Alternatively, you can use the SQL scripts included with +[guacamole-auth-jdbc](http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-jdbc-0.9.6.tar.gz/download). + +Once this script is generated, you must: + +1. Create a database for Guacamole within PostgreSQL, such as `guacamole_db`. +2. Run the script on the newly-created database. +3. Create a user for Guacamole within PostgreSQL with access to the tables and + sequences of this database, such as `guacamole_user`. + +The process for doing this via the `psql` and `createdb` utilities included +with PostgreSQL is documented in +[the Guacamole manual](http://guacamole.incubator.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-postgresql). + +Deploying Guacamole with MySQL authentication +-------------------------------------------------- + + docker run --name some-guacamole --link some-guacd:guacd \ + --link some-mysql:mysql \ + -e MYSQL_DATABASE=guacamole_db \ + -e MYSQL_USER=guacamole_user \ + -e MYSQL_PASSWORD=some_password \ + -d -p 8080:8080 glyptodon/guacamole + +Linking Guacamole to MySQL requires three environment variables. If any of +these environment variables are omitted, you will receive an error message, and +the image will stop: + +1. `MYSQL_DATABASE` - The name of the database to use for Guacamole authentication. +2. `MYSQL_USER` - The user that Guacamole will use to connect to MySQL. +3. `MYSQL_PASSWORD` - The password that Guacamole will provide when connecting to MySQL as `MYSQL_USER`. + +### Initializing the MySQL database + +If your database is not already initialized with the Guacamole schema, you will +need to do so prior to using Guacamole. A convenience script for generating the +necessary SQL to do this is included in the Guacamole image. + +To generate a SQL script which can be used to initialize a fresh MySQL database +[as documented in the Guacamole manual](http://guacamole.incubator.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-mysql): + + docker run --rm glyptodon/guacamole /opt/guacamole/bin/initdb.sh --mysql > initdb.sql + +Alternatively, you can use the SQL scripts included with +[guacamole-auth-jdbc](http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-jdbc-0.9.6.tar.gz/download). + +Once this script is generated, you must: + +1. Create a database for Guacamole within MySQL, such as `guacamole_db`. +2. Create a user for Guacamole within MySQL with access to this database, such + as `guacamole_user`. +3. Run the script on the newly-created database. + +The process for doing this via the `mysql` utility included with MySQL is +documented in +[the Guacamole manual](http://guacamole.incubator.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-mysql). + +Reporting issues +================ + +Please report any bugs encountered by opening a new issue in +[our JIRA](https://issues.apache.org/jira/browse/GUACAMOLE/). + diff --git a/guacamole-docker/bin/download-guacamole.sh b/guacamole-docker/bin/download-guacamole.sh new file mode 100755 index 000000000..2feca4f0d --- /dev/null +++ b/guacamole-docker/bin/download-guacamole.sh @@ -0,0 +1,49 @@ +#!/bin/sh -e +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +## +## @fn download-guacamole.sh +## +## Downloads Guacamole, saving the specified version to "guacamole.war" within +## the given directory. +## +## @param VERSION +## The version of guacamole.war to download, such as "0.9.6". +## +## @param DESTINATION +## The directory to save guacamole.war within. +## + +VERSION="$1" +DESTINATION="$2" + +# +# Create destination, if it does not yet exist +# + +mkdir -p "$DESTINATION" + +# +# Download guacamole.war, placing in specified destination +# + +echo "Downloading Guacamole version $VERSION to $DESTINATION ..." +curl -L "http://sourceforge.net/projects/guacamole/files/current/binary/guacamole-${VERSION}.war" > "$DESTINATION/guacamole.war" + diff --git a/guacamole-docker/bin/download-jdbc-auth.sh b/guacamole-docker/bin/download-jdbc-auth.sh new file mode 100755 index 000000000..7ee31270a --- /dev/null +++ b/guacamole-docker/bin/download-jdbc-auth.sh @@ -0,0 +1,83 @@ +#!/bin/sh -e +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +## +## @fn download-jdbc-auth.sh +## +## Downloads JDBC authentication support, including any required JDBC drivers. +## The downloaded files will be grouped by their associated database type, with +## all MySQL files being placed within the "mysql/" subdirectory of the +## destination, and all PostgreSQL files being placed within the "postgresql/" +## subdirectory of the destination. +## +## @param VERSION +## The version of guacamole-auth-jdbc to download, such as "0.9.6". +## +## @param DESTINATION +## The directory to save downloaded files within. Note that this script +## will create database-specific subdirectories within this directory, +## and downloaded files will be thus grouped by their respected database +## types. +## + +VERSION="$1" +DESTINATION="$2" + +# +# Create destination, if it does not yet exist +# + +mkdir -p "$DESTINATION" + +# +# Download Guacamole JDBC auth +# + +echo "Downloading JDBC auth version $VERSION ..." +curl -L "http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-jdbc-$VERSION.tar.gz" | \ +tar -xz \ + -C "$DESTINATION" \ + --wildcards \ + --no-anchored \ + --strip-components=1 \ + "*.jar" \ + "*.sql" + +# +# Download MySQL JDBC driver +# + +echo "Downloading MySQL Connector/J ..." +curl -L "http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz" | \ +tar -xz \ + -C "$DESTINATION/mysql/" \ + --wildcards \ + --no-anchored \ + --no-wildcards-match-slash \ + --strip-components=1 \ + "mysql-connector-*.jar" + +# +# Download PostgreSQL JDBC driver +# + +echo "Downloading PostgreSQL JDBC driver ..." +curl -L "https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc41.jar" > "$DESTINATION/postgresql/postgresql-9.4-1201.jdbc41.jar" + diff --git a/guacamole-docker/bin/download-ldap-auth.sh b/guacamole-docker/bin/download-ldap-auth.sh new file mode 100755 index 000000000..f39a54dfd --- /dev/null +++ b/guacamole-docker/bin/download-ldap-auth.sh @@ -0,0 +1,62 @@ +#!/bin/sh -e +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +## +## @fn download-ldap-auth.sh +## +## Downloads LDAP authentication support. The LDAP authentication .jar file +## will be placed within the specified destination directory. +## +## @param VERSION +## The version of guacamole-auth-ldap to download, such as "0.9.6". +## +## @param DESTINATION +## The directory to save downloaded files within. +## + +VERSION="$1" +DESTINATION="$2" + +# +# Use ldap/ subdirectory within DESTINATION. +# + +DESTINATION="$DESTINATION/ldap" + +# +# Create destination, if it does not yet exist +# + +mkdir -p "$DESTINATION" + +# +# Download Guacamole LDAP auth +# + +echo "Downloading LDAP auth version $VERSION ..." +curl -L "http://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-ldap-$VERSION.tar.gz" | \ +tar -xz \ + -C "$DESTINATION" \ + --wildcards \ + --no-anchored \ + --xform="s#.*/##" \ + "*.jar" \ + "*.ldif" + diff --git a/guacamole-docker/bin/initdb.sh b/guacamole-docker/bin/initdb.sh new file mode 100755 index 000000000..f56da7467 --- /dev/null +++ b/guacamole-docker/bin/initdb.sh @@ -0,0 +1,69 @@ +#!/bin/sh -e +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +## +## @fn initdb.sh +## +## Generates a database initialization SQL script for a database of the given +## type. The SQL will be sent to STDOUT. +## +## @param DATABASE +## The database to generate the SQL script for. This may be either +## "--postgres", for PostgreSQL, or "--mysql" for MySQL. +## + +DATABASE="$1" + +## +## Prints usage information for this shell script and exits with an error code. +## Calling this function will immediately terminate execution of the script. +## +incorrect_usage() { + cat < "$GUACAMOLE_PROPERTIES" + fi + + # Set property + echo "$NAME: $VALUE" >> "$GUACAMOLE_PROPERTIES" + +} + +## +## Sets the given property to the given value within guacamole.properties only +## if a value is provided, creating guacamole.properties first if necessary. +## +## @param NAME +## The name of the property to set. +## +## @param VALUE +## The value to set the property to, if any. If omitted or empty, the +## property will not be set. +## +set_optional_property() { + + NAME="$1" + VALUE="$2" + + # Set the property only if a value is provided + if [ -n "$VALUE" ]; then + set_property "$NAME" "$VALUE" + fi + +} + +## +## Adds properties to guacamole.properties which select the MySQL +## authentication provider, and configure it to connect to the linked MySQL +## container. If a MySQL database is explicitly specified using the +## MYSQL_HOSTNAME and MYSQL_PORT environment variables, that will be used +## instead of a linked container. +## +associate_mysql() { + + # Use linked container if specified + if [ -n "$MYSQL_NAME" ]; then + MYSQL_HOSTNAME="$MYSQL_PORT_3306_TCP_ADDR" + MYSQL_PORT="$MYSQL_PORT_3306_TCP_PORT" + fi + + # Use default port if none specified + MYSQL_PORT="${MYSQL_PORT-3306}" + + # Verify required connection information is present + if [ -z "$MYSQL_HOSTNAME" -o -z "$MYSQL_PORT" ]; then + cat <