diff options
-rwxr-xr-x | localmaildomainupdate | 40 |
1 files changed, 23 insertions, 17 deletions
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 <dr@jones.dk> # -# $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" |