Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
WD=/opt/guacamole
mkdir -p $WD/{data,data/db,data/dbinit,setup}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: "3"
services:

  init-guacamole-db:
    image: guacamole/guacamole:latest
    command: ["/bin/sh", "-c", "test -e /init/initdb.sql && echo 'init file already exists' || /opt/guacamole/bin/initdb.sh --postgres > /init/initdb.sql" ]
    volumes:
      - type: bind
        source: /opt/guacamole/data/dbinit
        target: /init    

  postgres:
    container_name: postgres_guac
    image: postgres:latest
    hostname: postgres_guac
    volumes:
      - type: bind
        source: /opt/guacamole/data/dbinit
        target: /docker-entrypoint-initdb.d        
      - type: bind
        source: /opt/guacamole/data/db
        target: /var/lib/postgresql/data
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-guacdb}
      POSTGRES_PASSWORD: 
    depends_on:
      - init-guacamole-db

  guacd:
    container_name: guacd
    image: guacamole/guacd:latest
    hostname: guacd

  guac:
    container_name: guac
    image: guacamole/guacamole:latest
    hostname: guac
    ports:
      - "8428:8080"
    environment:
      GUACD_HOSTNAME: guacd
      POSTGRES_HOSTNAME: postgres
      POSTGRES_DATABASE: ${POSTGRES_USER:-guacdb}
      POSTGRES_USER: ${POSTGRES_USER:-guacdb}
      POSTGRES_PASSWORD:
    depends_on:
      - postgres
      - guacd

volumes:
  dbinit:
    driver: local
  dbdata:
    driver: local
EOF
chmod +x docker-compose.yaml

No Format
cd $WD/setup
cat << 'EOF'>.env
POSTGRES_USER=guacamoledbuser
POSTGRES_PASSWORD=guacamoledbuserpwd
EOF
chmod +x .env

No Format
WD=/opt/guacamole/setup
cat << EOF >$WD/guacamole.service.setup.sh
cat << EOL >/lib/systemd/system/guacamole.service
[Unit]
Description=guacamole_Docker
Requires=docker.service network-online.target

[Service]  

WorkingDirectory=$WD
ExecStartPre=docker-compose pull
Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name guacamole --project-directory $WD -f $WD/docker-compose.yaml up --force-recreate
ExecStop=/usr/bin/docker-compose --project-name guacamole --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable guacamole
systemctl restart guacamole
systemctl status guacamole
EOF
chmod +x $WD/guacamole.service.setup.sh
#$WD$WD/guacamole.service.setup.sh
#watch systemctl status guacamole.service