-
Notifications
You must be signed in to change notification settings - Fork 24
/
bootstrap.sh
executable file
·133 lines (105 loc) · 4.71 KB
/
bootstrap.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# This script attempts to bootstrap an environment, ready to
# use as a docker installation for SeAT.
# 2018 - 2023 @leonjza
set -e
SEAT_DOCKER_INSTALL=/opt/seat-docker
SEAT_GITHUB_BRANCH=master
echo "SeAT Docker Bootstrap"
echo
echo "This script will install docker, docker-compose, download"
echo "all of the nessesary container and finally start up a fresh"
echo "SeAT installation."
echo
echo "Everything will live in $SEAT_DOCKER_INSTALL"
read -p "Are you sure you want to continue? [Y/n] " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Please type \"y\" to continue"
exit 1
fi
# Running as root?
if (( $EUID != 0 )); then
echo "Please run as root"
exit
fi
# Have curl?
if ! [ -x "$(command -v curl)" ]; then
echo "curl is not installed."
exit 1
fi
# Have docker?
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed. Installing..."
sh <(curl -fsSL get.docker.com)
echo "Docker installed"
fi
# Make sure /opt/seat-docker exists
echo "Ensuring $SEAT_DOCKER_INSTALL is available..."
mkdir -p $SEAT_DOCKER_INSTALL
cd $SEAT_DOCKER_INSTALL
echo # (optional) move to a new line
echo "Grabbing docker-compose and .env file"
curl -L https://raw.githubusercontent.com/eveseat/seat-docker/$SEAT_GITHUB_BRANCH/docker-compose.yml -o $SEAT_DOCKER_INSTALL/docker-compose.yml
curl -L https://raw.githubusercontent.com/eveseat/seat-docker/$SEAT_GITHUB_BRANCH/docker-compose.mariadb.yml -o $SEAT_DOCKER_INSTALL/docker-compose.mariadb.yml
curl -L https://raw.githubusercontent.com/eveseat/seat-docker/$SEAT_GITHUB_BRANCH/docker-compose.traefik.yml -o $SEAT_DOCKER_INSTALL/docker-compose.traefik.yml
curl -L https://raw.githubusercontent.com/eveseat/seat-docker/$SEAT_GITHUB_BRANCH/docker-compose.proxy.yml -o $SEAT_DOCKER_INSTALL/docker-compose.proxy.yml
curl -L https://raw.githubusercontent.com/eveseat/seat-docker/$SEAT_GITHUB_BRANCH/.env.example -o $SEAT_DOCKER_INSTALL/.env
echo "Generating a random database password and writing it to the .env file."
sed -i -- 's/DB_PASSWORD=i_should_be_changed/DB_PASSWORD='$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c22 ; echo '')'/g' .env
echo "Generating an application key and writing it to the .env file."
sed -i -- 's/APP_KEY=insecure/APP_KEY='$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c32 ; echo '')'/g' .env
echo # (optional) move to a new line
echo "Setup the domain"
while true; do
while [ -z "$SEAT_DOMAIN" ]
do
read -p "SeAT domain (eg: seat.domain.tld): " SEAT_DOMAIN
done
read -p "SeAT will be served over https://${SEAT_DOMAIN} - is that correct ? [Y/n]" -n 1 -r
echo # (optional) move to a new line
case $REPLY in
[yY]|"") sed -i -- 's/SEAT_DOMAIN=seat.domain.tld/SEAT_DOMAIN='"${SEAT_DOMAIN}"'/g' .env
break ;;
*) SEAT_DOMAIN=''
echo "No changes have been applied. Please provide the domain on which SeAT will be served"
esac
done
echo "Enabling SSL entrypoint"
echo "Please provide a valid e-mail address for Let's Encrypt account creation (this service will handle your SSL certificates) - leave empty to not use SSL"
read -p "e-mail: " ACME_EMAIL
if [ -n "$ACME_EMAIL" ]; then
sed -i -- 's/TRAEFIK_ACME_EMAIL=you@domain.tld/TRAEFIK_ACME_EMAIL='"${ACME_EMAIL}"'/g' .env
sed -i -- 's/ #- "traefik.http.routers.seat-web.tls.certResolver=primary"/ - "traefik.http.routers.seat-web.tls.certResolver=primary"/g' docker-compose.yml
else
echo "No e-mail address has been provided, SSL will not be available"
echo "SeAT will be reachable on http://${SEAT_DOMAIN} only"
fi
echo "Preparing an acme.json file for Traefik and Let's Encrypt"
mkdir acme
touch acme/acme.json
chmod 600 acme/acme.json
echo # (optional) move to a new line
echo "Setup EVE Online Application"
echo "Please go to https://developers.eveonline.com/applications/create in order to create a new application"
if [ -n "$ACME_EMAIL" ]; then
echo "You must use https://${SEAT_DOMAIN}/auth/eve/callback as callback"
else
echo "You must use http://${SEAT_DOMAIN}/auth/eve/callback as callback"
fi
while [ -z "$CLIENT_ID" ]
do
read -p "Client ID: " CLIENT_ID
done
while [ -z "$CLIENT_SECRET" ]
do
read -p "Secret Key: " CLIENT_SECRET
done
sed -i -- 's/EVE_CLIENT_ID=null/EVE_CLIENT_ID='"${CLIENT_ID}"'/g' .env
sed -i -- 's/EVE_CLIENT_SECRET=null/EVE_CLIENT_SECRET='"${CLIENT_SECRET}"'/g' .env
echo # (optional) move to a new line
echo "Starting docker stack. This will download the images too. Please wait..."
docker compose -f docker-compose.yml -f docker-compose.mariadb.yml -f docker-compose.traefik.yml up -d
echo # (optional) move to a new line
echo "Done! The containers are now initialising. To check what is happening, run 'docker-compose logs --tail 5 -f' in ${SEAT_DOCKER_INSTALL}"