To access the data in the opts dictionary, you could use the following code:

Code Block

language

py

print opts['user']

Anchor

existing

existing

Available script hooks

cPanel & WHM ships with hooks already available for the following scripts and system actions:

/scripts/cpbackup

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/cpbackup script's hooks trigger each time that cPanel & WHM runs a backup.

For these script hooks to function correctly, youmustadd the following lines to the/etc/cpbackup.conffile:

Code Block

language

text

linenumbers

true

PREBACKUP 1
POSTBACKUP 1

By default, the system triggers theprehook after it performs checks and validations. To cause the hook to runbeforethe checks and validations (for example, regardless of whether backups are up-to-date), add the following line to the/etc/cpbackup.conffile:

Code Block

language

text

precpbackup -1

Section

Column

width

25%

pre hook script:

Column

/scripts/precpbackup

Section

Column

width

25%

post hook script:

Column

/scripts/postcpbackup

/scripts/killacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/killacct script's hooks trigger each time that the system deletes an account.

Section

Column

width

25%

pre hook script:

Column

/scripts/prekillacct

Section

Column

width

25%

post hook script:

Column

/scripts/postkillacct

When the system runs the /scripts/postkillacct script, it passes in the %OPTS hash, which contains the following parameters:

Parameter

Type

Description

Possible values

Example

user

string

The terminated account's username.

A valid username.

username

killdns

boolean

Whether the system deleted the account's zone files during termination.

1 — The system deleted the zone files.

0 — The system did not delete the zone files.

0

/scripts/suspendacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/suspendacct script's hooks trigger each time that the system suspends an account.

Section

Column

width

25%

pre hook script:

Column

/scripts/presuspendacct

Section

Column

width

25%

post hook script:

Column

/scripts/postsuspendacct

These scripts accept the following arguments:

username — The suspended account's username.

reason — The reason for account suspension.

disallow — Whether to allow only the root user to unsuspend the account.

Warning

title

Important:

These arguments must maintain the following order: username, reason, disallow.

/scripts/unsuspendacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/unsuspendacct script's hooks trigger each time that the system unsuspends an account.

Section

Column

width

25%

pre hook script:

Column

/scripts/preunsuspendacct

This script accepts the following argument:

username — The suspended account's username.

Section

Column

width

25%

post hook script:

Column

/scripts/postunsuspendacct

This script accepts the following argument:

user — The suspended account's username.

/scripts/upcp

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/upcp script's hooks trigger each time that cPanel & WHM updates.

Section

Column

width

25%

pre hook script:

Column

/scripts/preupcp

Section

Column

width

25%

post hook script:

Column

/scripts/postupcp

/scripts/updateuserdomains

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/updateuserdomains script's hooks trigger each time that the system generates a domain list.

Section

Column

width

25%

pre hook script:

Column

none

Section

Column

width

25%

post hook script:

Column

/scripts/postupdateuserdomains

/scripts/enXim-pkgacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/enXim-pkgacct script's hooks trigger each time that the system packages an account into a cpmove file via this script. Generally, this occurs when an account transfers from the Ensim® control panel to a cPanel & WHM server.

Note

title

Note:

These hooks do not trigger for cPanel & WHM-generated cpmove files.

Section

Column

width

25%

pre hook script:

Column

/scripts/prepkgacct

This script accepts the following argument:

user — The account's username.

Section

Column

width

25%

post hook script:

Column

/scripts/postpkgacct

This script accepts the following argument:

user — The account's original (remote) username.

split — The cpmove file consists of multiple files.

nosplit — The cpmove file consists of a single file.

cpuser — The account's new (local) username.

splitdir — The directory that contains the cpmove file.

/scripts/restoreacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/restoreacct script's hooks trigger each time that the system restores an account.

Section

Column

width

25%

pre hook script:

Column

/scripts/prerestoreacct

This script accepts the following arguments:

cpuser — The account's new (local) username.

olduser — The account's old (remote) username.

extractdir — The directory to which the system will extract the cpmove file.

Section

Column

width

25%

post hook script:

Column

/scripts/postrestoreacct

This script accepts the following arguments:

user — The account's new (local) username.

olduser — The account's old (remote) username.

domain — The account's main domain.

user_homedir — The absolute path to the account's home directory.

/scripts/wwwacct

Panel

bgColor

#FFFFFF

borderStyle

none

The /scripts/wwwacct script's hooks trigger each time that the system creates a cPanel account.

cPanel, WebHost Manager, and WHM are registered trademarks of cPanel, Inc. for providing its computer software that facilitates the management and configuration of Internet web servers. ®2018 All rights reserved.