Last active
June 14, 2025 21:38
-
-
Save TehPeGaSuS/fc53be6e310a8ab7fdb7588224b0aeb2 to your computer and use it in GitHub Desktop.
Automated renewal of WeeChat relay certificate
This file contains hidden or 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
#!/usr/bin/env bash | |
#-----------------------------------------------------------------------------------# | |
# Shell script to manage WeeChat relay certificates with Let's Encrypt and Certbot # | |
# # | |
# Edit paths and/or commands according to your OS, etc # | |
# # | |
# NOTE: This script was tested on Ubuntu 20.04+ # | |
#-----------------------------------------------------------------------------------# | |
#------------------------# | |
# User that runs WeeChat # | |
#------------------------# | |
weechatUser=weechater | |
#------------------------------------------------# | |
# WeeChat user group (usually the same as above) # | |
#------------------------------------------------# | |
weechatGroup=weechater | |
#-----------------------------------------------------------------# | |
# WeeChat TLS folder (usually /home/username/.config/weechat/tls) # | |
#-----------------------------------------------------------------# | |
weechatTLS="/home/weechater/.config/weechat/tls" | |
#-------------------# | |
# WeeChat FIFO path # | |
#-------------------# | |
weechatFIFO="/run/user/1000/weechat/weechat_fifo" | |
#--------------------------------------------------------------------------------------------------------------# | |
# 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. # | |
#--------------------------------------------------------------------------------------------------------------# | |
# Concatenate fullchain.pem and privkey.pem into relay.pem | |
cat "$RENEWED_LINEAGE"/fullchain.pem "$RENEWED_LINEAGE"/privkey.pem > "$weechatTLS"/relay.pem && | |
# Set user that runs weechat as the file owner | |
chown -- "$weechatUser":"$weechatGroup" "$weechatTLS"/relay.pem && | |
# Reload weechat tlscertkey | |
echo "core.weechat */relay tlscertkey" > "$weechatFIFO" && | |
# Success! | |
printf "WeeChat relay certificate updated successfully!\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use?
This is done as the user running weechat
fifo.file.path
to${weechat_runtime_dir}/weechat_fifo
with the command:/set fifo.file.path "${weechat_runtime_dir}/weechat_fifo"
/home/$USER/.config/weechat/tls
if it doesn't existrelay.network.tls_cert_key
to${weechat_config_dir}/tls/relay.pem
with the command:/set relay.network.tls_cert_key "${weechat_config_dir}/tls/relay.pem"
relay
plugin with:/reload relay
This is done as root
scripts
under/etc/letsencrypt
, where we will put all the files for automation with Let's Encrypt using the following command:mkdir -p /etc/letsencrypt/scripts
/etc/letsencrypt/scripts
folder and save it under the nameweechat_renew.sh
wget https://gist.githubusercontent.com/TehPeGaSuS/fc53be6e310a8ab7fdb7588224b0aeb2/raw/8dac3b8710189f8cf3621da6f6cfe75ed8135e6f/weechat_renew.sh
chmod +x /etc/letsencrypt/scripts/weechat_renew.sh
certbot -d weechat.domain.tld --deploy-hook /etc/letsencrypt/scripts/weechat_renew.sh
(you may need to run the command twice)