config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  OLD="$(dirname $NEW)/$(basename $OLD .sample)"
  OLD="$(dirname $NEW)/$(basename $OLD .dist)"

  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

mkgroup() {
  GROUP="$1"
  if ! grep -qe "^$GROUP:" etc/group; then
    echo Creating group $GROUP...
    chroot . /usr/sbin/groupadd $GROUP
  fi
}

mkuser() {
  USER="$1"
  if [ ! -z "$2" ]; then
    GROUP="$2"
  else
    GROUP="$USER"
  fi
  if ! grep -qe "^$USER:" etc/passwd; then
    echo Creating user $USER...
    chroot . /usr/sbin/useradd $USER -g $GROUP
  fi
}

config etc/postfix/access.new ; config etc/postfix/aliases.new ; config etc/postfix/canonical.new ; config etc/postfix/generic.new ; config etc/postfix/header_checks.new ; config etc/postfix/main.cf.new ; config etc/postfix/master.cf.new ; config etc/postfix/relocated.new ; config etc/postfix/transport.new ; config etc/postfix/virtual.new; config etc/rc.d/rc.postfix.new
( cd usr/sbin ; rm -rf newaliases )
( cd usr/sbin ; ln -sf ../../usr/sbin/sendmail newaliases )
( cd usr/sbin ; rm -rf mailq )
( cd usr/sbin ; ln -sf ../../usr/sbin/sendmail mailq )
( cd usr/doc/postfix-2.5.6 ; rm -rf INSTALL )
( cd usr/doc/postfix-2.5.6 ; ln -sf README_FILES/INSTALL INSTALL )
