Created
September 10, 2017 16:47
-
-
Save woohooyeah/5acbe12f89322d70746b96a85dfff9a9 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 InspIRCd | |
## Run this after certbot renew ! | |
## Dorian Harmans <contact@dorianharmans.nl> | |
## --------------------------------------------------- | |
#!/bin/bash | |
LETSENCRYPTDIR="/etc/letsencrypt/live" | |
IRCSERVERNAME="irc.domain.tld" | |
IRCSERVERUSER=ircuser | |
IRCSERVERCONFDIR="/home/${IRCSERVERUSER}/inspircd/run/conf" | |
SRC_CERTDIR="${LETSENCRYPTDIR}/${IRCSERVERNAME}" | |
SRC_FULLCHAIN="${SRC_CERTDIR}/fullchain.pem" | |
SRC_KEY="${SRC_CERTDIR}/privkey.pem" | |
TGT_CRT="${IRCSERVERCONFDIR}/cert.pem" | |
TGT_KEY="${IRCSERVERCONFDIR}/key.pem" | |
if [ -e $SRC_FULLCHAIN ]; then | |
cp $SRC_FULLCHAIN $TGT_CRT | |
chown $IRCSERVERUSER:$IRCSERVERUSER $TGT_CRT | |
chmod 0640 $TGT_CRT | |
else | |
echo -e "Failed!\nReason: ${SRC_FULLCHAIN} not found" | |
exit 1 | |
fi | |
if [ -e $SRC_KEY ]; then | |
cp $SRC_KEY $TGT_KEY | |
chown $IRCSERVERUSER:$IRCSERVERUSER $TGT_KEY | |
chmod 0600 $TGT_KEY | |
else | |
echo -e "Failed!\nReason: ${SRC_KEY} not found" | |
exit 1 | |
fi | |
if [ -e $TGT_CRT ] && [ -e $TGT_KEY ]; then | |
/bin/systemctl reload inspircd.service | |
else | |
echo -e "Failed!\nReason: ${TGT_CRT} and/or ${TGT_KEY} 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