Skip to content

Instantly share code, notes, and snippets.

@Shillos
Forked from TehPeGaSuS/deploy_irc
Created July 15, 2021 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shillos/4a35c763404ad282ce837003ddd43514 to your computer and use it in GitHub Desktop.
Save Shillos/4a35c763404ad282ce837003ddd43514 to your computer and use it in GitHub Desktop.
Automate certificates with UnrealIRCd (one server only setup)
#!/bin/sh
# NOTE: This script was made to work with certbot. I don't guarantee it will
# work with other ACME clients.
#
# This was tested in Ubuntu 20.04. This should work as it is on
# Debian/Ubuntu based distros. For other distros please check Certbot
# documentation.
#
# Place this script inside /etc/letsencrypt/renewal-hooks/deploy/ and
# name it `deploy_irc'
#
# Make the script executable with:
#
# chmod +x /etc/letsencrypt/renewal-hooks/deploy/deploy_irc
#
# Edit the subdomain, user and paths to fit your setup.
# Enjoy!
# What's your subdomain?
subdomain=irc.domain.tld
# What is the shell user running UnrealIRCd?
user=ircd
# What is the shell group of the user running UnrealIRCd?
# Usually it's the same as the user specified above.
# You shouldn't have to edit this unless you've added the user to another group
group=$user
# Path to UnrealIRCd executable folder
# Usually "/home/<user>/unrealircd/" when installed normally
execdir=/home/$user/unrealircd
# Path to the UnrealIRCd tls folder
# Usually `/home/<user>/unrealircd/conf/tls' when installed normally
# You shouldn't have to edit this unless you've customised your installation
tlsdir=$execdir/conf/tls
# 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
*/"$subdomain")
cp -f -- "$RENEWED_LINEAGE"/fullchain.pem "$RENEWED_LINEAGE"/privkey.pem "$tlsdir" &&
chown -- "$user":"$group" "$tlsdir"/fullchain.pem "$tlsdir"/privkey.pem &&
"$execdir"/unrealircd reloadtls &&
"$execdir"/unrealircd rehash
esac
# Script to be used with Certbot and the `Setting up certbot for use with UnrealIRCd' guide
# located at https://www.unrealircd.org/docs/Setting_up_certbot_for_use_with_UnrealIRCd
#
# I can't guarantee that this script will work with other ACME clients
#
# NOTE: This script was tested on Ubuntu 20.04 and should work on Debian/Ubuntu based distros.
# For other distros, please check the distro/certbot documentation
#
# USAGE: Place this script inside `/etc/letsencrypt/renewal-hooks/deploy/' and name it `reload_cert.sh'
# Make the script executable with: chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload_cert.sh
#
# Edit the domain and paths to fit your installation
# What's your IRC domain/subdomain?
theDomain=irc.domain.tld
# What's the shell username that is running the IRCd?
theUser=ircd
# What's the directory where your unrealircd executable is installed?
# You probably won't need to edit this unless you've customised your installation
theDir=/home/$theUser/unrealircd
# 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
*/"$theDomain")
"$theDir"/unrealircd reloadtls &&
"$theDir"/unrealircd rehash
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment