From 9baff2f5066fc752282d0d3b749dad3af69cd5fe Mon Sep 17 00:00:00 2001 From: B Stack Date: Sat, 27 May 2017 17:42:48 -0400 Subject: allows multiple zone names! --- usr/share/updatezone/updatezone.sh | 106 +++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/usr/share/updatezone/updatezone.sh b/usr/share/updatezone/updatezone.sh index c8b6571..d6d01c0 100755 --- a/usr/share/updatezone/updatezone.sh +++ b/usr/share/updatezone/updatezone.sh @@ -20,12 +20,13 @@ updatezoneversion="2017-05-27a" usage() { less -F >&2 <&2 -} +## DEBUG SIMPLECONF +#debuglev 5 && { +# ferror "Using values" +# # used values: EX_(OPT1|OPT2|VERBOSE) +# set | grep -iE "^UZ_" 1>&2 +#} # MAKE TEMP LOCATIONS tempdir=/tmp/updatezone/ @@ -261,22 +270,30 @@ then exit 4 fi -temp_for_file="$( mktemp -p "${tempdir}" forward.XXXX 2>/dev/null )" -temp_rev_file="$( mktemp -p "${tempdir}" reverse.XXXX 2>/dev/null )" -zones_to_thaw_file="$( mktemp -p "${tempdir}" thaw.XXXX )" -zones_to_update_file="$( mktemp -p "${tempdir}" update.XXXX )" -for word in "${temp_for_file}" "${temp_rev_file}"; -do - if test ! -f "${word}"; - then - ferror "${scriptfile}: 4. Unable to make temp file ${word}. Aborted." - exit 4 - fi -done - # MAIN LOOP -#{ - pause_to_show_error=0 +main() { + # call: main "${conffile}" + get_conf "$1" + # DEBUG SIMPLECONF + debuglev 5 && { + ferror "Using values" + # used values: EX_(OPT1|OPT2|VERBOSE) + set | grep -iE "^UZ_" 1>&2 + } + local temp_for_file="$( mktemp -p "${tempdir}" forward.XXXX 2>/dev/null )" + local temp_rev_file="$( mktemp -p "${tempdir}" reverse.XXXX 2>/dev/null )" + local zones_to_thaw_file="$( mktemp -p "${tempdir}" thaw.XXXX )" + local zones_to_update_file="$( mktemp -p "${tempdir}" update.XXXX )" + for word in "${temp_for_file}" "${temp_rev_file}"; + do + if test ! -f "${word}"; + then + ferror "${scriptfile}: 4. Unable to make temp file ${word}. Aborted." + exit 4 + fi + done + + local pause_to_show_error=0 # Check forward zone file and freeze check_zone_file forward "${UZ_FORWARD_ZONE}" "${UZ_FORWARD_FILE}" "${temp_for_file}" @@ -287,7 +304,8 @@ done fistruthy "${pause_to_show_error}" && sleep 1.3 # Allow user to edit files that exist - $EDITOR $( find "${temp_for_file}" "${temp_rev_file}" 2>/dev/null | xargs ) + local these_temp_files="$( find "${temp_for_file}" "${temp_rev_file}" 2>/dev/null | xargs )" + test -n "${these_temp_files}" && $EDITOR ${these_temp_files} # Update the real zone if the temp file was updated update_real_zone_if_updated "${UZ_FORWARD_ZONE}" "${UZ_FORWARD_FILE}" "${temp_for_file}" @@ -321,7 +339,29 @@ done done fi -#} | tee -a ${logfile} +} #| tee -a ${logfile} + + +if test -n "${conffile}"; +then + ( main "${conffile}"; ) +else + # assume the $opt items are the zone names + y=0 + while test $y -lt $thiscount; + do + y=$(( y + 1 )) + eval "thiszonename=\${opt${y}}" + debuglev 1 && ferror "Will try to update zone ${thiszonename}" + file_for_this_zone="$( grep -liE "UZ_ZONE_NAME=${thiszonename}" "${default_dir}/"*.conf 2>/dev/null )" + if test -n "${file_for_this_zone}" && test -f "${file_for_this_zone}"; + then + ( main "${file_for_this_zone}"; ) + else + ferror "Skipping zone ${thiszonename} for which no file was found in ${default_dir}/" + fi + done +fi # EMAIL LOGFILE #${sendsh} ${sendopts} "${server} ${scriptfile} out" ${logfile} ${interestedparties} -- cgit