Re: [vchkpw] domain & user scripts

2004-01-24 Thread Jason Parker
On Friday, January 23, 2004, at 11:40 PM, Jeremy Kitchen wrote:

On Fri, 2004-01-23 at 19:41, Jason Parker wrote:
FYI -
[snip]

so what's wrong with rsync?

-Jeremy
In short - I may only have one system to work with in this case 
(working on that)... there is still tar. I'm not storing mail and am 
rebuilding stuff fresh. I just wanted the user info. I haven't used 
vconvert before and it is not entirely clear what happens/will 
happen I don't have prior experience migrating vpopmail domains, 
but I assume the procedure you allude to would be to vconvert to cdb 
from mysql, rsync the entire domain tree to the new system and then 
vconvert to postgres... and there is still tar... the procedure has 
become more clear to me as I get closer to doing it ... still I just 
wanted a plain text backup... anyway, I wrote the scripts and posted 
them...

-jason



Re: [vchkpw] domain & user scripts

2004-01-23 Thread Jeremy Kitchen
On Fri, 2004-01-23 at 19:41, Jason Parker wrote:
> FYI -
[snip]

so what's wrong with rsync?

-Jeremy

-- 
Jeremy Kitchen <[EMAIL PROTECTED]>



[vchkpw] domain & user scripts

2004-01-23 Thread Jason Parker
FYI -

Here are two scripts (further below) I wrote as an alternative to 
moving domains and users.

vmakeadddomains will read your domains and create a script to recreate 
those domains to another working system. Pretty simple. It doesn't 
attempt to move any domain settings.

vmakeaddusers will read all users and create a script to recreate those 
users for each domain.
It only works with clear passwd set on.
It recreates the user, quota, comment and passwd. All other items are 
left behind.
It doesn't move postmaster, assuming that creating the domain creates 
postmaster.

For both scripts remember to chmod 755... on them and then their 
outputs (I decided this was a good pause for the admin to consider what 
they were going to do :-)

I did this because I'm moving a small setup to a new os install and 
from MySQL to Postgres. I wanted a backup of what I had and an 
alternative for the bit clunky vconvert shuffle in case of trouble ...

-jason

vmakeadddomains  
#!/bin/bash
#
vpath=/var/qmail/vpopmail
domains=`$vpath/bin/vdominfo`
domains=`echo "${domains}" | grep domain:`
domains=`echo "${domains}" | sed "s/^domain://"`
echo "Domains found:"
echo "${domains}"
echo "Creating vadddomains file ..."
thecode="#!/bin/bash
# recreates vpopmail domains
# edit to suit
"
for dom in $domains
do
thecode="${thecode}
echo \"Adding domain: $dom ...\"
${vpath}/bin/vadddomain -u vpopmail ${dom} "
done
echo -e "${thecode}" > vadddomains

echo ""
cat vadddomains
echo ""
echo "Copy the vadddomains file to the new installation."
echo "Edit it to suit the new installation."
echo "chmod 755 vadddomains before running."
# end
vmakeaddusers-
#!/bin/bash
# Works only with clear passwds enabled
vpath=/var/qmail/vpopmail
domains=`$vpath/bin/vdominfo`
domains=`echo "${domains}" | grep domain:`
domains=`echo "${domains}" | sed "s/^domain://"`
echo "Domains found:"
echo "${domains}"
headcode="#!/bin/bash
# recreates vpopmail user for a given domain
# edit to suit
"
for dom in $domains
do
echo "Creating vaddusers.${dom} file ..."
thecode="${headcode}"
# do the users for the domain
users=`$vpath/bin/vuserinfo -n -D $dom`
for user in $users
 do
if [ "${user}" = "postmaster" ] ; then
   continue
fi
quota=`$vpath/bin/vuserinfo -q [EMAIL PROTECTED]
if [ -n "${quota}" ] ; then
   quota="-q ${quota}"
fi
comment=`$vpath/bin/vuserinfo -c [EMAIL PROTECTED]
comment=`echo $comment | sed "s/^ *//"` # in case it has all spaces
if [ -n "${comment}" ] ; then
   comment="-c ${comment}"
fi
passwd=`$vpath/bin/vuserinfo -C [EMAIL PROTECTED]
thecode="${thecode}
echo \"Adding user: $user ...\"
$vpath/bin/vadduser ${quota} ${comment} [EMAIL PROTECTED] ${passwd}"
 done
echo -e "${thecode}" > vaddusers.${dom}
done
echo ""
echo "Copy the vaddusers. files to the new installation."
echo "Edit each to suit the new installation."
echo "chmod 755 on each before running."
#end