I am using a wildcard cert for my main domain on several other devices in my home, such that when my Virtualmin server updates the cert via LetsEncrypt, it calls a script to run two sub-scripts, which each target a specific device.
The script I have in Virtualmin is:
#!/bin/sh
if [ "$VIRTUALSERVER_ACTION" = "SSL_DOMAIN" ]; then
if ["$VIRTUALSERVER_DOM" = "aiskon.net"]; then
/root/scripts/deploy-freenas/deploy_freenas.py
/root/scripts/pihole-certs.sh
fi
fi
I know the two sub-scripts it calls work when I run them individually, and the main script (above) works when I comment out the “if” statements and run it manually.
It looks like I’m having trouble with properly triggering the script on SSL Renewal - can I get verification my script is correct?
I would suspect something is missing from the environment that makes your called scripts not work. Try checking the Webmin action log (in /var/webmin/webmin.log) and maybe adding some logging of your own to see what’s happening.
First make sure the if logic is sound:
#!/bin/sh
if [ "$VIRTUALSERVER_ACTION" = "SSL_DOMAIN" ]; then
if ["$VIRTUALSERVER_DOM" = "aiskon.net"]; then
echo "We made it!" >> /root/cert-copy.log
/root/scripts/deploy-freenas/deploy_freenas.py
/root/scripts/pihole-certs.sh
fi
fi
Then if that shows up in that file, redirect the output of those commands to the log (assuming they have output, if they don’t, add some). You need to just step through your assumptions, since one of them is wrong. I don’t think your logic related to when to run is wrong, but you should prove it before you start looking for what is wrong.
#!/bin/sh
echo `date` " - Parent Script called successfully" >> /root/scripts/scriptlog.txt
if [ "$VIRTUALSERVER_ACTION" = "SSL_DOMAIN" ]; then
if ["$VIRTUALSERVER_DOM" = "aiskon.net"]; then
echo `date` " - Parent script conditions met" >> /root/scripts/scriptlog.txt
/root/scripts/deploy-freenas/deploy_freenas.py
/root/scripts/pihole-certs.sh
fi
fi
echo `date` " - Parent Script completed successfully" >> /root/scripts/scriptlog.txt
So it will log if it’s called by Virtualmin, and it will also log if the conditions are met, and when it ends (so I can see what’s between, if needed).
The pihole-certs.sh also logs to the same file, so there’s that. The deploy_freenas.py is in Python which I’m not as familiar with, but hopefully if everything else runs, this one will to, and I can just check my TrueNAS to see if the cert updated.
Gonna wait a day before I renew my SSL Cert, so I’m not spamming the servers and lock myself out.
EDIT: I got a print statement to work in deploy_freenas.py, so I can see exactly what’s being called when.
I had JUST noticed this when you posted - that fixed it!
Thu Jun 26 12:02:16 EDT 2025 - Parent Script called successfully
SSL Condition Passed
aiskon.net
Domain Condition Passed
deploy_frerenas called successfully.
Thu Jun 26 12:02:36 EDT 2025 - PiHole script called successfully
Thu Jun 26 12:02:36 EDT 2025 - Parent Script ended successfully
So the working script, without the troubleshooting code, is:
#!/bin/sh
if [ "$VIRTUALSERVER_ACTION" = "SSL_DOMAIN" ]; then
if [ "$VIRTUALSERVER_DOM" = "aiskon.net" ]; then
/root/scripts/deploy-freenas/deploy_freenas.py
/root/scripts/pihole-certs.sh
fi
fi