#!/usr/local/bin/bash #################### # neomail2owb v0.2 # # 28/08/2004 # #################### # 21/08/2004 v0.1 # * First release # 28/08/2004 v0.2 # * fixed multipie .folder error # * chowns files to uid/gid listed in /etc/passwd # known bugs # * doesn't copy *.folder files which contain space # this script is exporting user data from NeoMail to OpenWebMail # you may (and probably you will need to) modify this script any way you want # to, but remember - you are using it at your own risk! # (c) Pyzmen 2004 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin neomail=/var/neomail/ chkmail() { if [ ! -d $uhome/mail ]; then mkdir $uhome/mail chown -R $uid:$gid $uhome/mail fi if [ ! -d $uhome/.openwebmail ]; then mkdir $uhome/.openwebmail mkdir $uhome/.openwebmail/webmail chown -R $uid:$gid $uhome/.openwebmail fi } chattr() { chmod 600 $1 chown $uid:$gid $1 } for i in `ls $neomail/users` do uhome=$(awk -F: "{if (\$1 == \"$i\") {print \$6}}" /etc/passwd) uid=$(awk -F: "{if (\$1 == \"$i\") {print \$3}}" /etc/passwd) gid=$(awk -F: "{if (\$1 == \"$i\") {print \$4}}" /etc/passwd) cd $neomail/users/$i echo "exporting $i's data" chkmail folder=`ls *.folder | head -n 1` if [ -a "$folder" ]; then for j in `ls *.folder` do cp "$j" $uhome/mail/`ls "$j" | sed s/\.folder//g` chattr $uhome/mail/`ls "$j" | sed s/\.folder//g` done fi if [ -f SAVED ]; then cp SAVED $uhome/mail/saved-messages chattr $uhome/mail/saved-messages fi if [ -f SENT ]; then cp SENT $uhome/mail/sent-mail chattr $uhome/mail/sent-mail fi if [ -f TRASH ]; then cp TRASH $uhome/mail/mail-trash chattr $uhome/mail/mail-trash fi if [ -f addressbook ]; then sed s/:/@@@/ addressbook | sed s/$/@@@/ > $uhome/.openwebmail/webmail/address.book chattr $uhome/.openwebmail/webmail/address.book fi if [ -f signature ]; then if [ $(wc -c signature | awk -F " " '{printf($1)}') != 76 ]; then cp signature $uhome/.openwebmail/webmail/ chattr $uhome/.openwebmail/webmail/signature fi fi done