cleaning in updaters
authorChris Koeritz <fred@gruntose.com>
Sun, 15 Oct 2017 22:44:07 +0000 (18:44 -0400)
committerChris Koeritz <fred@gruntose.com>
Sun, 15 Oct 2017 22:44:07 +0000 (18:44 -0400)
extracted some common code into shared updater parts.  added an archive collection list variable for representing the full list of critical repositories that should be synched (maybe blank for most users).  repointed musical wand at curie instead of banshee, and also starting to think this script no longer needed due to raw_synch_from_surya usage on euphrosyne.

scripts/archival/shared_updater_parts.sh [new file with mode: 0644]
scripts/core/variables.sh
scripts/customize/fred/fred_variables.sh
scripts/customize/fred/scripts/musical_wand.sh
scripts/customize/fred/scripts/update_fredmusicprime.sh [new file with mode: 0644]
scripts/customize/fred/scripts/update_soapbox.sh

diff --git a/scripts/archival/shared_updater_parts.sh b/scripts/archival/shared_updater_parts.sh
new file mode 100644 (file)
index 0000000..13518e9
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+
+# given a location in the filesystem, we will go to that location and attempt to
+# update any revision control repositories stored there to the latest versions.
+function update_source_folders()
+{
+  folder="$1"; shift
+  if [ ! -d "$folder" ]; then
+    echo "The folder '$folder' does not exist, so skipping repository update there."
+    return;
+  fi
+  echo getting latest codes in $folder...
+  pushd "$folder"
+  if [ $? -ne 0 ]; then
+    echo Changing to the folder $folder failed.
+    exit 1
+  fi
+  bash "$FEISTY_MEOW_SCRIPTS/rev_control/rev_checkin.sh"
+  if [ $? -ne 0 ]; then
+    echo Checking out the latest codes has failed somehow for $folder.
+    exit 1
+  fi
+  popd
+}
+
+# this attempts to copy all the contents in a folder called "from" into a folder
+# called "to".  it's a failure for the "from" folder to not exist, but the "to"
+# is allowed to not exist (in which case we don't try to synch to it).
+function synch_directory_to_target()
+{
+  local from="$1"; shift
+  local to="$1"; shift
+
+  sep
+
+  if [ ! -d "$from" ]; then
+    echo "skipping synch on missing source directory $from; this is not normal!"
+    exit 1
+  fi
+  if [ ! -d "$to" ]; then
+    echo "skipping synch into non-existent directory $to"
+    return
+  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
+  fi
+}
+
index 97f710b8c3af8dfb3ee2c8548dc2ef83469eb9cf..962535f11626c4fc9f75fab0f92b98cbb282a56a 100644 (file)
@@ -207,8 +207,13 @@ if [ -z "$CORE_VARIABLES_LOADED" ]; then
   # names can be added in your customized scripts.  the space at the end of
   # this variable is important and allows users to extend the list like:
   #    define_yeti_variable REPOSITORY_DIR+="muppets configs"
+  # see the customize/fred folder for a live example.
   define_yeti_variable REPOSITORY_LIST=
   
+  # the archive collections list is a set of directories that are major
+  # repositories of data which can be synched to backup drives.
+  define_yeti_variable ARCHIVE_COLLECTIONS_LIST=
+
   # initializes the feisty meow build variables, if possible.
   function initialize_build_variables()
   {
index 4f38085967d65bdb37d4247678b109ca49992494..a71d61ae35b011fc1287e95932df2057322d89a8 100644 (file)
@@ -17,6 +17,9 @@ if [ -z "$USER_CUSTOMIZATIONS_LOADED" ]; then
   # add a bunch of personal folders to the list for checkin & checkout.
   REPOSITORY_LIST+="$(basename $FEISTY_MEOW_APEX) cloud ebooks web active/webwork"
 
+  # adds our locally relevant archive folders into the list to be synched.
+  ARCHIVE_COLLECTIONS_LIST+="/z/basement /z/imaginations /z/musix /z/toaster /z/walrus"
+
   # point to our local certificate for ssh usage.
   export SVN_SSH="ssh -i $HOME/.ssh/id_dsa_sourceforge"
 
index 37dccc87818a7a162b3c75dccb11df553755784d..c3af4be3756ba9a6db77c421bd4e5be3c4f8f20a 100644 (file)
@@ -14,7 +14,7 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 #hmmm: add the goodness around these actions like the "nice" updater so we catch all errors.
 
 # this host is where all the music is supposed to come from.
-MUSICAL_HOST=banshee
+MUSICAL_HOST=curie
 
 #hmmm: this script is currently limited to run ON the music host.  it could easily do the backwards thing instead, and copy FROM music host.
 
@@ -23,7 +23,6 @@ MUSICAL_HOST=banshee
 MUSIX_ARCHIVE_SITE_LIST=(euphrosyne)
 #hmmm: list was contracted a lot, since we don't want to step on the updates done by syncthing.  euphrosyne is still our reference copy for what the archive states "should" be.
 
-
 if [[ ! ( $(hostname) =~ .*${MUSICAL_HOST}.* ) ]]; then
   echo "This script is only designed to run on $MUSICAL_HOST with the"
   echo "primary fred music source (external) disc plugged in."
diff --git a/scripts/customize/fred/scripts/update_fredmusicprime.sh b/scripts/customize/fred/scripts/update_fredmusicprime.sh
new file mode 100644 (file)
index 0000000..4459754
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# updates my little 1 TB "soapbox" style usb drive with items that it should contain.
+
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+source "$FEISTY_MEOW_SCRIPTS/archival/shared_updater_parts.sh"
+
+# where we're backing up to.
+TARGET_FOLDER="/media/fred/fredmusicprime"
+
+sep
+
+echo Target drive currently has...
+ls "$TARGET_FOLDER"
+if [ $? -ne 0 ]; then
+  echo "The target location '$TARGET_FOLDER' is not mounted currently, so cannot be updated."
+  exit 1
+fi
+
+# synch all our targets.
+for currdir in $ARCHIVE_COLLECTIONS_LIST; do
+  synch_directory_to_target "$currdir" "$TARGET_FOLDER/$(basename $currdir)"/
+done
+
+sep
+
+# update source code if present.
+echo getting latest fred repositories...
+pushd "$TARGET_FOLDER"
+update_source_folders extra_brain
+
+sep
+
+echo Updated all expected portions of the targets successfully.
+
index 869a1deb0882bb778a59871923b92cb5367984da..3ca715eb50d3c7f3d7e5f8118f1f7b18898b5221 100644 (file)
@@ -3,49 +3,61 @@
 # updates my little 1 TB "soapbox" style usb drive with items that it should contain.
 
 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+source "$FEISTY_MEOW_SCRIPTS/archival/shared_updater_parts.sh"
 
-function get_source()
-{
-  folder="$1"; shift
-  echo getting latest codes in $folder...
-  pushd "$folder"
-  if [ $? -ne 0 ]; then
-    echo Changing to the folder $folder failed.
-    exit 1
-  fi
-  bash "$FEISTY_MEOW_SCRIPTS/rev_control/rev_checkin.sh"
-  if [ $? -ne 0 ]; then
-    echo Checking out the latest codes has failed somehow for $folder.
-    exit 1
-  fi
-  popd
-}
+# where we're backing up to.
+TARGET_FOLDER="/media/fred/soapboxdrive"
 
 sep
 
-ls /media/fred/soapboxdrive
+echo Target drive currently has...
+ls "$TARGET_FOLDER"
 if [ $? -ne 0 ]; then
-  echo The soapbox drive is not mounted currently, so cannot be updated.
+  echo "The target location '$TARGET_FOLDER' is not mounted currently, so cannot be updated."
   exit 1
 fi
 
-for currdir in basement imaginations musix walrus; do
-  sep
-  echo "synching $currdir..."
-  netcp /z/$currdir/* /media/fred/soapboxdrive/$currdir/
-  if [ $? -ne 0 ]; then
-    echo "The $currdir sync failed."
-    exit 1
-  fi
+#function synch_directory_to_target()
+#{
+#  local from="$1"; shift
+#  local to="$1"; shift
+#
+#  sep
+#
+#  if [ ! -d "$from" ]; then
+#    echo "skipping synch one missing source directory $from; this is not normal!"
+#  fi
+#  if [ ! -d "$to" ]; then
+#    echo "skipping synch into non-existent directory $to"
+#  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
+#  fi
+#}
+
+# do all our targets.
+for currdir in $ARCHIVE_COLLECTIONS_LIST; do
+  synch_directory_to_target "$currdir" "$TARGET_FOLDER/$(basename $currdir)"/
+#  sep
+#  echo "synching $currdir..."
+#  netcp $currdir/* /media/fred/soapboxdrive/$currdir/
+#  if [ $? -ne 0 ]; then
+#    echo "The $currdir sync failed."
+#    exit 1
+#  fi
 done
 
 sep
 
 echo getting latest fred repositories...
-pushd /media/fred/soapboxdrive
-get_source extra_brain
+pushd "$TARGET_FOLDER"
+update_source_folders extra_brain
 
 sep
 
-echo Updated all portions of the soapbox drive successfully.
+echo Updated all expected portions of the targets successfully.