The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

automatically run server script

Discussion in 'General Discussion' started by classywear, Jun 14, 2007.

  1. classywear

    classywear Member

    Joined:
    Jun 3, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    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
     
    #2 cPanelDavidG, Jun 14, 2007
    Last edited: Jun 14, 2007
  3. classywear

    classywear Member

    Joined:
    Jun 3, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Can /scripts/postwwwacct be written in PHP or is it limited to Perl?
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    According to the documentation, it can be done in either PHP or Perl
     
  5. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    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
    
     
  6. bradandersen

    bradandersen Active Member

    Joined:
    Oct 6, 2003
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    6
    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
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    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 :).
     
  8. bradandersen

    bradandersen Active Member

    Joined:
    Oct 6, 2003
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    6
Loading...

Share This Page