Running Post-Hook on LE renewal for a specific domain / server?

SYSTEM INFORMATION
OS type and version Rocky Linux 9.3
Virtualmin version 7.9.0 Pro

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?

Thank you!

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

and YES this is not an elegant solution :slight_smile:

$VIRTUALSERVER_DOM

That contains the domain. So, only act if it matches the domain you want to act on.

1 Like

Does this look sound? My scripting is minimal:

#!/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

No, and isn’t a keyword in bash or POSIX shell. This is a reasonable discussion of the topic: An "and" operator for an "if" statement in Bash - Stack Overflow

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.)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.