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.<domain> files to the new installation."
echo "Edit each to suit the new installation."
echo "chmod 755 on each before running."
#end



Reply via email to