These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Executing script on DNS zone changes on the new forum.
Hi there!
The way i manage my secondary dns server right now is that i have a script that collects all zones, generates the configuration file and sends it via scp to the other server. The other server then has a cron script that looks if there is a new config file, if yes moves it to the bind dir and reloads it. I don't have root access to that server so i can't install webmin or anything, so this is the way to go for me.
I want to automate this, so that shell script gets executed whenever a zone is created or deleted.
Is this possible? I couldn't find the place to set such a thing up in virtualmin pro...
hal
Post edited by: Hal9000, at: 2009/03/02 22:49<br><br>Post edited by: Hal9000, at: 2009/03/02 22:56
You're looking for Module Config->Actions upon server and user creation
The commands are run with a handful of ENV variables set to indicate what's happening (whether it's a creation, deletion, update, etc.) and some details about it (like user, domain name, etc.). Click the help to get a bit of info about those variables. Because the variables are highly dependent on your particular situation (custom fields get variables, too), the best bet is probably to just make a script that writes the ENV out to a file and exits, so you can see exactly what information you have to work with.
--
Check out the forum guidelines!
thanks. under which user are those scripts executed? is it possible to execute a script as a precise user?
They run as root, and no, you're stuck running the scripts as root. They're intended to be used for administrative tasks--so running as anything else just wouldn't work.
That said, you could make a wrapper for it that executes another script as the virtual server owner. That'd actually be reasonably trivial, something like:
#!/bin/sh
su -c '/path/your-script.sh' $VIRTUALSERVER_USER
Or, you could write your script to do the things it needs to do as a particular user into the script in question.
Actually, I guess, technically, you might even be able to do this <i>in</i> the command field, since it's just one line...I'm not sure if the variables are available at that point, though. It'd be worth a try, though.
--
Check out the forum guidelines!