Hello! One of my domains uses a wildcard certificate for itself and its sub-domains. I have a script that can deploy that wildcard cert to a remote server, specifically the host on which my Virtualmin VM resides. How do I trigger the script to run, when the cert is renewed?
Normally, I’d use --post-hook for acme.sh, but I didn’t see an option for this in Virtualmin. I did find this thread discussing renewal options, but it appears to apply to all servers / domains, not a specific one.
Is there a way to run the script, when a specific cert is renewed?
a real cheap crude way would be to have an IF statement in your script, so while it will be called for every renewal, it will only fully execute for the domain you desire
#!/bin/sh
if [ "$VIRTUALSERVER_ACTION" = "SSL_DOMAIN" ] and ["$VIRTUALSERVER_DOM" = "aiskon.net"]; then
# Run deploy-freenas.py to install LE cert on TrueNAS Host
/root/scripts/deploy-freenas/deploy-freenas.py
fi
Note you’re using /bin/sh which on some systems will be a POSIX shell, and on others it’ll be bash in POSIX mode. You have to keep that in mind when scripting, as they are kinda compatible but not entirely, and there can be surprises. (But, since this is so short, it doesn’t matter, as long as you don’t use any bashisms.)