#!/bin/sh # # migrate-domain # John Simpson 2007-10-05 # # Full documentation at http://qmail.jms1.net/scripts/migrate-domain.shtml # # 2007-12-11 jms1 - adding explicit PATH assignment to generated script, # marking generated script executable. # # 2007-12-20 jms1 - fixing code to handle ezmlm lists and autoresponders. # # 2008-02-25 jms1 - removing double-quotes from PATH= line, some brain-dead # shells don't do tilde expansion within double quotes. # # 2008-02-29 jms1 - removed double-quotes from PATH= line in the generated # script as well... thanks to Bob Walter for keeping me honest. # # 2008-06-18 jms1 - changed "$DIR" to "\$DIR" in code which creates aliases # on the target machine. # ############################################################################### # # Copyright (C) 2007,2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 or version 3 of the # license, at your option. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### PATH=~vpopmail/bin:/usr/bin:/bin DOMAIN=${1:?No domain specified} SCRIPT=$DOMAIN.sh NOW=`date +"%Y-%m-%d %X %Z"` ############################################################################## # # start the output script echo Writing script header cat > $SCRIPT < 2008-02-29 # Documentation at http://qmail.jms1.net/scripts/migrate-domain.shtml # # Restores vpopmail domain $DOMAIN EOF echo 'PATH=~vpopmail/bin:/usr/bin:/bin' >> $SCRIPT DOMDIR=`vdominfo -d $DOMAIN | grep -v ^alias` ############################################################################## # # create the domain and handle the postmaster mailbox echo Backing up postmaster@$DOMAIN EPW=`vuserinfo -p postmaster@$DOMAIN` GECOS=`vuserinfo -c postmaster@$DOMAIN` QUOTA=`vuserinfo -q postmaster@$DOMAIN` DIR=`vuserinfo -d postmaster@$DOMAIN` ( cd $DIR ; tar cf - . ) | gzip -c9 > $DOMAIN-postmaster.tar.gz cat >> $SCRIPT < $DOMAIN-$USER.tar.gz cat >> $SCRIPT </dev/null | cut -d" " -f5 | \ while read adir do aname=`echo $adir | sed 's/^.*\///'` echo Backing up autoresponder directory $aname ( cd $DOMDIR ; tar cf - $aname ) | gzip -c9 > $DOMAIN-$aname.tar.gz cat >> $SCRIPT </dev/null | \ cut -d"'" -f2 | sort | uniq | \ while read ldir do lname=`echo $ldir | sed 's/^.*\///'` echo Backing up list $lname ( cd $DOMDIR ; tar cf - $lname ) | gzip -c9 > $DOMAIN-$lname.tar.gz cat >> $SCRIPT < $DOMAIN.qmail.tar.gz cat >> $SCRIPT <