Created
September 10, 2017 16:45
-
-
Save woohooyeah/a14601f3204fb5da95513beae00aea2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Script to copy LetsEncrypt certificates to ZNC | |
## Run this after certbot renew ! | |
## Dorian Harmans <contact@dorianharmans.nl> | |
## --------------------------------------------------- | |
#!/bin/bash | |
LETSENCRYPTDIR="/etc/letsencrypt/live" | |
ZNCSERVERNAME="znc.domain.tld" | |
ZNCUSER=zncuser | |
ZNCCONFDIR="/home/${ZNCUSER}/.znc" | |
SRC_CERTDIR="${LETSENCRYPTDIR}/${ZNCSERVERNAME}" | |
SRC_KEY="${SRC_CERTDIR}/privkey.pem" | |
SRC_CRT="${SRC_CERTDIR}/cert.pem" | |
SRC_CHAIN="${SRC_CERTDIR}/chain.pem" | |
SRC_DHFILE="/etc/ssl/private/dh.pem" | |
TGT_CRT="${ZNCCONFDIR}/znc.pem" | |
TGT_CRT_BACKUP="${ZNCCONFDIR}/znc.pem.backup" | |
if [ -e $SRC_CERTDIR ] && [ -e $SRC_DHFILE ]; then | |
cp $TGT_CRT $TGT_CRT_BACKUP | |
cat $SRC_KEY > $TGT_CRT | |
cat $SRC_CRT >> $TGT_CRT | |
cat $SRC_CHAIN >> $TGT_CRT | |
cat $SRC_DHFILE >> $TGT_CRT | |
chown $ZNCUSER:$ZNCUSER $TGT_CRT $TGT_CRT_BACKUP | |
chmod 0600 $TGT_CRT $TGT_CRT_BACKUP | |
else | |
echo -e "Failed!\nReason: ${SRC_CERTDIR} and/or ${SRC_DHFILE} not found" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment