Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    5

    Default automatically run server script

    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. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    5

    Default

    Can /scripts/postwwwacct be written in PHP or is it limited to Perl?

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by classywear View Post
    Can /scripts/postwwwacct be written in PHP or is it limited to Perl?
    According to the documentation, it can be done in either PHP or Perl

  5. #5
    Member brianoz's Avatar
    Join Date
    Mar 2004
    Location
    Melbourne, Australia
    Posts
    1,117
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by cPanelDavidG View Post
    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

  6. #6
    Member
    Join Date
    Oct 2003
    Posts
    46

    Default 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. #7
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #8
    Member
    Join Date
    Oct 2003
    Posts
    46

    Default Feature Request

    Here is the feature request, please vote for this:

    http://bugzilla.cpanel.net/show_bug.cgi?id=5641

    Thanks,
    Brad

Similar Threads & Tags
Similar threads

  1. Run a script remotley on a server.
    By Markspixel in forum cPanel Developers
    Replies: 1
    Last Post: 09-13-2010, 10:37 AM
  2. Run Script when server starts
    By CoolMike in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 01-05-2008, 04:33 AM
  3. Server reboot after run /script/easyapache
    By joy in forum New User Questions
    Replies: 8
    Last Post: 02-03-2007, 12:06 AM
  4. Issues with php script not run on new server
    By isputra in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 05-12-2006, 12:22 PM
  5. New script to monitor your server load automatically
    By PWSowner in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-23-2004, 02:09 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube