-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_installer.sh
72 lines (62 loc) · 2.47 KB
/
auto_installer.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
#!/bin/bash
cat << 'EOF'
_____ __ _ _ ___ _ _____ _ _ _
|_ _| / _(_) | / _ \ | | |_ _| | | | | |
| |_ __ __ _ ___| |_ _| | _/ /_\ \_ _| |_ ___ | | _ __ ___| |_ __ _| | | ___ _ __
| | '__/ _` |/ _ \ _| | |/ / _ | | | | __/ _ \ | || '_ \/ __| __/ _` | | |/ _ \ '__|
| | | | (_| | __/ | | | <| | | | |_| | || (_) || || | | \__ \ || (_| | | | __/ |
\_/_| \__,_|\___|_| |_|_|\_\_| |_/\__,_|\__\___/\___/_| |_|___/\__\__,_|_|_|\___|_|
EOF
VERSION='0.0.2'
echo "Version : $VERSION"
sudo apt-get update -y && apt-get upgrade -y
# Checks if htpasswd is available or installs it otherwise
which htpasswd >/dev/null || (sudo apt-get install apache2-utils)
# Checks if git is installed
which git >/dev/null || (sudo apt-get install git)
# Checks if docker is installed (if not installs it alongside docker-compose)
which docker >/dev/null || (sudo apt-get install docker docker-compose)
# Starting configuration
echo "Starting configuration..."
mkdir traefik
cd traefik
git clone https://github.com/HugoDemaret/Traefik-docker.git
mv Traefik-docker/* .
rm -r Traefik-docker/.git*
rmdir Traefik-docker
# Taking the required information
read -p "Enter your email address:" emailaddress
read -p "Enter the url " url
echo "Your Traefik monitoring app will be deployed at:"
echo "traefik."$url
echo "|----------------------------|"
echo "|--Configuring your traefik--|"
echo "|----------------------------|"
# Replaces by the user information
sed -i -e"s/\/PATH\/TO/./g" docker-compose.yml
sed -i -e"s/\/PATH\/TO/./g" start.sh
sed -i -e"s/email@example.com/$emailaddress/g" traefik.toml
sed -i -e"s/your.url/$url/g" docker-compose.yml
echo "Done !"
echo "|----------------------------|"
echo "|--Creating authentication---|"
echo "|----------------------------|"
# Asks username and password
read -p "User: " USER
read -p "Password: " PW
# Generate strings
string=$(htpasswd -nbB $USER $PW)
# Escapes string for docker-compose
credentials=$(echo "$string" | sed -e"s/\$/\$\$/g")
sed -i -e"s/name_of_user\:hashed_password/$credentials/g" docker-compose.yml
# Modify the owner (so it is root)
path=$(pwd)
chown 0:0 $path
# Creates acme.json and sets its permissions
touch acme.json
chmod 600 acme.json
# expose-network creation
docker network create expose-network --subnet=172.20.0.0/16
echo "|----------------------------|"
echo "|------------DONE------------|"
echo "|----------------------------|"