forked from naologic/nginx-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
letsencrypt.sh
35 lines (30 loc) · 872 Bytes
/
letsencrypt.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
#!/bin/bash
. config.sh
. app/colors.sh
# Install: let's encrypt certbot
#function pre_install() {}
function install() {
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
}
function post_install() {
# I need port :80
service nginx stop
}
function install_configs() {
# Run: generate certificate
[ ! -f /etc/letsencrypt/renewal/${SRV_URL}.conf ] && {
/bin/bash /opt/letsencrypt/letsencrypt-auto certonly --standalone -d ${SRV_URL}
service nginx stop
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
service nginx start
}
}
function install_services() {
# install cron
local CRON="/bin/bash /opt/letsencrypt/letsencrypt-auto renew --force-renewal"
( crontab -l | grep -v "$CRON" ; echo "0 0 1 * * ${CRON}" ) | crontab -
}
install
post_install
install_configs
install_services