blob: 221e12b750a614a2f9d8eab862cb263227a6195e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/bash
# create a circus network containing most of the containers making interaction
# on a network layer in between the containers possible
docker network create circus 2> /dev/zero
# create a network containing the database storing the challenges making it
# possible that containers in the same network can interact with the database
docker network create circus_db 2> /dev/zero
echo "Welcome to the circus-setup tool!"
echo "Please make sure you have the following services/tools installed before continuing:"
echo "- docker (with a running docker-server)"
echo "- docker-compose"
echo "- htpasswd (apache2-utils)"
#
# General confiuration
#
# get a hostname and a ctfname from the user
read -e -p "HOSTNAME: " -i "ctf.flexerilla.team" HOSTNAME
read -e -p "CTFNAME: " -i "FlexCTF" CTFNAME
# Write the vars to the .env file
echo "HOSTNAME=$HOSTNAME" > .env
echo "CTFNAME=$CTFNAME" >> .env
#
# Traefik configuration
#
# Read Traefik creds from the user
read -e -p "Traefik username: " -i "traefik" TRAEFIK_USER
read -e -p "Traefik password: " -i "secret" TRAEFIK_PASSWORD
# Create the traefik creds string (user:pass)
TRAEFIK_CREDS=$(htpasswd -nb $TRAEFIK_USER $TRAEFIK_PASSWORD)
# Write the creds to the traefik users file
echo "$TRAEFIK_CREDS" >> traefik_users
#
# Grafana configuration
#
# Grafana settings
read -e -p "Grafana server: " -i "https://grafana.$HOSTNAME:3000" GF_SERVER_ROOT_URL
read -e -p "Grafana admin pwd: " -i "secret" GF_SECURITY_ADMIN_PASSWORD
# Write the Grafana settings into the grafana.env file
echo "GF_SERVER_ROOT_URL=$GF_SERVER_ROOT_URL" > grafana.env
echo "GF_SECURITY_ADMIN_PASSWORD=$GF_SECURITY_ADMIN_PASSWORD" >> grafana.env
#
# Pull images from the darknebu.la registry
#
echo "Login to the darknebu.la registry to pull the images:"
docker login registry.darknebu.la
# pull some docker images needed from the darknebu.la registry such as the
# companion container and the vpn container
echo "Pulling docker images needed..."
docker pull registry.darknebu.la/circus/companion:latest
docker pull registry.darknebu.la/circus/vpn:latest
#
# Start the docker-compose
#
# Ask if the circus should be started
read -p "Do you want to start the circus now? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# start the docker-compose
docker-compose -f $(pwd)/docker-compose.yml up -d
|