Skip to content

Instantly share code, notes, and snippets.

@TehPeGaSuS
Last active November 30, 2024 20:47
Show Gist options
  • Save TehPeGaSuS/22295a9359bfe7a1b8f5ed7cfce36502 to your computer and use it in GitHub Desktop.
Save TehPeGaSuS/22295a9359bfe7a1b8f5ed7cfce36502 to your computer and use it in GitHub Desktop.
InspIRCd Stuff
#!/usr/bin/env bash
# NOTES:
# 1. This script was made to work with certbot. I don't guarantee it will
# work with other ACME clients.
#
# 2. This script was tested in Ubuntu 20.04 and higher. This should work as it is on
# any Debian/Ubuntu based distros. For other distros please check Certbot
# documentation.
#
# 3. This script assumes that you already have a webserver, such as Apache (tested) with
# a vhost properly set up with the IRC domain/subdomain.
#
# USAGE:
# Create a folder named `scripts` inside `/etc/letsencrypt` with:
# mkdir -p /etc/letsencrypt/scripts
#
# Place this script inside `/etc/letsencrypt/scripts` and name it `inspircd_cert.sh`
#
# Make the script executable with:
# chmod +x /etc/letsencrypt/scripts/inspircd_cert.sh
#
# Request the certificate with one of the following commands:
# - Normal:
# certbot -d irc.domain.tld --deploy-hook /etc/letsencrypt/scripts/inspircd_cert.sh
#
# - SAN certificate:
# certbot -d irc.domain.tld -d servername.domain.tld --deploy-hook /etc/letsencrypt/scripts/inspircd_cert.sh
#
#
# ATTENTION:
# The SAN certificate and private key will be saved on /etc/letsencrypt/live/irc.domain.tld and not /etc/letsencrypt/live/servername.domain.tld
#
#
# Edit the domain/subdomain, user and paths to fit your installation
# Enjoy!
# What's your IRC domain/subdomain?
ircDomain="irc.domain.tld"
# The user:group that InspIRCd runs as
ircOwner="ircd:ircd"
# Path to the InspIRCd TLS folder (the folder MUST exist)
# You need to configure InspIRCd to read fullchain.pem as certificate and
# privkey.pem as key from this location
ircTLS="/home/ircd/inspircd/tls"
# The location of the InspIRCd pid file
ircPID="/home/ircd/inspircd/inspircd.pid"
#--------------------------------------------------------------------------------------------------------------#
# Don't edit anything below unless you know exactly what you're doing #
# If you touch the code below and then complain the script "suddenly stopped working" I'll touch you at night. #
#--------------------------------------------------------------------------------------------------------------#
case $RENEWED_LINEAGE in
*/"$ircDomain")
cp -f -- "${RENEWED_LINEAGE}"/{fullchain,privkey}.pem "$ircTLS" &&
chown -- "$ircOwner" "${ircTLS}"/{fullchain,privkey}.pem &&
if [ -r "$ircPID" ]
then
kill -USR1 "$(cat $ircPID)"
fi
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment