SkyHorse.Org

DirectAdmin to cPanel : a partial BASH solution

I’m one of those who spent hours moving from DirectAdmin to cPanel, and in the meantime I’ve developed a couple of usefull tools to help me do it.

For the sanity of everyone ever trying to achieve this, forget googling because there is no tool available ATM. No one has ever started a script simply because the transition from DA to CP are so different that it is unthinkable.

There are scripts to move from cPanel to DirectAdmin though

I’ve started a BASH script that basically takes the files already available under the directories “backup” and “domains”, puts them nicely under one directory and tar-gzips it all. (the backup and domains directories come from untaring the User Backup created under DirectAdmin)

you then have to upload the resulting tar-gzip to the newly created cPanel account and untar-zip it. The file manager in cPanel does this with a click.

This script still has LOADS of problems, and if you’re unexperienced with the linux FS, permissions, etc… don’t come this way

What this does, however, is saving a lot of time if the accounts in question have many e-mails accounts (I did this because some of my clients had 100+ emails), and also takes care of the user files (public_html and everything else)

Resuming, this is what the script does:

- copy the quota file
- copy the IMAP folders and inbox folder of the main account
- copy the squirrelmail settings
for EACH e-mail account it does this:
- generate the entry and update the shadow and passwd file with its username and password (you keep everyone’s passwords!)
- copy the IMAP folders and inbox to the respective directory

to the domain files, it does this also:
- update references in every file (php, html, etc) by removing “domains/domain.net”
(ie /home/skyhorse/domains/skyhorse.org/public_html becomes /home/skyhorse/public_html)

This does not handle FTP settings, subdomain settings, dns settings, or anything else.
But hey, it saved me hundreds of hours of pain…

It is easily improved, so if you do, please send it back to me

BTW, the scripts assumes you’re using the SAME username in directadmin and in cpanel for each account, and the same domains as well.

It can also take a bit of hard disk space, since it literally duplicates the accounts files. If this is an issue, script around it to use the /tmp directory or even better, do some pipelining with tar

One last thing, although you see the CHMOD command being used, when untaring all files loose the damn permissions.
you NEED to change the permissions manually (inbox NEEDS to be group writable) or find a way to resolve the issue, which I couldn’t.

Here it is anyway, remember to replace the variables with your own settings:

# bash
# Copyleft (C) SkyHorse 2004
# for each account:
# put passwd as passwd + shadow
# quota (if != 0)
# into ~/etc/%domain%
GENDOMAIN=domain.com
GENUSERNAME=accuser
NEWACCPASS=accpass
MYFILESPATH=/home/skyhorse/temp_sites

mkdir result
mkdir result/mail
mkdir result/mail/$GENDOMAIN
mkdir result/etc
mkdir result/etc/$GENDOMAIN

cp $MYFILESPATH/$GENUSERNAME/backup/$GENDOMAIN/email/quota result/etc/quota
chmod 644 result/etc/quota

touch result/etc/shadow
chmod 640 result/etc/shadow

touch result/etc/passwd
chmod 644 result/etc/passwd

chmod 660 $MYFILESPATH/$GENUSERNAME/backup/email_data/imap/*
cp $MYFILESPATH/$GENUSERNAME/backup/email_data/imap/* result/mail
cp $MYFILESPATH/$GENUSERNAME/backup/email_data/pop/$GENUSERNAME result/mail/inbox
chmod 660 result/mail/inbox

mkdir result/.sqmaildata
cp $MYFILESPATH/$GENUSERNAME/backup/email_data/squirrelmail/* result/.sqmaildata

ENTRY=`cat $MYFILESPATH/$GENUSERNAME/backup/$GENDOMAIN/email/passwd`
for line in $ENTRY
do
login=`echo $line | sed s/[:].*//`
pass=`echo $line | sed s/.*[:]//`
mkdir result/mail/$GENDOMAIN/$login
mkdir result/mail/$login

echo $login:x:32120:622::/home/$GENUSERNAME/mail/$GENDOMAIN/$login:/usr/local/cpanel/bin/noshell >> result/etc/passwd
echo $login:$pass::::::: >> result/etc/shadow

chmod 750 result/mail/$GENDOMAIN/$login
cp $MYFILESPATH/$GENUSERNAME/backup/$GENDOMAIN/email/data/pop/$login result/mail/$GENDOMAIN/$login/inbox
chmod 660 result/mail/$GENDOMAIN/$login/inbox

cp $MYFILESPATH/$GENUSERNAME/backup/$GENDOMAIN/email/data/imap/$login/.mailboxlist result/mail/$GENDOMAIN/$login/
cp $MYFILESPATH/$GENUSERNAME/backup/$GENDOMAIN/email/data/imap/$login/mail/* result/mail/$GENDOMAIN/$login/

touch result/mail/$login/inbox
chmod 660 result/mail/$login/inbox
done

cp result/etc/* result/etc/$GENDOMAIN/

#domain files
cd domains/$GENDOMAIN
#update file references - this one liner deletes domains/domain.net in every file of the tree.
# efectively changes:
#/home/username/domains/domain.net/public_html into
#/home/username/public_html
find ./ -type f -exec sed -i ’s/domains\/$GENDOMAIN\///’ {} \;

cp -R * ../../result
cd ../../result

tar –owner=$GENUSERNAME –group=$GENUSERNAME -czf ../$GENUSERNAME-$GENDOMAIN.tar.gz *
cd ..

#upload tar.gz
#I have ncftpput installed, but because most people don’t, I’ve commented it out
#ncftpput -u $GENUSERNAME -p $NEWACCPASS localhost / $GENUSERNAME-$GENDOMAIN.tar.gz

#database:

#mysql

#subdomains

#ftp

Related posts:

  • DirectAdmin to cPanel : a partial BASH solution
  • The Definite Guide of Obscure Tweaks to Install and Maintain cPanel / WHM (version 10)
  • The future of E-mail
  • Tags

    AI apple behavioural-targeting business christianity Computing cPanel design DNS Downloads Games GNU/Linux google hacking Hardware headphones hosting Ideas Instant Messaging iphone islam marketing online-advertising online media Personal Philosophy poker Programming satire scripts search Security sociology startups technology Travel ubuntu v-moda Visionarism web-2.0 web-marketing Web Design WHM wunderloop
  • Pages

    • About
    • Web Server Administration
      • Auto update modsecurity rules - modsec.sh
      • DirectAdmin to cPanel : a partial BASH solution
      • The Definite Guide of Obscure Tweaks to Install and Maintain cPanel / WHM (version 10)
        • Configuring E-mail (Exim) related areas
        • Fixing open DNS servers
        • Monitoring your server
        • Scripts and misc information
        • Security by Obscurity
        • Tweaking apache web server
  • Twitter Updates

    • Ads

    • RSS NMA

      • Twentysix restructures senior staff roles 10 October, 2008
      • Geraldine Wilson leaves Yahoo for Truphone 10 October, 2008
      • Swiftcover launches UGC competition 10 October, 2008
    • RSS Brand Republic

      • ITV signs Sony for exclusive England sponsorship 10 October, 2008
      • TBWA-BMB deal scrapped at 11th hour 10 October, 2008
      • Nielsen forms China joint venture for web rankings 10 October, 2008
    • RSS iMedia Connection: Consumer Strategies

      • How to tailor display to every user
      • 3 top tools for branding in a Web 2.0 world
      • How to create better brand advocates
    • RSS Behavioural Targeting news

      • Mobile marketing budgets to grow 150% by 2013 - New Media Age 8 October, 2008
      • Expert claims some internet users understand behavioural targeting - Direct Traffic Media 24 September, 2008
      • BlueCentral Plants Flag in Britain - ARNnet 1 October, 2008
      • Brands set to increase mobile marketing spend - Mobile News 10 October, 2008
      • BlueCentral centralises in the UK - CRN Australia 2 October, 2008
    • RSS Adotas

      • Media Plan ’08: Look Out of the Window 10 October, 2008
      • Hiring Round Up: HealthCentral, Break Media, NetShelter 10 October, 2008
      • Microhoo: Back From the Dead? 10 October, 2008
    • RSS MarketingVox

      • YHOO Stakeholder Appeals to MSFT on Bended Knee
      • Verizon Lobs Per-Text Charge on Content Providers
      • Google Maps, Now Infused with AdSense
    • RSS SimsCity blog

      • Scalability 8 July, 2008
      • A message to Mac users 5 July, 2008
      • Transfering files from computer to iPhone 26 June, 2008
    • RSS Donald Hamilton

      • Online ad spending bucks trends 29 September, 2008
      • Ad:Tech 25 September, 2008
      • Phorm in the clear? 18 September, 2008
    • RSS Don't be Square

      • x 11 September, 2008
      • See no evil with TELEVISION 18 August, 2008
      • Science meets Culture = PHILOTAXIS 14 August, 2008
    • Ads

    • RSS mindcode

      • Proof of God 30 September, 2008
      • Good old-skool h4Ă—0r! 29 September, 2008
      • PLoP paper accepted 17 September, 2008
    • RSS ZDnet Security

      • Microsoft expected to release Silverlight 2 next week 10 October, 2008
      • Microsoft renames its 'D' language 'M' 10 October, 2008
      • The Apple II is baaaaccckk (via emulator) 10 October, 2008
    • TechDispenser


    • Blogroll

      • 90kts
      • Acxiom Poker Nights
      • Amy’s blog
      • Bytter’s blog
      • morena flor no samba da saudade
      • Not Quite There Yet
      • Swedish Pirate Party
    • Cartoons

      • Geek & Poke
      • Order of the Stick
      • User Friendly
    • Gaming

      • Neverwinter Nights
    • Personal

      • Atelier de Camisa
      • Banksy
      • Designarte
      • My Amazon Wishlist
      • SkyServers.Org
    • Science

      • Hermetic Research
      • New Scientist
      • Rex Research
      • ScienceBox
      • Wired
    • Security

      • GPG4Win
      • GPGol
      • GPGShell
      • Mod Security
      • Offline Windows NT(2k,XP) Password Recovery
    • Web Design

      • PageStrength
      • SiteScore
      • UrlTrends
    • Akismet

      32,059 spam comments
      blocked by
      Akismet

    © 2003 - 2008 Paulo Cunha | SkyHorse.Org is proudly powered by WordPress | Theme based on Bob