Skip to content

Instantly share code, notes, and snippets.

@spacetourist
Last active April 7, 2023 13:44
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 spacetourist/788ea722901e81d355850842e2b17cda to your computer and use it in GitHub Desktop.
Save spacetourist/788ea722901e81d355850842e2b17cda to your computer and use it in GitHub Desktop.
#!/bin/bash
KEY=`xxd -c 100000 -p /etc/letsencrypt/live/opensips/privkey.pem`
CRT=`xxd -c 100000 -p /etc/letsencrypt/live/opensips/fullchain.pem`
# Update both the default domains (client+server) with the renewed certificate
mysql -h 192.168.151.20 -u opensips_dev -pPASSWORD opensips_dev -e "UPDATE opensips_dev.tls_mgm SET certificate=0x${CRT}, private_key=0x${KEY} WHERE domain='default'" >/dev/null
if [ $? -ne 0 ]; then
# Something went wrong, report error back to lets encrypt
echo "MySQL certificate update failed"
exit 1
fi
# Reload certs into running system
/usr/local/bin/opensips-cli -x mi tls_reload >/dev/null
if [ $? -ne 0 ]; then
# Something went wrong, report error back to lets encrypt
echo "Failed to reload certificates using opensips-cli"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment