Package hooks

General Information

Custom scripts, triggered for actions on packages. Env vars include:

  • the contents of the package file, plus:
  • name: package name
  • package_level: reseller|admin
  • package_filename:
    • /usr/local/directadmin/data/admin/packages/NAME.pkg OR
    • /usr/local/directadmin/data/users/RESELLER/packages/NAME.pkg

A non-zero exit code will abort the save if it's a "pre" script, but the exit code of post scripts do not affect the result. Any output is added to the result.

Contents of the package file

Note that because one may have custom package itemsopen in new window, the contents of one's package may vary from another's in not only what settings, but what variables are available as well. Thus, this list is provided as a reference only and does not constitute all possible package variables passed via env. The following is the contents of an example package file:

  • aftp=OFF
  • bandwidth=1000
  • catchall=OFF
  • cgi=OFF
  • cron=ON
  • dnscontrol=ON
  • domainptr=0
  • email_daily_limit=-1
  • ftp=1
  • inode=unlimited
  • language=en
  • login_keys=OFF
  • mysql=5
  • nemailf=0
  • nemailml=0
  • nemailr=10
  • nemails=10
  • nsubdomains=10
  • php=ON
  • quota=100
  • skin=evolution
  • spam=ON
  • ssh=OFF
  • ssl=ON
  • suspend_at_limit=ON
  • sysinfo=ON
  • vdomains=1
Location

It is recommended to use the new naming scheme utilizing the directory method that allows one to have multiple separate scripts that run after a single designated action. The resulting custom hook script for package writes, for example, would be as follows:
/usr/local/directadmin/scripts/custom/package_write_pre/your_custom_name.sh
Using the old naming scheme, which still works fine, the resulting script would be:
/usr/local/directadmin/scripts/custom/package_write_pre.sh

package_write_(pre|post).sh

Called anytime the save button is clicked and all package variables are passed. This does also include one of the rename cases, see the rename script below.

package_delete_(pre|post).sh

The delete scripts will not contain the contents of the package in the env, but can be read in pre via $package_filename, ahead of the removal.

package_rename_(pre|post).sh

The rename scripts will also include:

  • new_name: NEWPACKAGENAME

but will not contain the contents of the package file.

Note that this can be triggered via 2 different ways:

  1. action=rename, which only renames the file. Just the above 2 rename files are triggered.
  2. add=* method during creation/saving where rename=yes && old_package=OLDNAME are passed. It calls the above package rename scripts, but also the write and delete scripts.

package_copy_(pre|post).sh

The copy scripts will also include:

  • new_name: NEWPACKAGENAME

but will not contain the contents of the package file.

Last Updated: 6/23/2021, 9:36:08 PM