Browse Source
Resolve "Add Apache Guacamole service" Closes #137 See merge request cyber5k/mistborn!64merge-requests/65/merge
5 changed files with 128 additions and 1 deletions
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
version: '3' |
||||
|
||||
# services |
||||
services: |
||||
# guacd |
||||
guacd: |
||||
container_name: mistborn_production_guacd |
||||
image: guacamole/guacd |
||||
networks: |
||||
guacnetwork: |
||||
restart: unless-stopped |
||||
volumes: |
||||
- ../../mistborn_volumes/extra/guacamole/drive:/drive:rw |
||||
- ../../mistborn_volumes/extra/guacamole/record:/record:rw |
||||
|
||||
|
||||
# postgres |
||||
guac_postgres: |
||||
container_name: mistborn_production_guac_postgres |
||||
env_file: |
||||
- ../.envs/.production/.guacamole |
||||
environment: |
||||
PGDATA: /var/lib/postgresql/data/guacamole |
||||
image: postgres |
||||
networks: |
||||
guacnetwork: |
||||
restart: unless-stopped |
||||
volumes: |
||||
- ../../mistborn_volumes/extra/guacamole/init:/docker-entrypoint-initdb.d:ro |
||||
- ../../mistborn_volumes/extra/guacamole/data:/var/lib/postgresql/data:rw |
||||
|
||||
|
||||
# guacamole |
||||
guacamole: |
||||
container_name: mistborn_production_guacamole |
||||
labels: |
||||
- "traefik.enable=true" |
||||
- "traefik.http.routers.guacamole-http.rule=Host(`guac.mistborn`)" |
||||
- "traefik.http.routers.guacamole-http.entrypoints=web" |
||||
- "traefik.http.routers.guacamole-http.middlewares=mistborn_auth@file" |
||||
- "traefik.http.routers.guacamole-https.rule=Host(`guac.mistborn`)" |
||||
- "traefik.http.routers.guacamole-https.entrypoints=websecure" |
||||
- "traefik.http.routers.guacamole-https.middlewares=mistborn_auth@file" |
||||
- "traefik.http.routers.guacamole-https.tls.certresolver=basic" |
||||
- "traefik.http.services.guacamole-service.loadbalancer.server.port=8080" |
||||
depends_on: |
||||
- guacd |
||||
- guac_postgres |
||||
environment: |
||||
GUACD_HOSTNAME: guacd |
||||
GUACD_PORT: 4822 |
||||
#GUACAMOLE_HOME: /config |
||||
env_file: |
||||
- ../.envs/.production/.guacamole |
||||
image: guacamole/guacamole |
||||
links: |
||||
- guacd |
||||
networks: |
||||
guacnetwork: |
||||
#ports: |
||||
## enable next line if not using nginx |
||||
## - 8080:8080/tcp # Guacamole is on :8080/guacamole, not /. |
||||
## enable next line when using nginx |
||||
#- 8080/tcp |
||||
restart: unless-stopped |
||||
|
||||
# networks |
||||
# create a network 'guacnetwork' in mode 'bridged' |
||||
networks: |
||||
guacnetwork: |
||||
driver: bridge |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash |
||||
|
||||
mkdir -p /opt/mistborn_volumes/extra/guacamole/init/ >/dev/null 2>&1 |
||||
chmod -R +x /opt/mistborn_volumes/extra/guacamole/init/ |
||||
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > /opt/mistborn_volumes/extra/guacamole/init/initdb.sql |
||||
|
||||
# grab values in initdb.sql to replace |
||||
HEXSTRINGS=($(egrep -o [0-9a-fA-F]{64} /opt/mistborn_volumes/extra/guacamole/init/initdb.sql)) |
||||
|
||||
# reset default password in init.db |
||||
SALT=$(python3 -c "import secrets; import string; print(f''.join([secrets.choice('0123456789ABCDEF') for x in range(64)]))") |
||||
GUAC_PASSWORD_HASHED=$(echo -n "${MISTBORN_DEFAULT_PASSWORD}${SALT}" | sha256sum | awk '{print $1}' | tr a-z A-Z) |
||||
|
||||
sed -i "s/${HEXSTRINGS[1]}/$SALT/" /opt/mistborn_volumes/extra/guacamole/init/initdb.sql |
||||
sed -i "s/${HEXSTRINGS[0]}/$GUAC_PASSWORD_HASHED/" /opt/mistborn_volumes/extra/guacamole/init/initdb.sql |
||||
sed -i "s/guacadmin/mistborn/g" /opt/mistborn_volumes/extra/guacamole/init/initdb.sql |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
[Unit] |
||||
Description=Mistborn Guacamole |
||||
Requires=Mistborn-base.service |
||||
After=Mistborn-base.service |
||||
PartOf=Mistborn-base.service |
||||
|
||||
[Service] |
||||
Restart=always |
||||
User=root |
||||
Group=docker |
||||
PermissionsStartOnly=true |
||||
EnvironmentFile=/opt/mistborn/.envs/.production/.guacamole |
||||
ExecStartPre=/opt/mistborn/scripts/env/guacamole_init.sh |
||||
# Shutdown container (if running) when unit is stopped |
||||
ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/extra/guacamole.yml down |
||||
|
||||
# Start container when unit is started |
||||
ExecStart=/usr/local/bin/docker-compose -f /opt/mistborn/extra/guacamole.yml up --build |
||||
# Stop container when unit is stopped |
||||
ExecStop=/usr/local/bin/docker-compose -f /opt/mistborn/extra/guacamole.yml down |
||||
# Post stop |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
||||
Loading…
Reference in new issue