Skip to content

Instantly share code, notes, and snippets.

@ericdraken
Forked from shawngmc/guacamole_setup.sh
Last active August 4, 2019 22:08
Show Gist options
  • Save ericdraken/bd0a86aafdd0082b2e148eb86a7907f1 to your computer and use it in GitHub Desktop.
Save ericdraken/bd0a86aafdd0082b2e148eb86a7907f1 to your computer and use it in GitHub Desktop.
Guacamole Docker Setup for Raspberry Pi 3
#!/bin/bash
. .env
# Used from .env
# PASSWD: The postgres password
# Set up Guacd
echo Creating guacd container...
docker run -d \
--name guacd \
--restart=unless-stopped \
-e TZ="America/Vancouver" \
guacamole/guacd
# Set up Postgres image
echo Creating postgres container...
docker run -d \
--name guac-postgres \
--restart=unless-stopped \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=$PASSWD \
-e TZ="America/Vancouver" \
-v /var/guacamole/database:/var/lib/postgresql/data \
postgres
echo "Do you want to initialize the database? If you already have a working guacamole schema, choose no! (yes/no)"
read input
if [ "$input" == "yes" ]
then
echo Creating the database, user, and applying the schema per:
echo http://guacamole.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-postgresql
# make sql script
echo Making init DB scripts...
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > /tmp/initdb.sql
# Copy scripts into postgres
echo Copying init DB script into postgres container...
docker cp /tmp/initdb.sql guac-postgres:/initdb.sql
# Create the DB
echo Creating guacamole db...
docker exec -u postgres guac-postgres createdb guacamole_db
# Run the DB init
echo Pre-populating guacamole db...
docker exec -u postgres guac-postgres psql guacamole_db postgres -f /initdb.sql
fi
# Set up guacamole for Raspberry Pi 3+
echo Creating guacamole container
docker run -d \
--name guacamole \
--link guacd:guacd \
--link guac-postgres:postgres \
--restart=unless-stopped \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=$PASSWD \
-e POSTGRES_DATABASE=guacamole_db \
-e TZ="America/Vancouver" \
-v /var/guacamole/guacamole:/guac \
-e GUACAMOLE_HOME=/guac \
-p 8080:8080 \
oznu/guacamole:armhf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment