2025-01-15 21:31:27 +01:00
|
|
|
#!/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
2025-01-15 21:40:28 +01:00
|
|
|
# Provides: LE SERVICES CERT AUTO UPDATER
|
2025-01-15 21:31:27 +01:00
|
|
|
# Required-Start: $local_fs $network
|
|
|
|
# Required-Stop: $local_fs
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
2025-01-15 21:40:28 +01:00
|
|
|
# Short-Description: LE SERVICES CERT AUTO UPDATER
|
|
|
|
# Description: Restart services automatically when a new Let's Encrypt certificate is issued.
|
2025-01-15 21:31:27 +01:00
|
|
|
### END INIT INFO
|
2025-01-16 20:43:45 +01:00
|
|
|
|
2025-01-15 21:53:55 +01:00
|
|
|
# postfix
|
2025-01-16 20:43:45 +01:00
|
|
|
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
|
|
|
|
|
2025-01-15 21:53:55 +01:00
|
|
|
FILE=/etc/postfix/main.cf
|
|
|
|
if [ -f "$FILE" ]; then
|
|
|
|
systemctl restart influxd
|
|
|
|
fi
|
|
|
|
|
|
|
|
# dovecot
|
|
|
|
FILE=/etc/dovecot/dovecot.conf
|
|
|
|
if [ -f "$FILE" ]; then
|
|
|
|
systemctl restart dovecot
|
|
|
|
fi
|
2025-01-15 21:40:28 +01:00
|
|
|
|
|
|
|
# pro-tftp
|
2025-01-15 21:53:55 +01:00
|
|
|
FILE=/etc/pure-ftpd/pure-ftpd.conf
|
|
|
|
if [ -f "$FILE" ]; then
|
2025-01-16 20:43:45 +01:00
|
|
|
cat $certfile > /etc/ssl/private/pure-ftpd.pem
|
|
|
|
cat $keyfile >> /etc/ssl/private/pure-ftpd.pem
|
2025-01-15 21:53:55 +01:00
|
|
|
systemctl restart pure-ftpd-mysql.service
|
|
|
|
fi
|
2025-01-15 21:40:28 +01:00
|
|
|
|
|
|
|
# influxdb
|
|
|
|
FILE=/etc/influxdb/influxdb.pem
|
|
|
|
if [ -f "$FILE" ]; then
|
2025-01-16 20:43:45 +01:00
|
|
|
cat $certfile > /etc/influxdb/influxdb.pem
|
|
|
|
cat $keyfile > /etc/influxdb/influxdb.key
|
2025-01-15 21:53:55 +01:00
|
|
|
systemctl restart influxd
|
2025-01-15 21:40:28 +01:00
|
|
|
fi
|
|
|
|
|
2025-01-15 21:53:55 +01:00
|
|
|
# coturn
|
|
|
|
FILE=/usr/local/etc/turn_server_cert.pem
|
|
|
|
if [ -f "$FILE" ]; then
|
2025-01-16 20:43:45 +01:00
|
|
|
cat $certfile > /usr/local/etc/turn_server_cert.pem
|
|
|
|
cat $keyfile > /usr/local/etc/turn_server_pkey.pem
|
2025-01-15 21:53:55 +01:00
|
|
|
chown turnserver /usr/local/etc/turn_server*
|
|
|
|
systemctl restart coturn
|
|
|
|
fi
|
2025-01-15 21:40:28 +01:00
|
|
|
|
2025-01-16 20:43:45 +01:00
|
|
|
rm $certfile
|
|
|
|
rm $keyfile
|