kishenhawkins

Registered
Mar 26, 2006
4
0
151
Hello,

Is it possible to make a custom script that will make a couple of things happen when certain accounts are created:
1. Install a database in MySQL
2. Copy some php/html files into the accounts web root directory

Basically i have several versions of my cms that i want to auto-install for customers depending on which package they have... so for some packages i will install database A wih fileset A and for for other packages maybe whm will auto instal database B with fileset B.

Is this completely possible and does anyone know where i can go to get this done?

Thanks!
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
As for #1 in your message, I'm not sure about how to go about doing that ...

As for #2 in your message, that can be done with the use of the skeleton directories ...
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
Don't know if this is helpful or overkill, but I use a really neat little technique to enable me to drop files into the postwwwacct path. I create a directory /etc/postwwwacct.dir which contains a bunch of scripts which are run in alpha order every time an account is created.

Check out this link for the script and some examples of drop-in scripts that work with this technique, for instance, one to enable accounts with certain plans for MailScanner, and another to assist with SohoLaunch installation by renaming a default index.php out of the way when the account is created (a cron script renames it back after soholaunch is installed).

As far as the original poster goes, check out the scripts and you'll see how to check against existing plans, there are several that do that.

I wrote this for myself, but the limited doco that exists is in the postwwwacct script, read the comments at the top - the current version of those comments is duplicated below.

To install, copy the postwwwacct file into /scripts/postwwwacct and make it executable:
Code:
cp  postwwwacct /scripts/postwwwacct
chmod 755 /scripts/postwwwacct
Here's the (limited) doco:
Code:
#  Cpanel postwwwacct script multiplexer
#
#   Run multiple account post-creation scripts from a given directory.
#   (/scripts/postwwwacct.dir, changeable via dir= below)
#   This allows multiple account setup scrpts to be easily run without
#   fiddling around too much.
#   This could be done in in about 4 lines without error checking!
#
#  In operation:
#   Prints a line announcing the start of postwwwacct scripts, then
#   runs them.  Prints a line announcing each script, unless the magic
#   string "@@SILENT@@" is in the script, when it will not be announced.
#   Error exit statuses are displayed in bold.  Contains loop detect code
#   in case someone is silly enough to copy this into $dir!
#
#   To install,
#	cp postwwwacct.multiplex /scripts/postwwwacct
#	chmod 755 /scripts/postwwwacct
#	mkdir /etc/postwwwacct.dir
#   To add scripts:
#	cp script1 /etc/postwwwacct.dir/script1
#	chmod 755 /etc/postwwwacct.dir/script1
#
 

kishenhawkins

Registered
Mar 26, 2006
4
0
151
Hi again

am i going to need a dedicated server to do what brianoz suggests or can it be done on shared reseller hosting?

btw, brianoz - love your site, very cool.
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
kishenhawkins said:
am i going to need a dedicated server to do what brianoz suggests or can it be done on shared reseller hosting?
You need a dedicated server to run the postwwwacct scripts, as they run as root. A friendly server owner might help you but probably unlikely.

However, to just install default code into your new directories it's just a matter of creating a cpanel3-skel directory in your reseller account, and the contents of that will then be copied into the new user account. To make this manageable you should probably have that be a script that just includes a master .php file from your reseller account -- so that you can change the displayed text by changing the one master .php file rather than having to change them all.

Installing a database in mysql is a little trickier. One way of doing it would be to have it done by the master .php file - the first time it's run, it runs some special code which creates the database. Subsequent times it would check for the database and not recreate it. Not that hard to code for a PHP programmer!

To find the plan, you'd look in /var/cpanel/users/username and look for the PLAN= line. Then, extract a tar file named after the plan from your directory, maybe edit the extracted files to replace a known string with the accountname if needed, and run a script included in the tar file and then delete that script. You wouldn't have access to the cpanel password at this stage unfortunately which may make some things a lot harder - although you could just ask for it.

Using this method you'd have to visit the webpage as soon as you created it to get this code to run. If you could do it without asking for the password it would be pretty transparent if the user was first to visit.
 

asuservice

Well-Known Member
Oct 24, 2001
83
0
306
I agree

Also, Mike has some useful scripts in his "scripts club" at http://www.premierwebsitesolutions.com/scripts/ ...
I know this is an old post but I wanted to give my kudos to Mike! I have implemented several of his scripts and they work great. Additionally he has written some mods to them for me at a VERY reasonable price.

Save yourself a LOT of time and headaches by checking out what Mike has to offer!

That URL has been under redesign for a while but you can find his poswwwacct scripts at here

He has more so I'm sure if you contact him from his main page he'll hook you up.