Command to run after making changes to a server

Is there a complete list of the variables mentioned in the help bubble for:

Server Settings, Virtualmin Configuration, Actions upon server and user creation, Command to run after making changes to a server

image

somewhere?:

(Note that it says “VIRTUALSERVER_HOME, VIRTUALSERVER_PASS, and more”… I am looking for the “and more”.)

And (even better) possibly some instructions on how to use them exactly?

I found my way to this list:

https://www.virtualmin.com/docs/development/template-variables

But this isn’t really a template and trying to use $DB (from that list) like this:

virtualmin install-script --domain $VIRTUALSERVER_DOM --type roundcube --version 1.6.10 --path / --db mysql $DB

resulted in a no-such-database error:

I took a guess at this:

virtualmin install-script --domain $VIRTUALSERVER_DOM --type roundcube --version 1.6.10 --path / --db mysql $VIRTUALSERVER_DB

But it did nothing at all (no error on virtual server creation, no line for trying to run a post-creation command all).

Further, the help bubble has a list of virtualmin operations:

That may or may not imply that these could be run only on a server-creation, not on a server deletion (which would no doubt cause an error if my example actually worked at creation).

Or is the idea that I must have it run /some-path/something.sh (it seems not because the help says “can be a script” and it’s not called “Script to run after…”)?

Either way, knowing the variables list and the basic idea/syntax would be help. I feel like it must be in the documentation somewhere, it’s just that no search or menu I’ve tried has it hiding there.

Thanks.

SYSTEM INFORMATION
OS type and version Ubuntu 24.04
Virtualmin version 7.30.8

Hello,

Thanks for reaching out!

You can always use printenv > /root/env in pre or post commands (“Command to run before making changes to a server” and “Command to run after making changes to a server” in “System Settings ⇾ Virtualmin Configuration: Actions upon server and user creation”) to make a full dump.

Hi thank you, that gives me a useful dump.

My example worked (to an extent) changed to this:

virtualmin install-script --domain $VIRTUALSERVER_DOM --type roundcube --version 1.6.10 --path / --db mysql $VIRTUALSERVER_DB_MYSQL

However it gives a message about the database (although the command seems to work anyway and the database is populated with roundcube stuff).

I get no such error if I remove that “after changes command” and make another virtual server and run what I believe to be the manually composed version of the same line from the command line:

virtualmin install-script --domain manualtest.com --type roundcube --version 1.6.10 --path / --db mysql manualtest

That just gives me:

So that’s kind of weird.

I does not display anything at all from a successful run though unless you (duh) check “Yes” on “Always show output from pre and post commands” here (which default to “Only on failure”):

image

So I suppose I can suppress the output to avoid seeing the confusing message (but it’s still happening for some reason).

Of course there are errors if I remove or change a virtual server with that line as my “after making changes”:

So a better fix in my case is to use something like:

[ $VIRTUALSERVER_ACTION = CREATE_DOMAIN ] && virtualmin install-script --domain $VIRTUALSERVER_DOM --type roundcube --version 1.6.10 --path / --db mysql $VIRTUALSERVER_DB_MYSQL

Which I thought might push the error out of the web buffer:

But it actually just doesn’t record an error that way if I run this from the command line, though it seems to think that it failed:

So maybe that “after changes” script expects a “success” message of some kind?

If “Only on failure” is checked, the web interface doesn’t count that as enough of an error to complain though so this is actually workable for me for now.

And in case anyone else (or I) ever comes looking for this, that printenv dump was (I have obscured a few values with [OBSCURED], and the test site I made was printenvtest.com (with no non-default settings except I gave it a password and I unchecked), all of which seem useful in that command line (lead by a $):

OLD_LANG=en_US.UTF-8
LIBROOT=/usr/share/webmin
CONTENT_TYPE=application/x-www-form-urlencoded; charset=UTF-8
GATEWAY_INTERFACE=CGI/1.1
VIRTUALSERVER_LIMIT_SPAM=1
VIRTUALSERVER_PROXY_PASS_MODE=0
REMOTE_HOST=[OBSCURED]
VIRTUALSERVER_EMAILTO_ADDR=printenvtest@printenvtest.com
VIRTUALSERVER_QUOTA=
VIRTUALSERVER_ALIASLIMIT=
USER=root
LANGUAGE=
REMOTE_USER=[OBSCURED]
VIRTUALSERVER_LIMIT_DNS=1
VIRTUALSERVER_OWNER=
VIRTUALSERVER_EDIT_SCRIPTS=0
VIRTUALSERVER_PROXY_PASS=
VIRTUALSERVER_LASTSAVE_SCRIPT=/virtual-server/domain_setup.cgi
VIRTUALSERVER_EDIT_DELETE=0
MINISERV_CERTFILE=/etc/ssl/virtualmin/172910502762394/ssl.cert
USERADMIN_OLD_GROUP=printenvtest
VIRTUALSERVER_EDIT_ALIASES=1
VIRTUALSERVER_SAFEUNDER=0
HTTP_X_REQUESTED_WITH=XMLHttpRequest
VIRTUALSERVER_EDIT_SCHED=0
VIRTUALSERVER_EDIT_SSL=0
VIRTUALSERVER_POSTGRES=0
VIRTUALSERVER_GROUP=printenvtest
VIRTUALSERVER_REALDOMSLIMIT=*
VIRTUALSERVER_BW_LIMIT=
VIRTUALSERVER_USER=printenvtest
LD_LIBRARY_PATH=
REMOTE_ADDR=[OBSCURED]
VIRTUALSERVER_SSL=0
VIRTUALSERVER_EDIT_REDIRECT=0
VIRTUALSERVER_EDIT_BACKUP=0
VIRTUALSERVER_FORCEUNDER=0
HOME=/root
QUERY_STRING=
USERADMIN_MEMBERS=www-data
VIRTUALSERVER_EMAIL=
VIRTUALSERVER_DNS_IP=[OBSCURED]
VIRTUALSERVER_ALIAS_MODE=0
VIRTUALSERVER_DEFIP=1
MINISERV_CONFIG=/etc/webmin/miniserv.conf
USERADMIN_GID=1021
BASE_REMOTE_USER=root
USERADMIN_ACTION=MODIFY_GROUP
VIRTUALSERVER_MAILBOXLIMIT=
VIRTUALSERVER_EDIT_DOMAIN=0
VIRTUALSERVER_LAST_CGIMODE=suexec
VIRTUALSERVER_LIMIT_FTP=0
PERLLIB=/usr/share/webmin
HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
DOCUMENT_ROOT=/usr/share/webmin
VIRTUALSERVER_EDIT_USERS=1
VIRTUALSERVER_UQUOTA=
VIRTUALSERVER_EDIT_SHAREDIPS=0
VIRTUALSERVER_LASTSAVE_USER=[OBSCURED]
VIRTUALSERVER_ALIAS=
VIRTUALSERVER_DB_MYSQL=printenvtest
VIRTUALSERVER_IP6=
VIRTUALSERVER_UNIX=1
VIRTUALSERVER_NORENAME=0
THEME_DIRS=authentic-theme
LOCALE=
HTTP_ACCEPT=*/*
VIRTUALSERVER_VIRT=0
VISUAL=/usr/share/webmin/cron/cron_editor.pl
CONTENT_LENGTH=336
VIRTUALSERVER_UGROUP=printenvtest
VIRTUALSERVER_LASTSAVE_TYPE=web
VIRTUALSERVER_EDIT_ADMINS=0
VIRTUALSERVER_SMTP_CLOUD=
VIRTUALSERVER_WEBALIZER=0
VIRTUALSERVER_MIGRATE=0
VIRTUALSERVER_IDNDOM=printenvtest.com
MINISERV_KEYFILE=/etc/ssl/virtualmin/172910502762394/ssl.key
USERADMIN_OLD_MEMBERS=
VIRTUALSERVER_DBSLIMIT=
VIRTUALSERVER_LASTREAD_TIME=1746707845
HTTP_HOST=[OBSCURED]:10000
USERADMIN_OLD_GID=1021
VIRTUALSERVER_NAME=1
VIRTUALSERVER_MYSQL=1
VIRTUALSERVER_EMAILTO=printenvtest@printenvtest.com
SERVER_REALROOT=/usr/share/webmin
VIRTUALSERVER_ACTION=CREATE_DOMAIN
VIRTUALSERVER_DB=printenvtest
VIRTUALSERVER_EDIT_PHPMODE=0
VIRTUALSERVER_LIMIT_POSTGRES=0
VIRTUALSERVER_EDIT_MAIL=0
VIRTUALSERVER_GID=1021
LOGNAME=
VIRTUALSERVER_MAIL=1
VIRTUALSERVER_LIMIT_SSL=0
VIRTUALSERVER_HASHPASS=0
VIRTUALSERVER_WEB_PORT=80
REQUEST_URI=/virtual-server/domain_setup.cgi
VIRTUALSERVER_ALLOWEDSCRIPTS=
VIRTUALSERVER_TEMPLATE=0
VIRTUALSERVER_MYSQL_MODULE=mysql
VIRTUALSERVER_LASTSAVE_WEBMINCRON=
VIRTUALSERVER_VIRUS=1
SERVER_SOFTWARE=MiniServ/2.303
VIRTUALSERVER_VIRTALREADY=0
HTTP_CONNECTION=keep-alive
MYSQL_PWD=[OBSCURED]
HTTP_SEC_FETCH_MODE=cors
VIRTUALSERVER_WEBMIN=1
VIRTUALSERVER_AWSTATS_PASS=/home/printenvtest/.awstats-htpasswd
VIRTUALSERVER_AUTO_LETSENCRYPT=1
VIRTUALSERVER_VIRTUALMIN_AWSTATS=1
VIRTUALSERVER_RESELLER=
VIRTUALSERVER_CREATOR=[OBSCURED]
VIRTUALSERVER_EDIT_DBS=0
VIRTUALSERVER_EDIT_RECORDS=0
VIRTUALSERVER_LIMIT_UNIX=1
HTTP_X_PROGRESSIVE_URL=https://[OBSCURED]:10000/virtual-server/domain_setup.cgi
HTTP_COOKIE=_ga=GA1.2.1304341158.1562801625; _delighted_web={%22FutSOUgy5edCcTk9%22:{%22_delighted_fst%22:{%22t%22:%221662134900867%22}}}; redirect=1; testing=1; usid=1229312653
VIRTUALSERVER_MONGRELSLIMIT=
VIRTUALSERVER_EDIT_ALLOWEDHOSTS=0
VIRTUALSERVER_LIMIT_VIRT=0
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/snap/bin
VIRTUALSERVER_ID=17467078222445105
VIRTUALSERVER_NETMASK=
VIRTUALSERVER_LIMIT_WEBALIZER=0
VIRTUALSERVER_HOME=/home/printenvtest
VIRTUALSERVER_UGID=1021
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.5
VIRTUALSERVER_EDIT_FORWARD=0
VIRTUALSERVER_EDIT_CATCHALL=0
HTTP_REFERER=https://[OBSCURED]:10000/virtual-server/domain_form.cgi?generic=1&gparent=1746121943568019&xnavigation=1
VIRTUALSERVER_LIMIT_MYSQL=1
VIRTUALSERVER_LASTSAVE=1746707845
VIRTUALSERVER_PLAN=0
VIRTUALSERVER_LOGROTATE=1
REMOTE_ADDR_PROTOCOL=4
LANG=
MINISERV_PID=1742
SERVER_PROTOCOL=HTTP/1.0
VIRTUALSERVER_WEB_URLPORT=
VIRTUALSERVER_WEB=1
VIRTUALSERVER_DOMSLIMIT=
HTTP_PRIORITY=u=0
WEBMIN_VAR=/var/webmin
HTTP_ACCEPT_ENCODING=gzip, deflate, br, zstd
VIRTUALSERVER_DIR=1
VIRTUALSERVER_PHP_ERROR_LOG=/home/printenvtest/logs/php_log
VIRTUALSERVER_LIMIT_MAIL=1
VIRTUALSERVER_VIRT6=
USERADMIN_SOURCE=
PATH_INFO=
VIRTUALSERVER_PARENT=
VIRTUALSERVER_ALIASMAIL=
VIRTUALSERVER_LIMIT_VIRUS=1
VIRTUALSERVER_DOM=printenvtest.com
VIRTUALSERVER_SUBDOM=
DOCUMENT_REALROOT=/usr/share/webmin
HTTP_CONTENT_TYPE=application/x-www-form-urlencoded; charset=UTF-8
VIRTUALSERVER_LASTSAVE_PID=2445105
VIRTUALSERVER_EDIT_DNSIP=0
THEME_ROOT=/usr/share/webmin/authentic-theme
VIRTUALSERVER_EDIT_DISABLE=0
VIRTUALSERVER_LIMIT_WEBMIN=0
VIRTUALSERVER_LIMIT_VIRTUALMIN_AWSTATS=1
VIRTUALSERVER_NAME6=1
VIRTUALSERVER_EDIT_SPAM=0
VIRTUALSERVER_EMAILTO_SRC=printenvtest@printenvtest.com
VIRTUALSERVER_UID=1045
HTTP_SEC_FETCH_DEST=empty
VIRTUALSERVER_SPAM=1
REQUEST_METHOD=POST
VIRTUALSERVER_PREFIX=printenvtest
VIRTUALSERVER_SUBPREFIX=
VIRTUALSERVER_DNS=1
VIRTUALSERVER_NODBNAME=0
SERVER_ADMIN=
VIRTUALSERVER_PHP_MODE=fcgid
VIRTUALSERVER_EDIT_IP=0
VIRTUALSERVER_VIRT6ALREADY=
VIRTUALSERVER_IPFOLLOW=
PWD=/usr/share/webmin/virtual-server/
LC_ALL=
VIRTUALSERVER_LIMIT_LOGROTATE=0
VIRTUALSERVER_CREATED=1746707822
VIRTUALSERVER_SOURCE=domain_setup.cgi
VIRTUALSERVER_IP=[OBSCURED]
VIRTUALSERVER_EDIT_PASSWD=1
HTTP_SEC_FETCH_SITE=same-origin
HTTPS=ON
HTTP_ORIGIN=https://[OBSCURED]:10000
VIRTUALSERVER_LIMIT_WEB=1
VIRTUALSERVER_EDIT_SPF=0
SERVER_PORT=10000
WEBMIN_CONFIG=/etc/webmin
VIRTUALSERVER_PUBLIC_HTML_PATH=/home/printenvtest/public_html
VIRTUALSERVER_LIMIT_DIR=1
VIRTUALSERVER_ALIASDOMSLIMIT=*
VIRTUALSERVER_PUBLIC_HTML_DIR=public_html
VIRTUALSERVER_PASS=printenvtestpass
USERADMIN_GROUP=printenvtest
VIRTUALSERVER_FTP=0
VIRTUALSERVER_NETMASK6=
VIRTUALSERVER_EDIT_PHPVER=0
SSL_HSTS=
CRON_EDITOR_COPY=/tmp/.webmin/16074_2445105_2_domain_setup.cgi
VIRTUALSERVER_MYSQL_USER=printenvtest
VIRTUALSERVER_EDIT_RESTORE=0
EDITOR=/usr/share/webmin/cron/cron_editor.pl
SERVER_NAME=[OBSCURED]
HTTP_CONTENT_LENGTH=336
VIRTUALSERVER_LETSENCRYPT_DWILD=0
VIRTUALSERVER_DB_POSTGRES=
root@[OBSCURED]:/home# cat /root/env | grep -I db
VIRTUALSERVER_DB_MYSQL=printenvtest
VIRTUALSERVER_DBSLIMIT=
VIRTUALSERVER_DB=printenvtest
VIRTUALSERVER_EDIT_DBS=0
VIRTUALSERVER_NODBNAME=0
VIRTUALSERVER_DB_POSTGRES=
root@[OBSCURED]:/home# cat /root/env | grep -I DOM
VIRTUALSERVER_LASTSAVE_SCRIPT=/virtual-server/domain_setup.cgi
VIRTUALSERVER_REALDOMSLIMIT=*
VIRTUALSERVER_EDIT_DOMAIN=0
VIRTUALSERVER_IDNDOM=printenvtest.com
VIRTUALSERVER_ACTION=CREATE_DOMAIN
REQUEST_URI=/virtual-server/domain_setup.cgi
HTTP_X_PROGRESSIVE_URL=https://[OBSCURED]:10000/virtual-server/domain_setup.cgi
HTTP_REFERER=https://[OBSCURED]:10000/virtual-server/domain_form.cgi?generic=1&gparent=1746121943568019&xnavigation=1
VIRTUALSERVER_DOMSLIMIT=
VIRTUALSERVER_DOM=printenvtest.com
VIRTUALSERVER_SUBDOM=
VIRTUALSERVER_SOURCE=domain_setup.cgi
VIRTUALSERVER_ALIASDOMSLIMIT=*