Make it work with set -u
[mirror/dsa-puppet.git] / modules / geodns / files / common / recvconf
index e3acbd3..e124e71 100755 (executable)
@@ -4,13 +4,21 @@ set -e
 set -u
 
 ## Copyright (c) 2005 David B. Harris <dbharris@eelf.ddts.net>
-## Copyright (c) 2005 Peter Palfrader <peter@palfrader.org>
+## Copyright (c) 2005,2009 Peter Palfrader <peter@palfrader.org>
 
 ## This text is released under the "three-clause BSD license".
 ## The full text of the license is available at the end of this file.
 
+if [ "$#" != 1 ]; then
+       echo "Usage: $0 <recvconf.files>" >&2
+       exit 1
+fi
+
+FILELIST="$1"
+
 printf "\nrecvconf on %s processing:\n" "$(hostname -s)"
-FILELIST=/etc/NOREPLY/recvconf.files
+
+umask 077
 
 temptar="$(mktemp)"
 chmod 0600 "$temptar"
@@ -86,7 +94,14 @@ copy_and_runcommands() {
 
 IN=0
 linenum=0
+file=""
 nextfile=""
+
+clear_vars() {
+       perms=""; user=""; group=""; precommand=""; postcommand=""
+}
+clear_vars
+
 while read line; do
     linenum="$(($linenum + 1))"
 
@@ -112,7 +127,7 @@ while read line; do
        ## the file, then set a $file to the new value and continue parsing.
        [ -n "$file" ] && copy_and_runcommands "$file" "$perms" "$user" "$group" "$precommand" "$postcommand"
        file="$(printf "%s" "$line" | sed -e 's/[[:space:]]*file[[:space:]]\+\([^[:space:]#]*\).*/\1/')"
-       perms=""; user=""; group=""; precommand=""; postcommand=""
+       clear_vars
        continue
     fi