From 6702017ea5d679def3a052abe65e8cb97d547218 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 11 Jul 2007 22:49:22 +0000 Subject: Separate code into function catfirstfile(). --- postfix/postfix.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'postfix') diff --git a/postfix/postfix.sh b/postfix/postfix.sh index 63c10b8..e7093a4 100755 --- a/postfix/postfix.sh +++ b/postfix/postfix.sh @@ -3,7 +3,7 @@ # /etc/local-COMMON/postfix/postfix.sh # Copyright 2002-2004 Jonas Smedegaard # -# $Id: postfix.sh,v 1.36 2007-07-11 17:28:40 jonas Exp $ +# $Id: postfix.sh,v 1.37 2007-07-11 22:49:22 jonas Exp $ # # Auto-tweak plain installed postfix Debian package # @@ -55,6 +55,20 @@ else fi sasldir="$confdir/sasl" +function catfirstfile() { + for dir in $paramdirs; do + if [ -d "$dir" ] && [ -f "$dir/$param" ]; then + paramdir="$dir" + break + fi + done + if [ -z "$paramdir" ]; then + echo "ERROR: Parameter file for \"$param\" not found." + exit 1 + fi + cat "$paramdir/$param" +} + function getlinesfromfile() { param="$1" shift @@ -82,18 +96,8 @@ function getlinesfromfile() { replacements="$replacements;s/$oldparam/$newstring/" done paramdir='' - for dir in $paramdirs; do - if [ -d "$dir" ] && [ -f "$dir/$param" ]; then - paramdir="$dir" - break - fi - done - if [ -z "$paramdir" ]; then - echo "ERROR: Parameter file for \"$param\" not found." - exit 1 - fi echo -n "$param = " - cat $paramdir/$param | sed 's/#.*//' | tr '\n' ',' | sed -e 's/^[, ]*//;s/[, ]\+/,/g' -e 's/\^/ /g' -e "s/,\$//$replacements" + catfirstfile "$param" | sed 's/#.*//' | tr '\n' ',' | sed -e 's/^[, ]*//;s/[, ]\+/,/g' -e 's/\^/ /g' -e "s/,\$//$replacements" } # Inspired by D. J. Bernstein: http://cr.yp.to/smtp/greeting.html -- cgit v1.2.3