74 lines
1.6 KiB
Bash
74 lines
1.6 KiB
Bash
#!/bin/bash
|
||
rep="guacamole"
|
||
|
||
apt-get update
|
||
apt-get install -y curl wget vim
|
||
|
||
if ! which docker ; then
|
||
curl -s -o getdocker.sh https://get.docker.com
|
||
bash getdocker.sh
|
||
gpasswd -a vagrant docker
|
||
fi
|
||
|
||
[[ -e "$rep" ]] || mkdir "$rep"
|
||
|
||
cd "$rep" || exit 1
|
||
|
||
cat > docker-compose.yml <<EOT
|
||
version: '3'
|
||
services:
|
||
|
||
guacdb:
|
||
container_name: guacdb
|
||
image: mariadb/server:latest
|
||
restart: unless-stopped
|
||
environment:
|
||
MYSQL_ROOT_PASSWORD: 'MariaDBRootPSW'
|
||
MYSQL_DATABASE: 'guacamole_db'
|
||
MYSQL_USER: 'guacamole_user'
|
||
MYSQL_PASSWORD: 'MariaDBUserPSW'
|
||
volumes:
|
||
- 'guacdb-data:/var/lib/mysql'
|
||
- ./initdb:/docker-entrypoint-initdb.d
|
||
|
||
guacd:
|
||
container_name: guacd
|
||
image: guacamole/guacd
|
||
restart: unless-stopped
|
||
|
||
guacamole:
|
||
container_name: guacamole
|
||
image: 'guacamole/guacamole:latest'
|
||
restart: unless-stopped
|
||
ports:
|
||
- '8080:8080'
|
||
environment:
|
||
GUACD_HOSTNAME: "guacd"
|
||
MYSQL_HOSTNAME: "guacdb"
|
||
MYSQL_DATABASE: "guacamole_db"
|
||
MYSQL_USER: "guacamole_user"
|
||
MYSQL_PASSWORD: "MariaDBUserPSW"
|
||
depends_on:
|
||
- guacdb
|
||
- guacd
|
||
|
||
volumes:
|
||
guacdb-data:
|
||
EOT
|
||
|
||
|
||
docker compose pull
|
||
[[ -e "initdb" ]] || mkdir "initdb"
|
||
cat > initdb/initdb-1.sql <<EOT
|
||
CREATE DATABASE guacamole_db;
|
||
CREATE USER 'guacamole_user'@'%' IDENTIFIED BY 'StrongPassw0rd';
|
||
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'%';
|
||
FLUSH PRIVILEGES;
|
||
EOT
|
||
|
||
echo "USE guacamole_db ;" > initdb/initdb-2.sql
|
||
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql >> initdb/initdb-2.sql
|
||
docker compose up -d
|
||
|
||
|