Hi Anoop,
Although the script hook method is deprecated, they are still working and I've been using without an issue:
Guide to Standardized Hooks - Script Hooks - Developer Documentation - cPanel Documentation
/scripts/restoreacct
The /scripts/restoreacct script's hooks trigger each time that the system restores an account.
pre hook script:
/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.
post hook script:
/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.
Just place a script that bash can execute. Here's an example if you want to test it:
1. Make a file /scripts/postrestoreacct
2. Put in it:
#!/bin/bash
ARRAY=($@)
ARRAYLENGTH=${#ARRAY[@]}
for (( ARG=0 ; ARG < $ARRAYLENGTH ; ARG++ ))
do
echo "ARG$ARG=${ARRAY[$ARG]}"
done
3. chmod it to execute:
chmod +x /scripts/postrestoreacct
4. Restore a test account
If done correctly, you should see in the output of the restore log
[ 7511][RESTORE:1 ][A:demouser ]: Progress: 79% (2019-02-27 04:42:23 +0000)
[ 7511][RESTORE:1 ][A:demouser ]: PostRestoreActions
[ 7511][RESTORE:1 ][A:demouser ]: Updating Caches …
[ 7511][RESTORE:1 ][A:demouser ]: Enabling IPv6 for account …
[ 7511][RESTORE:1 ][A:demouser ]: Updating Nameserver IP Address Report
[ 7511][RESTORE:1 ][A:demouser ]: Syncing contact information
[ 7511][RESTORE:1 ][A:demouser ]: Running postrestore script
[ 7511][RESTORE:1 ][A:demouser ]: ARG0=demouser
[ 7511][RESTORE:1 ][A:demouser ]: ARG1=demouser
[ 7511][RESTORE:1 ][A:demouser ]: ARG2=demowebsite.com
[ 7511][RESTORE:1 ][A:demouser ]: ARG3=/home/demouser
[ 7511][RESTORE:1 ][A:demouser ]: PostRestoreActions
Knowing the argument positions to the script, you can do simple things to trigger on restore, like change a theme:
uapi --user="$1" Styles update type=default name=basic
Or set to the system version of PHP:
whmapi1 php_set_vhost_versions version=inherit vhost-0="$3"