0

I'm using Virtualmin, and I have a command set up under Virtualmin > Module Config > Actions Upon Server and user creation > Command to run after making changes to a server

This command is designed to perform a few additional steps after the account is set up. However, the action is called every time the account is modified, and also gets called when the account is deleted. The actions it performs should only be done when the account is first created.

How can my custom command know which action is being performed? Is there an environment variable which determines if the action is creation, alteration, or deletion?

Pierre.Vriens
  • 1,159
  • 34
  • 15
  • 19
Josh
  • 9,190
  • 28
  • 80
  • 128

1 Answers1

2

Found the answer in the Virtualmin documentation: There's an environment variable $VIRTUALSERVER_ACTION available to the scripts which will contain one of:

  • CREATE_DOMAIN Set when a virtual server is being created.
  • DELETE_DOMAIN Set when a virtual server is being deleted.
  • MODIFY_DOMAIN Set when a virtual server is being changed, such as getting a new password, features or quota.
  • DISABLE_DOMAIN Set when a virtual server is being disabled via the UI or for exceeding its bandwidth limit.
  • ENABLE_DOMAIN Set when a virtual server is being enabled via the UI or for dropping back under its bandwidth limit.
  • RESTORE_DOMAIN Set when a virtual server is being restored from a backup.
Josh
  • 9,190
  • 28
  • 80
  • 128