"Command to run after making changes to a server"

OS type and version Ubuntu 22.04
Webmin version 2.013
Virtualmin version 7.5

@Jamie, @Joe, @Ilia, @Eric,

When writing a script for “Command to run after making changes to a server”, how do I know whether the action being taken is “create”, “update” or “delete”?

I need to know this, as the script would be taking different steps depending on the action being taken by Virtualmin.


I’m developing a script which adds, updates, or removes entries from /etc/postfix/sender_relay and /etc/postfix/sasl_passwd in relation to a “sender_dependent” policy I’ve got setup.

Presently I manage this process somewhat “manually”, though it’d be nice to streamline the process along with domain creation.

My script works like: pm-relay-add --domain {domain} where {domain} represents a domain present on the server with mail enabled. A secondary script called pm-relay-del removes the domain from the two configurations, after which both scripts issue a rehash of the two map files, and reload of postfix.

*** I also developed a wrapper script called virtualmin-import which fetches all enabled domains with mail enabled, then passes each to pm-relay-add accordingly ***

See the bottom of this page: Template Variable Listing – Virtualmin

1 Like



This needs to be added to the “tooltip” in Virtualmin Configuration as it presently only discusses VIRTUALSERVER_DOM, VIRTUALSERVER_IP, VIRTUALSERVER_USER, VIRTUALSERVER_HOME, VIRTUALSERVER_PASS along with the any variable found in the /etc/webmin/virtual-server/domains/$DOM

Hence the reason for the question :slight_smile:


1 Like

Good suggestion, I’ll add docs for this in the next release.

1 Like

@Jamie, why don’t we also mention on the docs that an admin could use /usr/bin/printenv > /root/envs.txt inside the custom script to get the dump of all available environmental variables?

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.