cPanel creates a whole wack of configuration files when you run through the Create Account Wizard so doing this process by hand would likely be more time-consuming and tedious than it would be to use the Wizard. That being said, if you only have home directory data to worry about for each user, you can easily just hack together a Bash script (like the one below :)) to move the home directory data out of the way (say /home/user.bak), kill the account (userdel -r user
), create the account,and finally move the data back. Note that if the home directory for the user contains web content, under the cPanel directory schema, that content needs to be moved into ~/public_html
.
Here's a very simple bash script, which takes a list of accounts from a text file and does what I mentioned above. Note the text file is formatted domain.com:user
as cPanel won't create an account without a domain name. You'll have to setup this mapping manually when you create that file or come up with a way to script using awk/grep from your existing config. The script also creates a password for all of the accounts of 'temppass' -- make sure you change that! :)
#!/bin/bash
# Replace this with the file you use
FILE=/root/acctlist
for USER in `awk -F':' {'print $2'} $FILE`
do
mv /home/$USER /home/$USER.bak
userdel -r $USER
DOMAIN=`grep $USER|awk -F':' {'print $1'}`
/scripts/createacct $DOMAIN $USER temppass
cp -a /home/$USER.bak/* /home/$USER/
#Uncomment this if you're sure you want to remove the old dir
# rm -rf /home/$USER.bak
done