-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup_configs.sh
More file actions
executable file
·76 lines (58 loc) · 2.92 KB
/
setup_configs.sh
File metadata and controls
executable file
·76 lines (58 loc) · 2.92 KB
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
#!/bin/bash
# These values are required for your SSL cert to work. Please add them!
domain=mydomain.com
email=ssl@mydomain.com
echo "Creating folders for docker volumes!"
mkdir -p data/nginx/conf.d
mkdir -p data/nginx/ssl
mkdir -p data/certbot/conf
mkdir -p data/certbot/www
mkdir -p data/ipfs
path=/etc/letsencrypt/live/$domain
mkdir -p ./data/certbot/conf/live/$domain
data_path=./data/certbot
mkdir -p "$data_path/conf"
temp_ssl_path=/etc/nginx/ssl
docker-compose up -d ipfs_host
echo "Sleeping for 5 seconds, then trying to print connected peers. If you don't see any, something might be wrong!"
sleep 5
echo $(docker-compose exec ipfs_host ipfs swarm peers)
echo "Now let's also test if we can grab some data. You should see a greeting printed to the screen next!"
echo $(curl http://127.0.0.1:8080/ipfs/QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A)
echo "Now setting up ipfs-configs!"
docker-compose exec ipfs_host ipfs config Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/8081/ws", "/ip6/::/tcp/4001"]' --json
docker-compose exec ipfs_host ipfs config --bool Swarm.RelayService.Enabled true
docker-compose exec ipfs_host ipfs config --bool Swarm.RelayClient.Enabled true
docker-compose exec ipfs_host ipfs config AutoNAT.ServiceMode '"enabled"' --json
echo "Adding config files to the volumes!"
cp nginx.conf ./data/nginx/conf.d/app.conf
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf"
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem"
echo "Now creating a temporary certificate so nginx can start. Make sure you set your domain in the bash file as well!"
sleep 5
docker-compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:1024 -days 1\
-keyout '$temp_ssl_path/privkey.pem' \
-out '$temp_ssl_path/fullchain.pem' \
-subj '/CN=localhost'" certbot
echo "Now starting up ipfs and nginx. Printing logs of nginx, if there's any errors stop this script and debug!"
docker-compose up -d ipfs_host
docker-compose up -d nginx
echo $(docker-compose logs nginx)
sleep 5
echo "Deleting temporary cert and starting grabbing the actual one!"
echo "For the final cert you'll need to answer some questions. Please do so!"
docker-compose run --rm --entrypoint "\
certbot certonly --webroot -w /var/www/certbot \
--email $email \
-d $domain \
--rsa-key-size 4096 \
--agree-tos \
--force-renewal" certbot
docker-compose run --rm --entrypoint "\
ln -s -f $path/privkey.pem $temp_ssl_path/privkey.pem" certbot
docker-compose run --rm --entrypoint "\
ln -s -f $path/fullchain.pem $temp_ssl_path/fullchain.pem" certbot
docker-compose down
echo "Everything should be ready now! Starting..."
docker-compose up -d