diff options
author | Jonas Smedegaard <dr@jones.dk> | 2007-07-11 22:49:22 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2007-07-11 22:49:22 +0000 |
commit | 6702017ea5d679def3a052abe65e8cb97d547218 (patch) | |
tree | ff3ba3113e56a7179e5793df5b169d34f430bbc7 | |
parent | d71c1d985c8cfc117ad3e9a2aad7f9111016a150 (diff) |
Separate code into function catfirstfile().
-rwxr-xr-x | postfix/postfix.sh | 28 |
1 files changed, 16 insertions, 12 deletions
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 <dr@jones.dk> # -# $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 |