How can I have cpanel pass a new users unername and password to a script on the server automatically when a new account is created? Has anyone done something similar to this?
John
How can I have cpanel pass a new users unername and password to a script on the server automatically when a new account is created? Has anyone done something similar to this?
John
You can always use hooks
/script/prewwwacct (before wwwacct is executed)
/scripts/postwwwacct (after wwwacct is executed)
/scripts/wwwacct = script executed when a user account is created, I'd advise against modifying this directly as your customizations are likely to become overwritten (hence we created hooks).
EDIT: Documentation for using hooks can be found at: http://www.cpanel.net/support/docs/hooks.htm
Last edited by cPanelDavidG; 06-14-2007 at 10:51 AM. Reason: Added link to documentation for hooks.
Can /scripts/postwwwacct be written in PHP or is it limited to Perl?
A few doco notes:
The tag line for "postkillacct" at top reads "Runs after account creation" which is kind of true if you count waiting for it to be run manually up to a few years later
There's no mention of "prekillacct" in the doco but it does work like postkillacct.
A bug in the "prewwwacct" script is that it doesn't allow creation to be aborted as a result of the script AFAIK. For example, I'd like to be able to run a spam list check to ensure that the domain isn't listed anywhere as being evil, for instance in URIBL which lists spammer domains. To do this, I need to be able to safely abort the current create. How do I do that? A non-zero exit would be a neat solution, but I can also kill $PPID or something similar.
/scripts/prekillacct code to backup an account at time of termination, which also demos how to unpack the new style arguments in shell:Code:#! /bin/sh # # Mini-script to backup an account when it is deleted # ... brianoz July 2007 # backupdir=/backup/deleted # Unpack parameters ... while [ $# != 0 ] do eval cp_$1="$2" shift 2 done test -d $backupdir || mkdir -p $backupdir /scripts/pkgacct $cp_user $backupdir
Hello,
Can I please request that you pass more parameters to postkillacct? I'm specifically looking for $opts['domain']. In postwwwacct I create DNS entries on my slave DNS servers. I'd like to be able to remove those entries when an account is terminated. However, I can't really do that with a "user" which has since been deleted so I can't really get their domain name.
Ahh, there is the little issue of add-on domains! Can we also get a postaddondomain and include all of the add-on domains to the postkillacct.
Thanks,
Brad
I'd recommend posting these suggestions to http://bugzilla.cpanel.net - I agree that pre- hooks should have the ability to abort the process (after all, that's probably why you're not using a post- hook). Post a link here and I'll vote for the pre- hook thing and CC myself to whatever else you guys come up with.
Here is the feature request, please vote for this:
http://bugzilla.cpanel.net/show_bug.cgi?id=5641
Thanks,
Brad