Directadmin give the developer the ability to write custom scripts using post and pre hook which can be used in /usr/local/directadmin/scripts/custom

 

If you want to get what kind of variable each script can pass then you need to write a simple one line bash script. For example, let us say that you need to get the information about the variable for the custom script called:

all_backups_post.sh

Inside the all_backups_post.sh, you could write the following simple bash:

#!/bin/bash env | grep -v pass > $0.env

What the code does is, when Directadmin executed all_backups_post.sh, it will generate a file call all_backups_post.sh.env. This file will contains all the information about the variable that was passed through all_backups_post.sh. Here is the example of the all_backups_post.sh.env content:

 

minute=0 database_data_aware=yes owner=usertest _=/usr/bin/env LANG=en_US.UTF-8 where=local when=now id=1 value=multiple USER=root who=all local_path=/backup/admin_backups/admin_backups-31-07-2020_23-44-01 hour=5 PWD=/usr/local/directadmin HOME=/root success=1 dayofmonth=* type=admin reseller=admin append_to_path=custom:admin_backups-%d-%m-%Y_%H-%M-%S file=/backup/admin_backups/admin_backups-31-07-2020_23-44-01/admin.admin.user.tar.gz trash_aware=yes xml_file=/backup/admin_backups/admin_backups-31-07-2020_23-44-01/user/backup/test.com/email/data/roundcube.xml username=maxisofi88 email_data_aware=yes action=backup SHELL=/bin/sh dayofweek=* domain=sofibox.com month=* SHLVL=3 LANGUAGE=en current_result=
User abc has been backed up. <23:44:01>

The Admin backups have been created in /backup/admin_backups/admin_backups-31-07-2020_23-44-01 <23:44:51>
LOGNAME=root PATH=/usr/bin:/bin

 

You will see some variables are passed through the script in the above example. For example the variable of success=1 which indicates that the backup is success. You can then use the variable $success in your script to write more condition.

 

Best regards,

Arafat Ali