summaryrefslogtreecommitdiff
path: root/localmaildomainupdate
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2006-10-30 12:46:54 +0000
committerJonas Smedegaard <dr@jones.dk>2006-10-30 12:46:54 +0000
commit64de72df14cb2373830a1e02679ea68bb96f1302 (patch)
tree2a4645810749ca4fb12913fd4299ee74a57c7e1b /localmaildomainupdate
parent2334e6d4adda53e725b669d17e15d55a5f4c806b (diff)
Avoid changing workingdir. Explicity exit on errors (rather than continuing on success).
Diffstat (limited to 'localmaildomainupdate')
-rwxr-xr-xlocalmaildomainupdate40
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"