Skip to content

Instantly share code, notes, and snippets.

@mrksdiehl
Created July 28, 2017 15:01
Show Gist options
  • Save mrksdiehl/4be12c7a6337b908518bfe6ff1169c37 to your computer and use it in GitHub Desktop.
Save mrksdiehl/4be12c7a6337b908518bfe6ff1169c37 to your computer and use it in GitHub Desktop.
Script to automatically check and renew vesta ssl certificate if outdated
#!/bin/bash
# first run
# v-add-letsencrypt-domain or add them from control panel
# vi /etc/cron.daily/vesta_ssl
# chmod +x /etc/cron.daily/vesta_ssl
cert_src="/home/[USER]/conf/web/ssl.[DOMAIN].pem"
key_src="/home/[USER]/conf/web/ssl.[DOMAIN].key"
cert_dst="/usr/local/vesta/ssl/certificate.crt"
key_dst="/usr/local/vesta/ssl/certificate.key"
if ! cmp -s $cert_dst $cert_src
then
# Copy Certificate
cp $cert_src $cert_dst
# Copy Keyfile
cp $key_src $key_dst
# Change Permission
chown root:mail $cert_dst
chown root:mail $key_dst
# Restart Services
service vesta restart &> /dev/null
service exim4 restart &> /dev/null
fi
@mrksdiehl
Copy link
Author

mrksdiehl commented Jul 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment