-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·72 lines (61 loc) · 2.3 KB
/
setup.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
#!/usr/bin/env bash
# shellcheck disable=SC2154
export DEBIAN_FRONTEND="noninteractive"
sudo apt update -y
sudo apt install python3 git nginx python3-certbot-nginx python3-pip -y
cd /tmp || exit
sudo certbot --noninteractive --nginx --agree-tos --email [email protected] --domain verify.thescriptgroup.in
cat << EOF | sudo tee /etc/nginx/sites-available/verify.thescriptgroup.in
server {
listen 80;
server_name verify.thescriptgroup.in;
location ^~ /.well-known/acme-challenge/ {
root /var/www/html;
}
location / {
return 301 https://verify.thescriptgroup.in\$request_uri;
}
}
server {
listen 443 ssl;
server_name verify.thescriptgroup.in;
ssl_certificate /etc/letsencrypt/live/verify.thescriptgroup.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/verify.thescriptgroup.in/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location /static {
root /home/deploy/Hestia/new_app;
try_files \$uri \$uri/ =404;
}
location ^~ / {
proxy_pass http://127.0.0.1:8001;
proxy_redirect off;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/verify.thescriptgroup.in /etc/nginx/sites-enabled/verify.thescriptgroup.in
sudo rm -fv /etc/nginx/sites-{available,enabled}/default
sudo nginx -s reload
cat << EOF | sudo tee /etc/systemd/system/hestia.service
[Unit]
Description=Deploy Hestia server
After=network.target
[Service]
User=deploy
WorkingDirectory=/home/deploy/Hestia
ExecStart=/home/deploy/Hestia/venv/bin/gunicorn --workers=2 hestia.wsgi -b :8001
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable hestia
echo "systemd unit `hestia` is setup, start it whenever ready"
echo '30 2 * * * /usr/bin/certbot renew --noninteractive --renew-hook "/usr/sbin/nginx -s reload" >> /var/log/le-renew.log' > /tmp/cron
sudo crontab /tmp/cron
rm -v /tmp/cron
cd - || exit
echo "Setup your configuration file and run the application! (make sure its running on port 8001"