Using Command to run after making changes

I’d like to use the “Command to run after making changes to a server” to call a script which will create a Datasource for Coldfusion, or update it when i change passwords etc.

I assumed that i would be able to use the same substitutions that are available in the email templates, but this doesn’t seem to work. I’m using the following command

[code:1]/usr/bin/wget http: / / localhost/create_dsn.cfm?user=${USER}&pwd=${PASS}&db=${DB}[/code:1]

${DB} and ${PASS} are empty, and ${USER} returns “root” (the user i’m logged into VM with.

I’m trying to set this up on a dev box running VM GPL, but if it works i’d also like to set it up on my VM Pro boxes.

Any one know if this should work, or are substitutions not implemented for this function ?

Post edited by: ChrisBlackwell, at: 2008/02/05 10:39

Post edited by: ChrisBlackwell, at: 2008/02/05 10:40<br><br>Post edited by: ChrisBlackwell, at: 2008/02/05 10:40

Firstly VM GPL has no help docs attached to the "Command to run after making changes" field, but i noticed that the Pro version does.

Sounds like a bug. Maybe the bug-tracker deserves a visit. :wink:

Otherwise, great sleuthing. We should get this added to the wiki…good data for folks writing custom scripts to be called by Virtualmin.

Ok, another hour of hunting around and i’ve solved this. Firstly VM GPL has no help docs attached to the “Command to run after making changes” field, but i noticed that the Pro version does.

The docs for VM Pro say that theres lots of environment variables available, these aren’t substitutions in the same form as the templates ${DOM} but shell enviroment variables like $VIRTUALSERVER_DOM.

A good way to see all variables available when you update a domain is to enter the following in the before or after changes field

[code:1]/usr/bin/env > /root/env.txt[/code:1]

This will list every environment variable available to you when VM calls your script, like

[code:1]VIRTUALSERVER_LIMIT_WEBALIZER=0
VIRTUALSERVER_FILE=/etc/webmin/virtual-server/domains/120223826925534
VIRTUALSERVER_DB=test_dev
VIRTUALSERVER_LOGROTATE=1
VIRTUALSERVER_MAILBOXLIMIT=[/code:1]

The other problem i had was that the url i was passing to wget needed quotes around it because the &'s were borking the command after the first query argument and making it run in the background.

Ok, another hour of hunting around and i’ve solved this. Firstly VM GPL has no help docs attached to the “Command to run after making changes” field, but i noticed that the Pro version does.

The docs for VM Pro say that theres lots of environment variables available, these aren’t substitutions in the same form as the templates ${DOM} but shell enviroment variables like $VIRTUALSERVER_DOM.

A good way to see all variables available when you update a domain is to enter the following in the before or after changes field

[code:1]/usr/bin/env > /root/env.txt[/code:1]

This will list every environment variable available to you when VM calls your script, like

[code:1]VIRTUALSERVER_LIMIT_WEBALIZER=0
VIRTUALSERVER_FILE=/etc/webmin/virtual-server/domains/120223826925534
VIRTUALSERVER_DB=test_dev
VIRTUALSERVER_LOGROTATE=1
VIRTUALSERVER_MAILBOXLIMIT=[/code:1]

The other problem i had was that the url i was passing to wget needed quotes around it because the &'s were borking the command after the first query argument and making it run in the background.