commands/vconf2dir
author "Tomas Zeman <tzeman@volny.cz>"
Wed, 16 Jan 2008 22:39:43 +0100
changeset 0 6f7a81934006
permissions -rwxr-xr-x
Imported vmailmgr-0.96.9

#!/bin/sh
set -e
if [ $# -ne 2 ]; then
  echo Usage: vconf2dir configuration-file configuration-dir
  exit 1
fi

sed -e '/^#/d' -e '/^ *$/d' -e '/=/!d' -e 's/ *= */ /' <"$1" | \
{
  if ! cd "$2"; then
    echo vconf2dir: "$2" is not a directory.
    exit 1
  fi
  while read n v; do
    echo "$v" > $n
  done
}

cd "$2"
# Post-process postmaster-aliases
if [ -f postmaster-aliases ]; then
  pa=`cat postmaster-aliases`
  echo -n >postmaster-aliases
  i=1
  v=`echo $pa | cut -d, -f$i`
  while [ -n "$v" ]; do
    echo $v >>postmaster-aliases
    i=`expr $i + 1`
    v=`echo $pa | cut -d, -f$i`
  done
fi