Any hooks in place to call external code on update/create/delete of virtual servers in virtualmin GPL? I’d like to be able to do other things when virtualmin changes servers.
As my first example, which I’m trying to do now:
I’ve got some code I’m working on to sync zone files of created/edited virtualmin domains to Rackspace’s DNS servers via their cloud API. Works great on the commandline, but would like to not have to create a domain in virtualmin, then call my code with the same domain on the commandline to sync the domains to Rackspace DNS.
Sorry, I missed your post earlier… take a peek at System Settings -> Virtualmin Config -> Actions upon user and server creation – and look at the various “Command to run before” options there, I think those are what you’re after.
Assuming virtualmin uses the built-in /usr/sbin/useradd, you could create a shim file in its place. The shim file would run the standard grab the username from the parameters, add the user as normal, then create the user’s cron file. I’m no BASH guru so I’ll do it here in pseudo-code:
#!/bin/bash
A shim file to add users and create their cron jobs
Place this in /root/bin/adduser-cron with at least 700 permissions
Other user/group perms may be necessary.
get username from parameters for later creation of cron file
while getopts “:pq:” optname
do
case “$optname” in
“u”)
new_username == $optname
;;
esac
done #add user as normal
Be forewarned that if you update your OS and some package overwrites /usr/bin/useradd (shadow-utils for example) then you will loose your modified version and have to re-do the “mv …ln -s” bit.
Because of your assumption “Assuming virtualmin uses the built-in /usr/sbin/useradd” and since it is a production server, I was so reluctant that I changed my mind. I will just do some manual work when creating accounts. It feels safer for me. But I will try this if I will have a chance to have testing environment.
mogmismo, were you able to put something in place to keep your Rackspace Cloud DNS synced with your server’s DNS? I’m also looking to implement something like this and perhaps we could package it into a virtualmin module?