postwwwacct scripts

Here you will find postwwwacct scripts for various purposes. When a new account is created in WHM, the account is created by the script /scripts/wwwacct. When this script has completed it's job it checks for the existence of a postwwwacct file in the scripts directory. If that file exists, it is called and most of the account data is passed to it. That's where you can do various custom tasks upon account creation by using a postwwwacct script to do what you want done.

I currently have 3 different postwwwacct scripts, one to provide temporary /~username access to new accounts which automatically gets removed a specified number of days later, one to send an automatic email out to the client when the account is created, and one to do some automatic editing of the new accounts files by using variables in the cpanel3-skel template files.


If you are already using a postwwwacct script and want to use one of mine, just rename the other one postwwwacct2. Mine check for the existence of a postwwwacct2 script. If it exists, the original variables are passed to it and it is called to do it's job after my script is finished. If it's 2 of my scripts you want to use, it gets a bit trickier. You still rename one of them, whichever one you prefer to run second, but then you also need to make a minor change to the script you call postwwwacct2. If you have, or want to use more than 1 of my postwwwacct scripts, or want to know how multiples work, read about it at the bottom of this page.

If you need help with installing a postwwwacct script, we can help for free if you are a member of our Scripts Club, or for $10 if you are not. That would automatically add you to our club. If you need us to do this for you on more than 2 servers, we may need to charge a little extra. Email us at customscripts@premierwebsitesolutions.com.


You can scroll down the page or use these links to go to the one you want.

- give temporary /~username access
- send automatic email
- modify skeleton files upon account creation

be sure to upload scripts in ascii mode


postwwwacct script - to give temporary /~username access

Script to give new users temporary access with /~username: PWSpostwwwacct1 V1.3
  Created - January 2, 2004 (V1.0)
  Modified - January 3, 2004 (V1.1)
        added line to restart apache for changes to take effect
  Modified - February 29, 2004 (V1.2)
        added detailed instructions
  Modified - March 2, 2004 (V1.21)
        added warning at start of actual code
  Last Modified - March 11, 2004 (V1.3)
        made it easy to use when another postwwwacct script is also being used
        made adjustment so only the first UserDir line is modified
        removed taint checking (not necessary and sometimes causes problems)

This script allows you to give new accounts temporary /~username access so they can view their site while waiting for their domains nameserver changes to propagate. Setting up this script is a bit complicated because it requires a line of data added to the httpd.conf file, like this:
# UserDirData|14|
and requires the conf file to have the "IfModule mod_userdir.c" entry already in it, something like this:
<IfModule mod_userdir.c>
    UserDir disabled
    UserDir enabled username1 username2
    UserDir public_html
</IfModule>

If you feel uncomfortable modifying your httpd.conf file, we can install the script and modify the file(s) for you for free if you are a member of our scripts club. (on 1 or 2 servers)
If you are not a member, we can do this, and add you to our club, for a fee of $10. Email us at customscripts@premierwebsitesolutions.com.

Save the following file to your servers scripts directory, which should be at /scripts.
Rename the PWSpostwwwacct1.txt to postwwwacct. If you are already using a postwwwacct script and want to keep using it also, rename it to postwwwacct2 BEFORE uploading and renaming this one.

postwwwacct script - rename to postwwwacct (no extension)

Read the instructions at the beginning of the script to see what modifications need to be done to your httpd.conf file. That file is usually at /usr/local/apache/conf/httpd.conf.
No changes are needed to the script itself.

Once the httpd.conf file is ready for the script, and the script is uploaded to your /scripts directory and made executable, you will be ready to go. Every time a new account is created, that user is added to the UserDir enabled line and the current users on that line are checked for expiry and removed if it's time.


postwwwacct script - to send automatic email

Requires cPanel V11 or later.

Script to send automatic email upon account creation: PWSpostwwwacct2 V2.5
  Created - in 2003 (V1.0)
  Modified - March 2, 2004 (V2.0)
        extracted auto email part from our own postwwwacct script
        altered to be more usable by others
        added instructions for other users
  Modified - March 4, 2004 (V2.01)
        added variable to specify who the message is from
  Modified - March 11, 2004 (V2.1)
        made it easy to use when another postwwwacct script is also being used
  Modified - April 13, 2004 (V2.11)
        added note about using special characters in email message
  Modified - April 26, 2004 (V2.12)
        modified email template
  Modified - July 18, 2006 (V2.2)
        fixed minor error when no email is entered in WHM
  Last Modified - February 19, 2009 (V2.5)
        modified to work with cPanel changes using %OPTS instead of @ARGV

This script will automatically send a welcome email message to the email address provided when an account is created. It includes various bits of account information and the message is easily edited right in the script. If no email is specified in WHM when an account is created, the welcome message is sent to username@domain.com.

Save the following file to your servers scripts directory, which should be at /scripts.
Rename the PWSpostwwwacct2.txt to postwwwacct. If you are already using a postwwwacct script and want to keep using it also, rename it to postwwwacct2 BEFORE uploading and renaming this one.

postwwwacct script - rename to postwwwacct (no extension)

Read the instructions at the beginning of the script to set some variables and modify your welcome message.

Once the script is uploaded to your /scripts directory and made executable, you will be ready to go. Every time a new account is created, that user is automatically emailed with account details. You also have the option to send a copy to yourself.


postwwwacct script - to modify skeleton files upon account creation

Requires cPanel V11 or later.

Script to modify skeleton files upon account creation: PWSpostwwwacct3 V3.0
  Created - in 2003 (V1.0)
  Modified - October 6, 2004 (V2.0)
        altered to be more usable by others
        added instructions for other users
  Modified - June 6, 2006 (V2.5)
        modified to work with home or home2 directories   Last Modified - March 12, 2008 (V3.0)
        modified to work with cPanel changes using %OPTS instead of @ARGV

This script allows you to put placeholders in your cpanel3-skel directory files which will automatically be replaced with appropriate account information when an account is created.

Save the following file to your servers scripts directory, which should be at /scripts.
Rename the PWSpostwwwacct3.txt to postwwwacct. If you are already using a postwwwacct script and want to keep using it also, rename it to postwwwacct2 BEFORE uploading and renaming this one.

postwwwacct script - rename to postwwwacct (no extension)

older postwwwacct version - rename to postwwwacct (no extension)
for cPanel versions prior to V11.

Once the script is uploaded to your /scripts directory and made executable, you just add placeholders to your skeleton files, and you will be ready to go. Every time a new account is created, the placeholders will automatically be replaced with the variables provided by the wwwacct (account creation) script.

Instructions are at the beginning of the script.


Using multiple postwwwacct scripts

When an account is created in WHM, it uses the script at /scripts/wwwacct. This script checks for the existance of a postwwwacct script in the same directory. If it exists, that script is called and most of the variables from the account creation are passed to it. That's pretty simple, but what if there is more than 1 script you want to run after account creation? My postwwwacct scripts are fairly easy to add if you already have one. Just rename the one you have now to postwwwacct2 and my scripts check for the existance of a postwwwacct2 script. If it exists, that script is called and the variables are passed to it once my script is done. If you want to use more postwwwacct scripts, it gets more complicated. We can't have multiple postwwwacct or postwwwacct2 scripts. To use more, you would have to give each one a different name, and in each one, have it call the one you want next. Here's how you would do that.

The part where one script calls the next one is like this:
if (-e "/scripts/postwwwacct") {
    system("/scripts/postwwwacct",@ARGV);
}
That's what you see in WHM's wwwacct script.

My postwwwacct scripts use this:
if (-e "/scripts/postwwwacct2") {
    system("/scripts/postwwwacct2",@ARGV);
}
That's why all you need to do is rename a current one to postwwwacct2.

If you want to use more postwwwacct scripts, you will need to go into each one and add or modify that if statement to call the one you want next. If you are using someone elses postwwwacct script and you want to add that if statement, make sure it is added after the scripts job is done, but before it is told to exit. If you need help with multiple postwwwacct scripts, just ask. Scripts Club members are not charged for initial help.

If you do rename a script to postwwwacct2, make sure you change the part where it checks for and runs further scripts. If postwwwacct2 contains the code:
if (-e "/scripts/postwwwacct2") {
    system("/scripts/postwwwacct2",@ARGV);
}
it will cause it to loop endlessly.


Custom Scripts main page

Scripts Club
for a small donation you get access to the WHM scripts and improved versions of other scripts,
as well as other luxuries of being a "Scripts Club" member.

Go Back