SkyHorse.Org

DirectAdmin to cPanel : a partial BASH solution

September 21st, 2005 SkyHorse

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

DeliciousFacebookTwitterLinkedInShare/Bookmark
Tags: cPanel, directadmin, Downloads, hosting, Programming, scripts, Web Design, WHM

Related posts:

  • The Definite Guide of Obscure Tweaks to Install and Maintain cPanel / WHM (version 10)
  • Server-side redirection (a.k.a. tunneling) with PHP
  • modsec.sh updated

Posted in Downloads, Programming, Web Design | No Comments »

Qosmio G20

September 11th, 2005 SkyHorse

I never had a wishlist, but if I ever start one this litle beautiful girl will be on top:

Qosmio G20

Qosmio G20

Take a mix of Apple design, two SATA 100Gb disks with RAID0, the best in processing power available (including a GEForce 6600 PCIx16 with 128ram), the best TFT I have ever seen with in-built TV and DVD decoder which dont require the PC to be turned on and you end up with something to droll for. I know I have. Did I mention the looks? You have to see this one for yourself.

DeliciousFacebookTwitterLinkedInShare/Bookmark
Tags: Personal, Programming

Related posts:

  • Hi-Tech, Low-Work
  • My first (real) game of Poker
  • Reminiscence from Bologna (English really lacks the word…)

Posted in Personal, Programming | No Comments »

Server-side redirection (a.k.a. tunneling) with PHP

August 1st, 2005 SkyHorse

Some web applications, like my own cPanel and Web Mail, use non-standard tcp ports. Usually this is because they are part of a software package that runs alongside Apache but does not use it to serve the pages.

Problem is many corporate and university firewalls do not allow access to ports such as 2095 and makes all the neat web apps like the ones above completely useless until you get home (where you probably have some other e-mail software anyway).

For some time I have used a simple port redirector installed on my home computer which allowed me to see my e-mails from my work place and my university. This is a bit annoying, though, because not only I have to leave my pc on the all day just for this but also because it is a slower connection and I am the only one who can use it (yes, I am thinking about my own hosting clients/partners who complain about the same problem).

So, I am starting a journey to make a ‘transparent’ PHP application that can successfully accept an incoming HTTP connection, grab the headers and open a server-side connection to another service and use the incoming headers for the request. Upon reception of the response, the script must alter *all* tags to its own name and append a single GET variable with the original href.

Thus, on a simple page, where there is a:

<a xhref="www.skyhorse.org/abc.html?I=rule" mce_href="www.skyhorse.org/abc.html?I=rule">

there will be a:

<a xhref="redirector.php?requestedURL='www.skyhorse.org/abc.html?I=rule'" mce_href="redirector.php?requestedURL='www.skyhorse.org/abc.html?I=rule'">
.

I still don’t know if the use of ‘ or even ” will be tolerated by the HTTP request, but I think as a last resort I can always do some kind of two-way encoding (like base64 or something similar) to encode the original request in an AsciiSimple format.

For now, I have some proof of concept working (yikes, I can open a server-side socket in PHP!) but I am still a long way before I turn off my home computer during the day :)

If anyone has any information on how to accomplish what I am trying to do, please, do give me a shout :)

– Update 1

After some time I discovered another major issue: Images!
I think I will have to make a standalone script or function in PHP just to handle the redirection of images… yes, because there has to be a request for images to a PHP script and those images have to be quested server-side and returned… mmm … maybe not that complicated, just a redirect.php?requestImage=originalURL and the request.php will take care of returning just the binary information taken directly from the server-side connection made to the service… could work… will work!

–Update 2

Ok, so, I finally discovered I was re-inventing the wheel…
I had already looked for this on the web, but couldn’t find anything. But now I stumbled upon cpanelproxy .
It does exactly what is says on the label: server-side proxy to cPanel.
It’s funny how the script I was writting was starting to look like the script they made! Unfortunatelly it does not yet support SSL, perhaps I could find a way to implement it, but I think it would be almost impossible…

DeliciousFacebookTwitterLinkedInShare/Bookmark
Tags: cPanel, Ideas, Programming, Web Design, WHM

Related posts:

  • DirectAdmin to cPanel : a partial BASH solution
  • The Definite Guide of Obscure Tweaks to Install and Maintain cPanel / WHM (version 10)
  • modsec.sh updated

Posted in Ideas, Programming, Web Design | No Comments »

Hi-Tech, Low-Work

May 30th, 2005 SkyHorse

1 Laptop
1 PDA with GSM, GPRS, Bluetooth and Wi-Fi (HTC BlueAngel)
1 GSM Phone with Bluetooth (SonyEricson T610)
Wi-Fi internet access

Result?

I can’t send a *#”$% FAX!

There I am, ready to fax my resignation letter to my manager, all neat and stuff, and as I was preparing myself to do “Print -> Fax” I discover I don’t have the Fax service installed on my Windows XP.
Ok, fine, I though maybe I’ll just use the fax application on my PDA, which by the way I never thought I would ever use. So I transfer the word document. Well, not really, it doesn’t transfer for some reason (apparently the conversion fails). After some messing around, I get it to convert and bang I open it in the PDA. Everything is ok there, Uf!
Opening the document with KSE TrueFax to send it shows that my signature (an image in the document) just disappeared. Oh great! as I try to click on the space where the signature should be, I discover I can actually write in the document!!! ok, fantastic, I just fiddle my signature in that space, even if it looks a bit pixelized…
So there I go! Fax – Send…wait…phone turns off…error no carrier detected. Funny… I don’t remember seeing this in the instructions manual. So I try again and the same problem occurs. Right, n’enough of this new hi-tech solution, lemme just try to use the PDA as a fax/modem.
What should be an easy task of adding a phone as a modem, turns out to be a quest for missing drivers that don’t work and the discovery that the “Fax service” is not available on the phone, only the “modem” bit… and even the modem seems to be very ‘nice’: it replies OK to every single AT command… go figure!
Ok, back to step 1: getting the Fax installed in Windows. Maybe I’ll just fax it through the normal land line. There I go, Add/Remove programs -> components -> fax… I tick and I say next… and it says it needs Windows XP SP2 cd-rom, which I actually have. So I insert it and it says it cannot find the bloody file it needs… I check manually and it’s right there!!! what do you mean you cant see it? I can see it! go get it!!!! … Oh well, I’ll just do it manually…
Some ‘expands’ later I have all fx* files under windows\system32. I try to do “Setup Fax” in the printers folder and it inserts the fax… but takes it off straight away!
I’m beginning to wonder if this is all a big conspiracy against my resignation from the company…
Only 3 hours later, after messing around with the security database (apparently this is what happens when the security database in windows gets messed up), I get the Fax component to install. Great I think! Now I can use the normal modem to Fax it!
So I do… and the land line seems to be making funny noises to the point that fax doesn’t get through… AAAARGGGH
I am not going to try any other solution, so I just kept trying and after like 5 attempts (how much noise can a line have?! I’m only sending one page!!!) I get the fax through… Was it worth it? Maybe I shouldn’t be quitting my job…

DeliciousFacebookTwitterLinkedInShare/Bookmark
Tags: Personal, Programming

Related posts:

  • Qosmio G20
  • jEdit – Programmers Text Editor
  • DirectAdmin to cPanel : a partial BASH solution

Posted in Personal, Programming | No Comments »

Java and Nuclear facilities

May 12th, 2005 SkyHorse

In a time where nuclear crisis seem to bloom, it is no wonder everyone is doing their bit to avoid another major disaster.
But if it does, what will everyone be looking for? The software running on the problematic server that crashed when it shouldn’t!
Well, if you don’t think so, Sun seems to at least by the looks of their software License.
In the bottom end you’ll read:

“You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility.“

Like if anyone would even dream of running Java for operating a nuclear facility…

DeliciousFacebookTwitterLinkedInShare/Bookmark
Tags: business, java, nuclear, Programming, software-licenses, sun

Related posts:

  • H2N-Gen: VaporWare?
  • Satire: Microsoft Patents Ones, Zeroes
  • Turning a camera phone with bluetooth into a mouse (HID for you and me)

Posted in Programming | No Comments »

« Previous Entries
Next Entries »
  • Tags

    advertising AI apple behavioural-targeting business Computing cPanel deep packet inspection Downloads DSP Games GNU/Linux google hacking hacking Hardware headphones hosting Ideas Instant Messaging iphone marketing online-advertising online media Personal Philosophy phorm poker Programming satire scripts Security sociology startups technology Travel ubuntu v-moda Visionarism web-2.0 web-marketing Web Design WHM wunderloop yahoo
  • 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 ExchangeWire.com

      • The PostView: Is Cutting Supply Really The Answer To The Current Malaise In Display Advertising? 9 February, 2012
      • Euro Round-Up: The French Get “Serieux” About RTB; mediascale Reports Strong 2011 Growth; Jemm Goes All-In With AppNexus 9 February, 2012
      • Moving On From Retargeting: Why Prospecting In Display Is Good For The Industry 8 February, 2012
    • RSS Lies, Damned Lies…

      • Big (Hairy) Data 8 February, 2012
      • Building the Perfect Display Ad Performance Dashboard, Part II – metrics 20 December, 2011
      • Should Wikipedia accept advertising? 21 November, 2011
    • RSS iMedia Connection: Consumer Strategies

      • A consumer-driven mindset in a big media package
      • Learn to leverage the social-search connection
      • Your social media disaster kit
    • RSS Segmentacion por comportamiento

      • Comment Notifications! 10 February, 2012
      • New Themes: Splendio and Suburbia 7 February, 2012
      • Post Videos from Your iPhone or iPad 3 February, 2012
    • RSS Sandlines

      • The Social Phone doesn’t come with an IVR menu 7 November, 2011
      • Are you ready for Big Data? 2 November, 2011
      • Sandlines @ Mediapro 29 October, 2011
    • RSS Adotas

      • Covario Issues Annual Client Awards for SEO/SEM Success 10 February, 2012
      • Infographic: The Online Ad Industry Is Like the Stock Market 10 February, 2012
      • Mobile Search: More Intent, More SMB Opportunity 10 February, 2012
    • RSS NMA

      • Q&A: Lee Jury, VP studio marketing, The Walt Disney Company EMEA 10 February, 2012
      • Kraft poaches PepsiCo’s global digital chief 9 February, 2012
      • Zeebox launches click-to-buy TV ad service 9 February, 2012
    • RSS Brand Republic

      • NEWSPAPER ABCs: 20p i overtakes The Guardian after TV campaign 10 February, 2012
      • VIDEO: Audi 'believes there is growth in the UK market', says Chambers 10 February, 2012
      • Betfair to knock rivals for the first time in campaign 10 February, 2012
    • RSS MarketingVox

      • Transaction Emails as Marketing Channel? Yes, But Tread Carefully 10 February, 2012
      • Another Shift for AdMob Next Week 10 February, 2012
      • Engagement on Google+. Finally 10 February, 2012
    • RSS Behavioural Targeting news

      • Internet Broadcasting and Exact Drive to Provide Comprehensive Digital ... - Sacramento Bee 9 February, 2012
      • IP Audience Zones Provides Advertisers with Nearly 100% Qualified Reach - Sacramento Bee 8 February, 2012
      • IG Index Launches Cross Platform Campaign - Sacramento Bee 8 February, 2012
      • UK Agency Digital & Wise Partners with Web Optimization Provider SiteSpect to ... - MarketWatch (press release) 6 February, 2012
      • Online behavioural targeting: Q&A - Telegraph.co.uk 1 February, 2012
    • Ads

    • Blogroll

      • 90kts
      • Acxiom Poker Nights
      • Amy’s blog
      • Bytter’s blog
      • Impare Arquitectura
      • Impare Design
      • 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
    • online media

      • Knowledge for the Digital Economy
      • Mike on Ads
    • Personal

      • Banksy
      • Designarte
      • Made to measure shirts – Atelier de Camisa
      • My Amazon Wishlist
      • SkyServers.Org
    • Science

      • 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

      99,826 spam comments blocked by
      Akismet
    • Meta

      • Log in
      • Entries RSS
      • Comments RSS
      • WordPress.org

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