Executing script on DNS zone changes

4 posts / 0 new
Last post
#1 Mon, 03/02/2009 - 22:48
Hal9000

Executing script on DNS zone changes

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

Tue, 03/03/2009 - 07:55
Joe
Joe's picture

You're looking for Module Config-&gt;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!

Tue, 03/03/2009 - 08:49 (Reply to #2)
Hal9000

thanks. under which user are those scripts executed? is it possible to execute a script as a precise user?

Tue, 03/03/2009 - 10:01 (Reply to #3)
Joe
Joe's picture

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!

Topic locked