All pastes #233329 Raw Edit

Stuff

public text v1 · immutable
·published 2006-11-01 21:52 UTC
rendered paste body
#!/bin/bash

MAILBOX=$1

echo ""
echo "Restoring Folders for $MAILBOX"
echo ""
echo "Checking if Email Exist and HOME_DIR is set..."
DIR=`~vpopmail/bin/vuserinfo $MAILBOX@domain.com | grep dir: | awk '{print $2}'`

echo "	HOME_DIR reported is: $DIR"

MAILDIR="$DIR/Maildir"
echo ""
echo "Checking if $MAILDIR/ exists physically.."
if [ -d $MAILDIR ]
	then 
		
		echo "	$MAILDIR Exists .. "
		
	else
		
		echo "	Required Folder does not exist .. exiting."
		
	exit 101
fi
echo ""
OLDDIR="/home/domain.com/$MAILBOX"
echo "Checking if Directory $OLDDIR/ exists physically"
if [ -d $OLDDIR ]
	then 
		
		echo "	$OLDDIR Exists .. "
		
	else
		
		echo "	Old Folder does not exist .. exiting."
		
	exit 101
fi
echo ""
echo "Listing Files in $OLDDIR/"
echo " ----------- xx -------------"
echo ""
ls -al $OLDDIR/
echo ""
echo " ----------- xx -------------"
echo ""
echo "Preparing to copy & convert."
echo ""
echo "cd $MAILDIR/"
cd $MAILDIR/
FILES=($OLDDIR/*)
 for F in $FILES
	do

	echo "cp $OLDDIR/$F $MAILDIR/"
	echo ""
	echo "Current Directory is `pwd`"
	echo ""
		if [ $F == "inbox" ]
		then 
		mb2md inbox . 508 503
	elif [ $F == "INBOX.Drafts" ]
		then 
		mb2md "INBOX.Drafts" ".Drafts" 508 503
	
	elif [ $F == "INBOX.Sent" ]
		then
		mb2md "INBOX.Sent" ".Sent" 508 503
		
	elif [ $F == "INBOX.Trash" ]
		then
		mb2md "INBOX.Trash" ".Trash" 508 503

	else
		mb2md \"$F\" \"$F\" 508 503

	fi
	echo ""
	##echo "cd $OLDDIR/"
	echo "Removing $F"
	echo "rm -f $F"
	
 done
cd -