|
@@ -0,0 +1,33 @@
|
|
|
+#!/bin/bash
|
|
|
+
|
|
|
+# Get query for DB creation
|
|
|
+docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql > initdb.sql
|
|
|
+
|
|
|
+# Create query to update the guacadmin password
|
|
|
+cat >user.sql <<'EOL'
|
|
|
+SET @salt = UNHEX(SHA2(UUID(), 256));
|
|
|
+UPDATE guacamole_user
|
|
|
+ SET password_salt = @salt, password_hash = UNHEX(SHA2(CONCAT('_PASSWORD_', HEX(@salt)), 256))
|
|
|
+ WHERE user_id = 1;
|
|
|
+EOL
|
|
|
+
|
|
|
+source .env
|
|
|
+sed -i user.sql -e "s/_PASSWORD_/$PASSWORD/g"
|
|
|
+
|
|
|
+# Start mysql and create database as it is up
|
|
|
+docker-compose up -d mysql \
|
|
|
+ && docker cp initdb.sql mysql:/ \
|
|
|
+ && docker exec mysql \
|
|
|
+ sh -c "while [ ! -S /var/run/mysqld/mysqld.sock ] ; do sleep 2 && echo 'Wait for mysql to come up...'; done; sleep 5; echo 'go'" \
|
|
|
+ && docker exec mysql \
|
|
|
+ sh -c "mysql --verbose --user=guacamole --password=guacamole guacamole < /initdb.sql" \
|
|
|
+ && docker exec mysql \
|
|
|
+ sh -c "mysql --verbose --user=guacamole --password=guacamole guacamole -e 'show tables;'"
|
|
|
+
|
|
|
+# Update guacadmin password
|
|
|
+docker cp user.sql mysql:/ \
|
|
|
+ && docker exec mysql \
|
|
|
+ sh -c "mysql --verbose --user=guacamole --password=guacamole guacamole < /user.sql" \
|
|
|
+
|
|
|
+# Start guacamole
|
|
|
+docker-compose up -d
|