How to get all available values for CLI template variables?

I am trying to run a check in post-VS-creation script if the action is CLONE virtual server. Unfortunately,

if [ "$VIRTUALSERVER_ACTION" = "CLONE_DOMAIN" ]; then

does not work, because as https://www.virtualmin.com/documentation/id%2Ctemplate_variable_listing#... shows possible values for $VIRTUALSERVER_ACTION are only CREATE_DOMAIN, DELETE_DOMAIN, MODIFY_DOMAIN, DISABLE_DOMAIN, ENABLE_DOMAIN and RESTORE_DOMAIN.

Every time the VS is cloned the $VIRTUALSERVER_ACTION shows CREATE_DOMAIN, so I am trying to find out the old values (to later compare it with the new value and thus determining if VS is being cloned) within the following if statement:

if [ "$VIRTUALSERVER_ACTION" = "CREATE_DOMAIN" ]; then
  echo "old domain: "$VIRTUALSERVER_OLDSERVER_DOM
  echo "old domain: "$VIRTUALSERVER_OLDSERVERDOM
  echo "old domain: "$OLDSERVER_DOM
  echo "old domain: "$VIRTUALSERVER_OLD_DOM
  echo "old domain: "$VIRTUALSERVER_OLDDOM
if

However none of them is returning any value. I even tried the following ones

echo "old user: "$VIRTUALSERVER_OLDSERVER_USER
echo "old pass: "$VIRTUALSERVER_OLDSERVER_PASS

which also returned empty. So I have two questions:

(1) Please explain how to check in a script if the virtual server is being cloned.

(2) Would be much easier to deal with this kind of issues if it was possible to list, echo or dump all the available variable values. In fact, I remember one of the discussion pages here on virtualmin.com had a script that would output all the available values into a file, but can't find it now.

Thanks!

Status: 
Closed (works as designed)

Comments

1) You can use $VIRTUALSERVER_CLONE to check if a domain is a clone.

2) To get a dump of all variables, you can run have a post-creation script like : env | grep VIRTUALSERVER >/tmp/vars.txt

1) $VIRTUALSERVER_CLONE gives something like 147696816817890, I hope I can use it.

2) Thanks for env | grep VIRTUALSERVER >/tmp/vars.txt. It gives lot's of variables together with values, but none containing OLD (cat /tmp/vars.txt | grep OLD returns empty). And I remember there was a discussion where someone suggested a script which would list all the variables available including those containing OLD or OLDSERVER.

The OLDSERVER vars are only available when modifying a domain.

You can use the presence of VIRTUALSERVER_CLONE to determine if a domain is a clone or not.

Status: Active » Closed (works as designed)

That takes care of my needs. Thank you!