From 64de72df14cb2373830a1e02679ea68bb96f1302 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 30 Oct 2006 12:46:54 +0000 Subject: Avoid changing workingdir. Explicity exit on errors (rather than continuing on success). --- localmaildomainupdate | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'localmaildomainupdate') diff --git a/localmaildomainupdate b/localmaildomainupdate index dbe7bff..06af6f0 100755 --- a/localmaildomainupdate +++ b/localmaildomainupdate @@ -3,7 +3,7 @@ # /usr/local/sbin/localmaildomainupdate # Copyright 2004-2006 Jonas Smedegaard # -# $Id: localmaildomainupdate,v 1.4 2006-10-30 12:34:31 jonas Exp $ +# $Id: localmaildomainupdate,v 1.5 2006-10-30 12:46:54 jonas Exp $ # # Update an (already prepared!) mailuser file # @@ -21,19 +21,25 @@ else virtualfile="virtual" fi -( - cd /etc/postfix - localmkpostfixvirtual $maildomain > $virtualfile.new - if [ -f /etc/postfix/$virtualfile.addon ]; then - cat /etc/postfix/$virtualfile.addon >> $virtualfile.new - fi - diff $@ $virtualfile $virtualfile.new || if [ $? -eq 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 -) +pfdir="/etc/postfix" + +localmkpostfixvirtual $maildomain > $virtualfile.new +if [ -f "$pfdir/$virtualfile.addon" ]; then + cat "$pfdir/$virtualfile.addon" >> "$pfdir/$virtualfile.new" +fi + +diff $@ "$pfdir/$virtualfile" "$pfdir/$virtualfile.new" || if [ $? -gt 1 ]; then exit $?; fi + +echo -n "Above is the intended changes. OK to update (y/N)? " +read do_update +case $do_update in + y|Y) + ;; + *) + echo "Update aborted!" + exit 1 + ;; +esac + +mv "$pfdir/$virtualfile.new" "$pfdir/$virtualfile" +postmap "½pfdir/$virtualfile" -- cgit v1.2.3