From 81a3f3b9ce06d5e9f179da2dcfdac07ec1fe0ac4 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 12 Nov 2017 10:10:24 -0500 Subject: [PATCH] good abstraction of updater code --- scripts/archival/general_updater.sh | 69 ++++++++++++++++--- scripts/archival/shared_updater_parts.sh | 54 --------------- scripts/customize/fred/fred_variables.sh | 2 +- .../compare_soapbox.sh | 0 .../euphrosyne_comparator.sh | 0 .../{disk_synch => archival}/musical_wand.sh | 0 .../raw_surya_synch_.sh} | 0 .../scripts/archival/update_barkuptree.sh | 28 ++++++++ .../scripts/archival/update_catfurnose.sh | 8 +++ .../update_fredmusicprime.sh | 11 +-- .../update_soapbox.sh | 0 .../scripts/disk_synch/update_barkuptree.sh | 26 ------- 12 files changed, 105 insertions(+), 93 deletions(-) delete mode 100644 scripts/archival/shared_updater_parts.sh rename scripts/customize/fred/scripts/{disk_synch => archival}/compare_soapbox.sh (100%) rename scripts/customize/fred/scripts/{disk_synch => archival}/euphrosyne_comparator.sh (100%) rename scripts/customize/fred/scripts/{disk_synch => archival}/musical_wand.sh (100%) rename scripts/customize/fred/scripts/{disk_synch/raw_synch_from_surya.sh => archival/raw_surya_synch_.sh} (100%) create mode 100644 scripts/customize/fred/scripts/archival/update_barkuptree.sh create mode 100644 scripts/customize/fred/scripts/archival/update_catfurnose.sh rename scripts/customize/fred/scripts/{disk_synch => archival}/update_fredmusicprime.sh (77%) rename scripts/customize/fred/scripts/{disk_synch => archival}/update_soapbox.sh (100%) delete mode 100644 scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh diff --git a/scripts/archival/general_updater.sh b/scripts/archival/general_updater.sh index 2af8e568..3ae2d168 100644 --- a/scripts/archival/general_updater.sh +++ b/scripts/archival/general_updater.sh @@ -5,12 +5,65 @@ # if there is a target folder of the appropriate name already on the backup medium. source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" -source "$FEISTY_MEOW_SCRIPTS/archival/shared_updater_parts.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/rcheckin.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 +} + +# the uber controller method that does the "hard" work of updating. +# any items from the ARCHIVE_COLLECTION_LIST that are on the target will be +# updated. any items found on the target matching the members of the +# SOURCE_COLLECTION_LIST will be treated as code hierarchies and updated. function update_archive_drive() { - local target_folder="$1"; shift - # where we're backing up to. + local target_folder="$1"; shift # where we're backing up to. + local currdir # loop variable. sep @@ -31,14 +84,14 @@ function update_archive_drive() # update source code if present. echo getting latest fred repositories... pushd "$target_folder" - update_source_folders $SOURCE_HIERARCHY_LIST -#hmmm:clean -#extra_brain interbrane -#need source list + for currdir in $SOURCE_HIERARCHY_LIST; do + update_source_folders $currdir + done sep - echo Updated all expected portions of the targets successfully. + echo successfully updated all expected portions of the target drive at: + echo " $target_folder" } diff --git a/scripts/archival/shared_updater_parts.sh b/scripts/archival/shared_updater_parts.sh deleted file mode 100644 index 77c2c939..00000000 --- a/scripts/archival/shared_updater_parts.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/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/rcheckin.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 -} - diff --git a/scripts/customize/fred/fred_variables.sh b/scripts/customize/fred/fred_variables.sh index 58375868..aaf83291 100644 --- a/scripts/customize/fred/fred_variables.sh +++ b/scripts/customize/fred/fred_variables.sh @@ -18,7 +18,7 @@ if [ -z "$USER_CUSTOMIZATIONS_LOADED" ]; then REPOSITORY_LIST+=" cloud ebooks web " # adds our locally relevant archive folders into the list to be synched. - ARCHIVE_COLLECTION_LIST+="/z/basement /z/imaginations /z/musix /z/toaster /z/walrus" + ARCHIVE_COLLECTION_LIST+="/z/archons /z/basement /z/imaginations /z/musix /z/toaster /z/walrus" # our set of known source hierarchy folder names. SOURCE_HIERARCHY_LIST="codebarn extra_brain interbrane" diff --git a/scripts/customize/fred/scripts/disk_synch/compare_soapbox.sh b/scripts/customize/fred/scripts/archival/compare_soapbox.sh similarity index 100% rename from scripts/customize/fred/scripts/disk_synch/compare_soapbox.sh rename to scripts/customize/fred/scripts/archival/compare_soapbox.sh diff --git a/scripts/customize/fred/scripts/disk_synch/euphrosyne_comparator.sh b/scripts/customize/fred/scripts/archival/euphrosyne_comparator.sh similarity index 100% rename from scripts/customize/fred/scripts/disk_synch/euphrosyne_comparator.sh rename to scripts/customize/fred/scripts/archival/euphrosyne_comparator.sh diff --git a/scripts/customize/fred/scripts/disk_synch/musical_wand.sh b/scripts/customize/fred/scripts/archival/musical_wand.sh similarity index 100% rename from scripts/customize/fred/scripts/disk_synch/musical_wand.sh rename to scripts/customize/fred/scripts/archival/musical_wand.sh diff --git a/scripts/customize/fred/scripts/disk_synch/raw_synch_from_surya.sh b/scripts/customize/fred/scripts/archival/raw_surya_synch_.sh similarity index 100% rename from scripts/customize/fred/scripts/disk_synch/raw_synch_from_surya.sh rename to scripts/customize/fred/scripts/archival/raw_surya_synch_.sh diff --git a/scripts/customize/fred/scripts/archival/update_barkuptree.sh b/scripts/customize/fred/scripts/archival/update_barkuptree.sh new file mode 100644 index 00000000..9b0103f8 --- /dev/null +++ b/scripts/customize/fred/scripts/archival/update_barkuptree.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# updates the mounted barkuptree drive with stuff on wildmutt. +# very specific currently. + +source "$FEISTY_MEOW_SCRIPTS/core/general_updater.sh" + +update_archive_drive /media/fred/barkuptreedrive + +#gone below + +# copy up the archived bluray discs, and possibly future archived formats. +#netcp /z/archons/* $BARKY/bkup_archons/ +#test_or_die "synching archons" + +# copy over our somewhat attenuated but still important walrus archives. +#netcp /z/walrus/* $BARKY/walrus/ +#test_or_die "synching walrus" + +# copy all the music files for future reference. +#netcp /z/musix/* $BARKY/musix/ +#test_or_die "synching musix" + +# back up the photo archives. +#netcp /z/imaginations/* $BARKY/imaginations/ +#test_or_die "synching imaginations" + + diff --git a/scripts/customize/fred/scripts/archival/update_catfurnose.sh b/scripts/customize/fred/scripts/archival/update_catfurnose.sh new file mode 100644 index 00000000..b9622bed --- /dev/null +++ b/scripts/customize/fred/scripts/archival/update_catfurnose.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# updates local archive drive called catfurnose + +source "$FEISTY_MEOW_SCRIPTS/archival/general_updater.sh" + +update_archive_drive "/media/fred/catfurnose" + diff --git a/scripts/customize/fred/scripts/disk_synch/update_fredmusicprime.sh b/scripts/customize/fred/scripts/archival/update_fredmusicprime.sh similarity index 77% rename from scripts/customize/fred/scripts/disk_synch/update_fredmusicprime.sh rename to scripts/customize/fred/scripts/archival/update_fredmusicprime.sh index 9cd75dec..97f455c2 100644 --- a/scripts/customize/fred/scripts/disk_synch/update_fredmusicprime.sh +++ b/scripts/customize/fred/scripts/archival/update_fredmusicprime.sh @@ -2,11 +2,14 @@ # 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" +source "$FEISTY_MEOW_SCRIPTS/archival/general_updater.sh" -# where we're backing up to. -TARGET_FOLDER="/media/fred/fredmusicprime" +update_archive_drive "/media/fred/fredmusicprime" + +exit $? + +#####old#####old##### +#gone below. sep diff --git a/scripts/customize/fred/scripts/disk_synch/update_soapbox.sh b/scripts/customize/fred/scripts/archival/update_soapbox.sh similarity index 100% rename from scripts/customize/fred/scripts/disk_synch/update_soapbox.sh rename to scripts/customize/fred/scripts/archival/update_soapbox.sh diff --git a/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh b/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh deleted file mode 100644 index fcefd5de..00000000 --- a/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# updates the mounted barkuptree drive with stuff on wildmutt. -# very specific currently. - -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" - -export BARKY=/media/fred/barkuptreedrive - -# copy up the archived bluray discs, and possibly future archived formats. -netcp /z/archons/* $BARKY/bkup_archons/ -test_or_die "synching archons" - -# copy over our somewhat attenuated but still important walrus archives. -netcp /z/walrus/* $BARKY/walrus/ -test_or_die "synching walrus" - -# copy all the music files for future reference. -netcp /z/musix/* $BARKY/musix/ -test_or_die "synching musix" - -# back up the photo archives. -netcp /z/imaginations/* $BARKY/imaginations/ -test_or_die "synching imaginations" - - -- 2.34.1