Transfer tool hooks
Does the transfer tool provide any hooks?
I see the Guide to Standardized Hooks - PkgAcct Functions - Developer Documentation - cPanel Documentation hooks are not triggered when using the transfer tool.
I want a script to be triggered post account transfer and restore. Is it possible?
-
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.
- 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.
0 -
As indicated by @plesk4lyf the hooks system is really the way to go and if the event isn't hookable you can create a hookable event Guide to Standardized Hooks - Hookable Events in Custom Modules - Developer Documentation - cPanel Documentation though I wouldn't use the script hooks as they are deprecated. They are still usable at this time though. The whostmgr functions would be what you want to look at 0 -
Dear cPanel I think you simply cannot compare the simplicity of /scripts/postrestoreacct with the new standardized hooks system, and there is also no way currently to replicate its behaviour using the hooks system. While /scripts/postrestoreacct doesn't discriminate between restored and transferred accounts it is sublimely simple to use. Consider the case where you wish to do something immediately after EACH account in a large account transfer job has finished being transferred - say, add custom DNS records. There is no trivial way to detect this event using the standardized hooks and certainly no event triggered way. You have to register a script with the Transfers::Session hook and then find .data.session_details.sessionid from that and then use fetch_transfer_session_log to read the master.log and then search that for all events where contents.action == start and contents.queue == RESTORE and grab the contents.local_item value - this just allows you to enumerate all of the cpanel accounts that were part of the transfer - but you won't be able to do any of this until AFTER the whole transfer session has ended - which might be hours after the first account is transferred. No good. The only way to speed things along during the transfer session is to repeatedly search the master log of the transfer session looking for lines containing contents.action == [finish or whatever undocumented value signifies an account has finished transferring, if there is one, because you haven't documented it] and contents.queue == RESTORE and grab the contents.local_item values as you go - which is messy, and not event triggered. This is so insanely over the top for most people who buy a cPanel license I can't believe this is what you're expecting people to do instead of simple adding one line to /scripts/postrestoreacct What is needed here is a hook, say Transfers::Account - with a pre and post phase that just passes the details of the actual cpanel account that is being transferred AT THAT TIME. 0 -
@santrix - thanks for sharing that. I've passed that feedback along to the development team. 0
Please sign in to leave a comment.
Comments
4 comments