detect certbot and acme.sh and enable and start path
This commit is contained in:
parent
d32caa3762
commit
bc000e0bd8
@ -25,4 +25,7 @@ Update Domain-Name in files and copy them to:
|
||||
Don't forget to:
|
||||
```
|
||||
chmod +x /usr/local/bin/le_services_restart.sh
|
||||
systemctl enable le-services-restart.path
|
||||
systemctl start le-services-restart.path
|
||||
|
||||
```
|
||||
|
@ -2,7 +2,8 @@
|
||||
Description="Monitor the server certificate files to trigger a services restart after the certificates has been renewed"
|
||||
|
||||
[Path]
|
||||
PathModified=/root/.acme.sh/server.example.com/
|
||||
PathModified=/root/.acme.sh/SERVER.EXAMPLE.COM
|
||||
PathModified=/etc/letsencrypt/live/SERVER.EXAMPLE.COM
|
||||
Unit=le-services-restart.service
|
||||
|
||||
[Install]
|
||||
|
@ -8,7 +8,23 @@
|
||||
# Short-Description: LE SERVICES CERT AUTO UPDATER
|
||||
# Description: Restart services automatically when a new Let's Encrypt certificate is issued.
|
||||
### END INIT INFO
|
||||
|
||||
# postfix
|
||||
domain=SERVER.EXAMPLE.COM
|
||||
certfile=$(mktemp)
|
||||
keyfile=$(mktemp)
|
||||
|
||||
if [ -e "/etc/letsencrypt/live/$domain/fullchain.pem" ]; then
|
||||
cat /etc/letsencrypt/live/$domain/fullchain.pem > $certfile
|
||||
cat /etc/letsencrypt/live/$domain/privkey.pem > $keyfile
|
||||
elif [ -e "/root/.acme.sh/$domain/$domain.cer" ]; then
|
||||
cat /root/.acme.sh/$domain/ca.cer > $certfile
|
||||
cat /root/.acme.sh/$domain/$domain.cer >> $certfile
|
||||
cat /root/.acme.sh/$domain/$domain.key > $keyfile
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILE=/etc/postfix/main.cf
|
||||
if [ -f "$FILE" ]; then
|
||||
systemctl restart influxd
|
||||
@ -23,25 +39,27 @@ fi
|
||||
# pro-tftp
|
||||
FILE=/etc/pure-ftpd/pure-ftpd.conf
|
||||
if [ -f "$FILE" ]; then
|
||||
cat /root/.acme.sh/server.example.com/fullchain.pem > /etc/ssl/private/pure-ftpd.pem
|
||||
cat /root/.acme.sh/server.example.com/server.example.com.key >> /etc/ssl/private/pure-ftpd.pem
|
||||
cat $certfile > /etc/ssl/private/pure-ftpd.pem
|
||||
cat $keyfile >> /etc/ssl/private/pure-ftpd.pem
|
||||
systemctl restart pure-ftpd-mysql.service
|
||||
fi
|
||||
|
||||
# influxdb
|
||||
FILE=/etc/influxdb/influxdb.pem
|
||||
if [ -f "$FILE" ]; then
|
||||
cat /root/.acme.sh/server.example.com/fullchain.pem > /etc/influxdb/influxdb.pem
|
||||
cat /etc/letsencrypt/live/server.example.com/server.example.com.key > /etc/influxdb/influxdb.key
|
||||
cat $certfile > /etc/influxdb/influxdb.pem
|
||||
cat $keyfile > /etc/influxdb/influxdb.key
|
||||
systemctl restart influxd
|
||||
fi
|
||||
|
||||
# coturn
|
||||
FILE=/usr/local/etc/turn_server_cert.pem
|
||||
if [ -f "$FILE" ]; then
|
||||
cat /root/.acme.sh/server.example.com/fullchain.pem > /usr/local/etc/turn_server_cert.pem
|
||||
cat /etc/letsencrypt/live/server.example.com/server.example.com.key > /usr/local/etc/turn_server_pkey.pem
|
||||
cat $certfile > /usr/local/etc/turn_server_cert.pem
|
||||
cat $keyfile > /usr/local/etc/turn_server_pkey.pem
|
||||
chown turnserver /usr/local/etc/turn_server*
|
||||
systemctl restart coturn
|
||||
fi
|
||||
|
||||
rm $certfile
|
||||
rm $keyfile
|
Loading…
Reference in New Issue
Block a user