From 4d0c77932184931d856d904ebf79a24710206b02 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 15 Oct 2017 18:44:07 -0400 Subject: [PATCH] cleaning in updaters 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 | 54 ++++++++++++++ scripts/core/variables.sh | 5 ++ scripts/customize/fred/fred_variables.sh | 3 + .../customize/fred/scripts/musical_wand.sh | 3 +- .../fred/scripts/update_fredmusicprime.sh | 35 ++++++++++ .../customize/fred/scripts/update_soapbox.sh | 70 +++++++++++-------- 6 files changed, 139 insertions(+), 31 deletions(-) create mode 100644 scripts/archival/shared_updater_parts.sh create mode 100644 scripts/customize/fred/scripts/update_fredmusicprime.sh diff --git a/scripts/archival/shared_updater_parts.sh b/scripts/archival/shared_updater_parts.sh new file mode 100644 index 00000000..13518e95 --- /dev/null +++ b/scripts/archival/shared_updater_parts.sh @@ -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 +} + diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index 97f710b8..962535f1 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -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() { diff --git a/scripts/customize/fred/fred_variables.sh b/scripts/customize/fred/fred_variables.sh index 4f380859..a71d61ae 100644 --- a/scripts/customize/fred/fred_variables.sh +++ b/scripts/customize/fred/fred_variables.sh @@ -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" diff --git a/scripts/customize/fred/scripts/musical_wand.sh b/scripts/customize/fred/scripts/musical_wand.sh index 37dccc87..c3af4be3 100644 --- a/scripts/customize/fred/scripts/musical_wand.sh +++ b/scripts/customize/fred/scripts/musical_wand.sh @@ -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 index 00000000..44597545 --- /dev/null +++ b/scripts/customize/fred/scripts/update_fredmusicprime.sh @@ -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. + diff --git a/scripts/customize/fred/scripts/update_soapbox.sh b/scripts/customize/fred/scripts/update_soapbox.sh index 869a1deb..3ca715eb 100644 --- a/scripts/customize/fred/scripts/update_soapbox.sh +++ b/scripts/customize/fred/scripts/update_soapbox.sh @@ -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. -- 2.34.1