made a general comparator for my archives
[feisty_meow.git] / scripts / archival / general_updater.sh
index 83c9777514cbedb9346e834146ef7ee64548df4d..7dac5777b1291eacc5b77109fd57a1d2619ce2a0 100644 (file)
@@ -11,6 +11,7 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 function update_source_folders()
 {
   folder="$1"; shift
+  sep
   if [ ! -d "$folder" ]; then
     echo "The folder '$folder' does not exist, so skipping repository update there."
     return;
@@ -19,14 +20,15 @@ function update_source_folders()
   pushd "$folder"
   if [ $? -ne 0 ]; then
     echo Changing to the folder $folder failed.
-    exit 1
+    return 1
   fi
   bash "$FEISTY_MEOW_SCRIPTS/rev_control/rcheckin.sh"
   if [ $? -ne 0 ]; then
     echo Checking out the latest codes has failed somehow for $folder.
-    exit 1
+    return 1
   fi
   popd
+  sep
 }
 
 # this attempts to copy all the contents in a folder called "from" into a folder
@@ -40,19 +42,19 @@ function synch_directory_to_target()
   sep
 
   if [ ! -d "$from" ]; then
-    echo "skipping synch on missing source directory $from; this is not normal!"
-    exit 1
+    echo "skipping synch on missing source directory: ${from}"
+    return 0
   fi
   if [ ! -d "$to" ]; then
-    echo "skipping synch into non-existent directory $to"
-    return
+    echo "skipping synch into non-existent target directory $to"
+    return 0
   fi
 
   echo "synching from $from into $to"
   netcp "$from"/* "$to"/
   if [ $? -ne 0 ]; then
     echo "The synchronization of $from into $to has failed."
-    exit 1
+    return 1
   fi
 }
 
@@ -71,7 +73,7 @@ function update_archive_drive()
   ls "$target_folder"
   if [ $? -ne 0 ]; then
     echo "The target location '$target_folder' is not mounted currently, so cannot be updated."
-    exit 1
+    return 1
   fi
 
   # synch all our targets.
@@ -92,6 +94,63 @@ function update_archive_drive()
 
   echo successfully updated all expected portions of the target drive at:
   echo "  $target_folder"
+  echo
+  popd
+}
+
+# compares one local well-known folder against the similar folder on a
+# remote destination.
+function do_a_folder_compare()
+{
+  local archname="$1"; shift
+  local dest="$1"; shift
+  if [ -z "$archname" -o -z "$dest" ]; then
+    echo "do_a_folder_compare needs an archive name and a destination host."
+    return 1
+  fi
+
+  if [ -d "/z/$archname" ]; then
+    sep 14
+    echo "Comparing $archname folder..."
+    compare_dirs /z/${archname} ${dest}:/z/${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.
+function uber_archive_comparator()
+{
+  local target="$1"; shift
+  if [ -z "$target" ]; then
+    echo uber_archive_comparator needs the target host to compare with.
+    return 1
+  fi
+
+  sep 14
+  echo "comparing against host '$target'"
+  sep 14
+
+#hmmm: shouldn't this be a list in a variable someplace?
+  for archicle in \
+    basement \
+    imaginations \
+    musix \
+    toaster \
+    walrus \
+    ; do
+      do_a_folder_compare $archicle $target
+  done
 }
 
 
+#hmmm: abstractable piece?  the runtime plug at the end of a library script?
+# this block should execute when the script is actually run, rather
+# than when it's just being sourced.
+if [[ $0 =~ .*general_updater\.sh.* ]]; then
+  source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+  exit_on_error "sourcing the feisty meow environment"
+  update_archive_drive "${@}"
+  exit_on_error "updating archive drive at: $*"
+fi
+