From: Fred T. Hamster Date: Tue, 30 Oct 2018 16:38:39 +0000 (-0400) Subject: improved comparator X-Git-Tag: 2.140.115^2~70 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=29459d45ad974eb7ea75ead01fbe7b7cf61b1dba;p=feisty_meow.git improved comparator now can compare our archives against almost arbitrary locations. compare dirs now complains if a local or remote directory fails to be changed to. --- diff --git a/scripts/archival/comparator.sh b/scripts/archival/comparator.sh index 236cc2c5..90ad0918 100644 --- a/scripts/archival/comparator.sh +++ b/scripts/archival/comparator.sh @@ -3,14 +3,17 @@ # compares this machine's local archives against an exemplar set. target="$1"; shift - if [ -z "$target" ]; then target=wildmutt #target=curie fi +where="$1"; shift +if [ -z "$where" ]; then + where=/z +fi source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" source "$FEISTY_MEOW_SCRIPTS/archival/general_updater.sh" -uber_archive_comparator $target +uber_archive_comparator $target $where diff --git a/scripts/archival/general_updater.sh b/scripts/archival/general_updater.sh index 7dac5777..c0431eee 100644 --- a/scripts/archival/general_updater.sh +++ b/scripts/archival/general_updater.sh @@ -99,11 +99,18 @@ function update_archive_drive() } # compares one local well-known folder against the similar folder on a -# remote destination. +# remote destination. the first folder is the archive name, with no paths. +# the second paramter is the local path component of the archive, such as +# "/z" if the archives are found in the /z hierarchy. the third parameter +# is the remote location of the archive, which should just be a host name. +# the fourth parameter is the destination path component to match the local +# path component (since these can differ). function do_a_folder_compare() { local archname="$1"; shift + local pathing="$1"; shift local dest="$1"; shift + local destpath="$1"; shift if [ -z "$archname" -o -z "$dest" ]; then echo "do_a_folder_compare needs an archive name and a destination host." return 1 @@ -111,24 +118,31 @@ function do_a_folder_compare() if [ -d "/z/$archname" ]; then sep 14 - echo "Comparing $archname folder..." - compare_dirs /z/${archname} ${dest}:/z/${archname} + echo "Comparing ${pathing}/${archname} with remote $dest:${destpath}/${archname}" + compare_dirs ${pathing}/${archname} ${dest}:${destpath}/${archname} sep 14 fi } # runs through all the local archives on this host to make sure nothing is # different when compared with the mainline versions on the specified host. +# the first parameter is the remote version to compare against. if there is +# a second parameter, it is used as the path on the local machine where the +# comparison should be based (e.g. an archive drive rather than /z/). function uber_archive_comparator() { - local target="$1"; shift - if [ -z "$target" ]; then - echo uber_archive_comparator needs the target host to compare with. + local remote_arch="$1"; shift + if [ -z "$remote_arch" ]; then + echo uber_archive_comparator needs the remote archive host to compare with. return 1 fi + local local_place="$1"; shift + if [ -z "$local_place" ]; then + local_place="/z" + fi sep 14 - echo "comparing against host '$target'" + echo "comparing against host '$remote_arch'" sep 14 #hmmm: shouldn't this be a list in a variable someplace? @@ -139,7 +153,7 @@ function uber_archive_comparator() toaster \ walrus \ ; do - do_a_folder_compare $archicle $target + do_a_folder_compare ${archicle} ${local_place} ${remote_arch} "/z" done } diff --git a/scripts/files/compare_dirs.sh b/scripts/files/compare_dirs.sh index 6c700d8f..65c4f632 100644 --- a/scripts/files/compare_dirs.sh +++ b/scripts/files/compare_dirs.sh @@ -20,6 +20,8 @@ if [ "$dir1" == "$dir2" ]; then exit 1 fi +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" + out1="$(mktemp "$TMP/compare_dirs_output.XXXXXX")" out2="$(mktemp "$TMP/compare_dirs_output.XXXXXX")" @@ -44,11 +46,13 @@ fi if [ -z "$host1" ]; then # fully local compare location for first dir. pushd "$dir1" &>/dev/null + exit_on_error "compare_dirs: seeking directory $dir1" find . >"$out1" popd &>/dev/null else # remote compare location for first dir. ssh "$host1" "cd \"$dir1\" && find ." >"$out1" + exit_on_error "compare_dirs: listing remote directory $dir1" fi # sort the output from listing the first directory. @@ -57,11 +61,13 @@ sort "$out1" >"$out1".sort if [ -z "$host2" ]; then # fully local compare location for second dir. pushd "$dir2" &>/dev/null + exit_on_error "compare_dirs: seeking directory $dir2" find . >"$out2" popd &>/dev/null else # remote compare location for second dir. ssh "$host2" "cd \"$dir2\" && find ." >"$out2" + exit_on_error "compare_dirs: listing remote directory $dir2" fi # sort the output from listing the second directory.