#!/bin/sh
#
# /usr/local/sbin/localmaildomainupdate
# Copyright 2004 Jonas Smedegaard <dr@jones.dk>
#
# $Id: localmaildomainupdate,v 1.2 2004-12-07 16:04:14 jonas Exp $
#
# Update an (already prepared!) mailuser file
#
# (wrapper script for localmkpostfixvirtual)
#

set -e

if [ $# -ge 1 ]; then
	maildomain="$1"
	virtualfile="virtual.$1"
	shift
else
	maildomain=""
	virtualfile="virtual"
fi

(
	cd /etc/postfix
	diff $@ $virtualfile $virtualfile.new || if [ $? = 1 ]; then /bin/true; fi
	echo -n "Above is the intended changes. OK to update (y/N)? "
	read do_update
	case $do_update in
	    y|Y)
		mv $virtualfile.new $virtualfile
		postmap $virtualfile
		;;
	esac
)