A WHM server inherited from a previous team has a dozen scripts in /scripts/ named things like postwwwacct, prekillacct, pre_install_ssl, postupcp. They’ve been working for years. The first cPanel upgrade after the takeover wipes two of them and the team finds out the hard way which mechanism preserves which behaviour. Migrating from legacy hooks to Standardized Hooks is mechanical — but the mapping from legacy script names to standardized event names is not always one-to-one.
What’s happening
Legacy hooks live in /scripts/ with hardcoded filenames cPanel checks for at known points in its codepath. /scripts/postwwwacct, /scripts/prekillacct, /scripts/pre_install_ssl are common ones. cPanel preserves these in most upgrade paths but not all; major version bumps and migrations can clobber them. Standardized Hooks live in /var/cpanel/hooks/ registered through whmapi1 add_hook with category/event/stage tuples. The registry survives upgrades because cPanel treats it as a config file, not a script directory.
How to verify
Inventory both systems on the current server:
ls /scripts/post* /scripts/pre*
whmapi1 list_hooks --output=jsonpretty | jq -r '.data.hook[] | "\(.category)::\(.event) [\(.stage)] -> \(.hook)"'
cat /var/cpanel/hooks/registered_hooks.yaml
diff <(ls /scripts/ | grep -E '^(pre|post)') <(whmapi1 list_hooks --output=jsonpretty | jq -r '.data.hook[].hook' | grep '^/scripts/')
The diff shows scripts that exist but are not registered through the Standardized Hooks system; those are the ones at risk in an upgrade.
The fix
Migration script-by-script, in this order:
- Inventory legacy hooks —
ls -la /scripts/post* /scripts/pre*. Note the file path, what it does, and the event it fires on (the cPanel docs map legacy filenames to standardized events). - For each legacy script, register the equivalent standardized hook.
/scripts/postwwwacctmaps toWhostmgr::Accounts::Create [post]. Register:whmapi1 add_hook category=Whostmgr event=Accounts::Create stage=post hook=/scripts/postwwwacct. The script keeps working; it’s now in the registry. - Validate the registration with a test event — create a throwaway account and confirm the hook fires from both the legacy mechanism (cPanel still hits
/scripts/postwwwacctif it exists) and the registered hook. Until you’ve confirmed both run, do not remove the legacy file. - Remove the legacy file once the registered hook is confirmed.
mv /scripts/postwwwacct /usr/local/cpanel/scripts/yourorg-postwwwacctkeeps the script at a non-legacy path; update the registration to the new path. - For events with no clean legacy-to-standardized mapping —
postupcpis the most common — keep the legacy file, register a Standardized Hook for the modern event (System::UpdateNow [post]), and have the registered hook call the legacy script. Two paths, same target.
For shops with significant legacy-hook investment, Stack Harbor’s cPanel server management practice runs the migration as a single workstream so hooks are versioned, tested, and consistent across the fleet before the next major upgrade lands.