classywear

Member
Jun 3, 2007
5
0
151
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
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
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:

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
EDIT: Documentation for using hooks can be found at: http://www.cpanel.net/support/docs/hooks.htm
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
 

bradandersen

Active Member
Oct 6, 2003
42
0
156
Automagic?

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
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
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 :).