From 170a8e062d9283e65716e7aa55930ade13a66f7a Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Thu, 9 Nov 2017 11:14:26 -0500 Subject: [PATCH] added careful error checking to rev control these had some checks on actions, but not on all. i want anything that fails during an update or a push to cause the whole machinery to stop right there, because we cannot afford to be missing merge screw-ups. --- scripts/archival/serene_backer_upper.sh | 36 ++---------------- scripts/buildor/refresh_gffs_build.sh | 4 +- scripts/core/functions.sh | 8 ++-- .../scripts/disk_synch/update_barkuptree.sh | 8 ++-- .../fred/scripts/email/filter_grabber.sh | 4 +- .../customize/fred/scripts/games/gamesaver.sh | 2 +- scripts/rev_control/checkin.sh | 9 ++--- scripts/rev_control/compact_git.sh | 10 +++-- scripts/rev_control/diff_repo.sh | 11 ++++-- scripts/rev_control/getem.sh | 14 +++---- scripts/rev_control/push_repo_downstream.sh | 5 +-- scripts/rev_control/rcheckin.sh | 9 ++++- scripts/rev_control/report_new.sh | 10 +++-- scripts/rev_control/resolve_svn.sh | 1 + scripts/rev_control/rgetem.sh | 10 +++-- scripts/rev_control/version_control.sh | 32 ++++++++++------ scripts/site_avenger/avcoreup.sh | 4 +- scripts/site_avenger/powerup.sh | 4 +- scripts/site_avenger/shared_site_mgr.sh | 38 +++++++++---------- scripts/site_avenger/sitepush.sh | 2 +- scripts/site_avenger/siteup.sh | 2 +- scripts/system/add_apache_site.sh | 6 +-- scripts/system/add_swap_mount.sh | 8 ++-- scripts/system/naive_system_updater.sh | 4 +- 24 files changed, 119 insertions(+), 122 deletions(-) diff --git a/scripts/archival/serene_backer_upper.sh b/scripts/archival/serene_backer_upper.sh index b6dec6d9..8a852601 100644 --- a/scripts/archival/serene_backer_upper.sh +++ b/scripts/archival/serene_backer_upper.sh @@ -4,26 +4,6 @@ # # Author: Chris Koeritz -# tests whether the last action worked or not, and if not, it issues the -# complaint passed as the arguments. -function check_if_failed() -{ - if [ $? -ne 0 ]; then - echo "Step FAILed: $*" - return 1 - fi -} - -# uses the failure checking function, but actually exits out of the script -# if there was a failure detected. -function exit_if_failed() -{ - check_if_failed $* - if [ $? -ne 0 ]; then - exit 1 - fi -} - # given a source and target folder, this synchronizes the source into the target. function synch_to_backup() { @@ -34,16 +14,8 @@ function synch_to_backup() exit 1 fi echo "Synchronizing $source into $dest." -####hmmm: temporary measure until top-level dir bug fixed in synch_files app. -### if [ ! -d "$dest" ]; then -### mkdir -p "$dest" -### if [ $? -ne 0 ]; then -### echo "FAILed to make target directory: $dest" -### return 1 -### fi -### fi synch_files "$source" "$dest" - check_if_failed "synching $source to $dest" + test_or_continue "synching $source to $dest" } ############## @@ -55,12 +27,12 @@ function synch_to_backup() # now saddle up the backup. #NO LONGER USING MOUNT: mount /z/backup/ -#NO LONGER USING MOUNT: exit_if_failed "mounting backup folder" +#NO LONGER USING MOUNT: test_or_die "mounting backup folder" # we should always be synching to an existing set in there. make sure they exist. # for the first ever backup, this is not a good check... #test -d /z/backup/etc -a -d /z/backup/home -#exit_if_failed "testing presence of prior backup" +#test_or_die "testing presence of prior backup" ############## @@ -80,6 +52,6 @@ synch_to_backup /var/lib/mysql /z/backup/var/lib/mysql ############## #NO LONGER USING MOUNT: umount /z/backup/ -#NO LONGER USING MOUNT: exit_if_failed "unmounting backup folder" +#NO LONGER USING MOUNT: test_or_die "unmounting backup folder" diff --git a/scripts/buildor/refresh_gffs_build.sh b/scripts/buildor/refresh_gffs_build.sh index 3476b1ba..dc255929 100644 --- a/scripts/buildor/refresh_gffs_build.sh +++ b/scripts/buildor/refresh_gffs_build.sh @@ -14,12 +14,12 @@ echo cleaning out the logs directory... echo making a simple starting log file for container... if [ ! -d "$GFFS_LOGS" ]; then mkdir -p "$GFFS_LOGS" - test_or_fail Making GFFS logs directory. + test_or_die Making GFFS logs directory. fi echo building the code freshly, although not with a clean first... build_gffs -test_or_fail Building GFFS source code. +test_or_die Building GFFS source code. echo starting container now and spooling its log file... (bash $GFFS_TOOLKIT_ROOT/library/maybe_restart_container.sh &>$TMP/main_container_restarting.log & ) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 5771586f..45980cee 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -121,7 +121,7 @@ if [ -z "$skip_all" ]; then # checks the result of the last command that was run, and if that failed, # then this complains and exits from bash. the function parameters are # used as the message to print as a complaint. - function test_or_fail() + function test_or_die() { if [ $? -ne 0 ]; then echo -e "\n\naction failed: $*\n\nExiting script..." @@ -130,7 +130,7 @@ if [ -z "$skip_all" ]; then fi } - # like test_or_fail, but will keep going after complaining. + # like test_or_die, but will keep going after complaining. function test_or_continue() { if [ $? -ne 0 ]; then @@ -737,7 +737,7 @@ return 0 if [ -d "$src" ]; then ln -s "$src" "$target" - test_or_fail "Creating symlink from '$src' to '$target'" + test_or_die "Creating symlink from '$src' to '$target'" fi echo "Created symlink from '$src' to '$target'." } @@ -789,7 +789,7 @@ return 0 echo running tests on set_var_if_undefined. flagrant=petunia set_var_if_undefined flagrant forknordle - test_or_fail "testing if defined variable would be whacked" + test_or_die "testing if defined variable would be whacked" if [ $flagrant != petunia ]; then echo set_var_if_undefined failed to leave the test variable alone exit 1 diff --git a/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh b/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh index bb549231..fcefd5de 100644 --- a/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh +++ b/scripts/customize/fred/scripts/disk_synch/update_barkuptree.sh @@ -9,18 +9,18 @@ export BARKY=/media/fred/barkuptreedrive # copy up the archived bluray discs, and possibly future archived formats. netcp /z/archons/* $BARKY/bkup_archons/ -test_or_fail "synching archons" +test_or_die "synching archons" # copy over our somewhat attenuated but still important walrus archives. netcp /z/walrus/* $BARKY/walrus/ -test_or_fail "synching walrus" +test_or_die "synching walrus" # copy all the music files for future reference. netcp /z/musix/* $BARKY/musix/ -test_or_fail "synching musix" +test_or_die "synching musix" # back up the photo archives. netcp /z/imaginations/* $BARKY/imaginations/ -test_or_fail "synching imaginations" +test_or_die "synching imaginations" diff --git a/scripts/customize/fred/scripts/email/filter_grabber.sh b/scripts/customize/fred/scripts/email/filter_grabber.sh index 5261c8c5..1889b2fe 100644 --- a/scripts/customize/fred/scripts/email/filter_grabber.sh +++ b/scripts/customize/fred/scripts/email/filter_grabber.sh @@ -5,9 +5,9 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" cp $HOME/.thunderbird/oqv30zg4.default/ImapMail/zooty.koeritz.com/msgFilterRules.dat $CLOUD_BASE/magic_cabinet/mail_filters/zooty_serene_hamstertronic_$(date_stringer).filters -test_or_fail "copying feistymeow.org filters" +test_or_die "copying feistymeow.org filters" cp $HOME/.thunderbird/oqv30zg4.default/ImapMail/mail.eservices.virginia.edu/msgFilterRules.dat $CLOUD_BASE/magic_cabinet/mail_filters/uva_email_$(date_stringer).filters -test_or_fail "copying UVa filters" +test_or_die "copying UVa filters" diff --git a/scripts/customize/fred/scripts/games/gamesaver.sh b/scripts/customize/fred/scripts/games/gamesaver.sh index 767ded0b..80cdfd98 100644 --- a/scripts/customize/fred/scripts/games/gamesaver.sh +++ b/scripts/customize/fred/scripts/games/gamesaver.sh @@ -20,7 +20,7 @@ fi if [ ! -d "$SPOOLING_OUTPUT_DIR" ]; then mkdir -p "$SPOOLING_OUTPUT_DIR" - test_or_fail Creating spooling output directory. + test_or_die Creating spooling output directory. fi # copies the files for a particular game out to a spooling folder. diff --git a/scripts/rev_control/checkin.sh b/scripts/rev_control/checkin.sh index 70564a16..5b126d9a 100644 --- a/scripts/rev_control/checkin.sh +++ b/scripts/rev_control/checkin.sh @@ -10,16 +10,13 @@ source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" echo "committing repositories at: $(date)" echo -FULL_LIST="$(dirname $FEISTY_MEOW_APEX) $HOME" -#if [ "$OS" != "Windows_NT" ]; then -# # first get individual folders. -# checkin_list $(dirname $FEISTY_MEOW_APEX) $HOME -#else (end old) +FULL_LIST=" $(dirname $FEISTY_MEOW_APEX) $HOME " if [ "$OS" == "Windows_NT" ]; then - FULL_LIST+=" c:/ d:/ e:/" + FULL_LIST+=" c:/ d:/ e:/ " fi checkin_list $FULL_LIST +test_or_die "checking in list: $FULL_LIST" ############## diff --git a/scripts/rev_control/compact_git.sh b/scripts/rev_control/compact_git.sh index 88efcdaa..8de72543 100644 --- a/scripts/rev_control/compact_git.sh +++ b/scripts/rev_control/compact_git.sh @@ -1,15 +1,17 @@ #!/bin/bash +# compresses the git archive in the folder specified. + prune_dir="$1" if [ -z "$prune_dir" ]; then prune_dir="$(pwd)" fi pushd "$prune_dir" -echo cleaning git in directory $(pwd) +echo "cleaning git repo in directory $(pwd)" git fsck --full -check_if_failed "git fsck" +test_or_die "git fsck" git gc --prune=today --aggressive -check_if_failed "git gc" +test_or_die "git gc" git repack -check_if_failed "git repack" +test_or_die "git repack" popd diff --git a/scripts/rev_control/diff_repo.sh b/scripts/rev_control/diff_repo.sh index d74905c3..eb02719e 100644 --- a/scripts/rev_control/diff_repo.sh +++ b/scripts/rev_control/diff_repo.sh @@ -1,20 +1,25 @@ #!/bin/bash + # does differences on a set of folders checked out from subversion or git. # this can take a directory as parameter, but will default to the current # working directory. all the directories under the passed directory will # be examined. +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +############## + dir="$1"; shift if [ -z "$dir" ]; then dir=. fi -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" - pushd "$dir" &>/dev/null +test_or_die "changing to directory: $dir" tempfile=$(generate_rev_ctrl_filelist) popd &>/dev/null perform_revctrl_action_on_file "$tempfile" do_diff +test_or_die "performing revision control action do_diff on: $tempfile" diff --git a/scripts/rev_control/getem.sh b/scripts/rev_control/getem.sh index 86c9531b..3818b588 100644 --- a/scripts/rev_control/getem.sh +++ b/scripts/rev_control/getem.sh @@ -5,6 +5,8 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" +############## + # trickery to ensure we can always update this file, even when the operating system has some # rude behavior with regard to file locking (ahem, windows...). # and even more rudeness is that the pwd and $TMP may not always be in the same form, @@ -17,13 +19,12 @@ if [ "$(\pwd)" != "$tmpdir" ]; then fi new_name="$TMP/zz_$(basename $0)" \cp -f "$0" "$new_name" - if [ $? -ne 0 ]; then - echo "failed to copy this script up to the TMP directory. exploit attempted?" - exit 1 - fi + test_or_die "failed to copy this script up to the TMP directory. exploit attempted?" cd "$TMP" chmod a+x "$new_name" + test_or_die "chmodding of file: $new_name" exec "$new_name" + test_or_die "execing cloned getemscript" fi ############## @@ -31,19 +32,18 @@ fi export TMPO_CHK=$TMP/zz_chk.log rm -f "$TMPO_CHK" +test_or_die "removing file: $TMPO_CHK" echo "getting repositories at: $(date)" echo # perform the checkouts as appropriate per OS. FULL_LIST="$(dirname $FEISTY_MEOW_APEX) $HOME" -#if [ "$OS" != "Windows_NT" ]; then -# checkout_list $HOME /usr/local 2>&1 | tee -a "$TMPO_CHK" -#else if [ "$OS" == "Windows_NT" ]; then FULL_LIST+="c:/ d:/ e:/" fi checkout_list $FULL_LIST 2>&1 | tee -a "$TMPO_CHK" +test_or_die "checking out list: $FULL_LIST" ############## diff --git a/scripts/rev_control/push_repo_downstream.sh b/scripts/rev_control/push_repo_downstream.sh index 0d0dcaa7..2f4e3db1 100644 --- a/scripts/rev_control/push_repo_downstream.sh +++ b/scripts/rev_control/push_repo_downstream.sh @@ -41,15 +41,14 @@ pushd "$dir" # get everything from the origin. git fetch origin - -# get everything from the origin. -#needed? git pull +test_or_die "running git fetch origin" # turn off occasionally troublesome setting before checkin. unset GIT_SSH # send the little boat down the stream to the dependent repository. git push downstream master +test_or_die "running the git push downstream" popd diff --git a/scripts/rev_control/rcheckin.sh b/scripts/rev_control/rcheckin.sh index cfb72c29..1c50d517 100644 --- a/scripts/rev_control/rcheckin.sh +++ b/scripts/rev_control/rcheckin.sh @@ -4,17 +4,22 @@ # current working directory. all the directories under the passed directory # will be examined. +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +############## + dir="$1"; shift if [ -z "$dir" ]; then dir=. fi -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" pushd "$dir" &>/dev/null +test_or_die "changing to directory: $dir" tempfile=$(generate_rev_ctrl_filelist) popd &>/dev/null perform_revctrl_action_on_file "$tempfile" do_checkin +test_or_die "doing a check-in on: $tempfile" diff --git a/scripts/rev_control/report_new.sh b/scripts/rev_control/report_new.sh index 224b1dfb..4da1a4a0 100644 --- a/scripts/rev_control/report_new.sh +++ b/scripts/rev_control/report_new.sh @@ -5,17 +5,21 @@ # a directory as a parameter, but will default to the current directory. # all the directories under the passed directory will be examined. +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +############## + dir="$1"; shift if [ -z "$dir" ]; then dir=. fi -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" - pushd "$dir" &>/dev/null +test_or_die "changing directory to: $dir" tempfile=$(generate_rev_ctrl_filelist) popd &>/dev/null perform_revctrl_action_on_file "$tempfile" do_report_new +test_or_die "running revision control report" diff --git a/scripts/rev_control/resolve_svn.sh b/scripts/rev_control/resolve_svn.sh index 941e5729..3484a859 100644 --- a/scripts/rev_control/resolve_svn.sh +++ b/scripts/rev_control/resolve_svn.sh @@ -6,5 +6,6 @@ filename="$1"; shift svn resolve --accept=working "$filename" +test_or_die "resolving tree conflict by accepting the working directory as the right one" diff --git a/scripts/rev_control/rgetem.sh b/scripts/rev_control/rgetem.sh index 6e096279..37538b6b 100644 --- a/scripts/rev_control/rgetem.sh +++ b/scripts/rev_control/rgetem.sh @@ -4,17 +4,21 @@ # working directory. all the directories under the passed directory will # be examined. +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" +source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" + +############## + dir="$1"; shift if [ -z "$dir" ]; then dir=. fi -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" -source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh" - pushd "$dir" &>/dev/null +test_or_die "changing to directory: $dir" tempfile=$(generate_rev_ctrl_filelist) popd &>/dev/null perform_revctrl_action_on_file "$tempfile" do_update +test_or_die "running revision control update" diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 2de20b0b..c3e21b21 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -6,6 +6,8 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh" +############## + # the maximum depth that the recursive functions will try to go below the starting directory. export MAX_DEPTH=5 @@ -45,13 +47,13 @@ function get_our_hostname() # this function sets a variable called "home_system" to "true" if the # machine is considered one of fred's home machines. if you are not # fred, you may want to change the machine choices. -export home_system= function is_home_system() { # load up the name of the host. get_our_hostname # reset the variable that we'll be setting. - home_system= + unset home_system + export home_system if [[ $this_host == *.gruntose.blurgh ]]; then home_system=true fi @@ -98,10 +100,9 @@ function compute_modifier() is_home_system # special override to pick local servers when at home. if [ "$home_system" == "true" ]; then -#what was this section for again? +#hmmm: this "home system" feature seems to be unnecessary? if [ "$in_or_out" == "out" ]; then # need the right home machine for modifier when checking out. -#huhhh? modifier="svn://shaggy/" modifier= else # no modifier for checkin. @@ -110,6 +111,8 @@ function compute_modifier() fi } +############## + # selects the method for check-in based on where we are. function do_checkin() { @@ -124,13 +127,13 @@ function do_checkin() fi local blatt="echo checking in '$nicedir'..." + local retval=0 # normally successful. + do_update "$directory" - if [ $? -ne 0 ]; then - echo "repository update failed; this should be fixed before check-in." - return 1 - fi + retval=$? + test_or_die "repository update failed; this should be fixed before check-in." + pushd "$directory" &>/dev/null - local retval=0 # normally successful. if [ -f ".no-checkin" ]; then echo "skipping check-in due to presence of .no-checkin sentinel file." elif [ -d "CVS" ]; then @@ -181,10 +184,13 @@ function do_diff # only update if we see a repository living there. if [ -d ".svn" ]; then svn diff . + retval+=$? elif [ -d ".git" ]; then git diff + retval+=$? elif [ -d "CVS" ]; then cvs diff . + retval+=$? fi popd &>/dev/null @@ -241,6 +247,7 @@ function checkin_list() # yep, this path is absolute. just handle it directly. if [ ! -d "$outer" ]; then continue; fi do_checkin $outer + test_or_die "running check-in on: $outer" sep 28 else for inner in $list; do @@ -248,6 +255,7 @@ function checkin_list() local path="$inner/$outer" if [ ! -d "$path" ]; then continue; fi do_checkin $path + test_or_die "running check-in on: $path" sep 28 done fi @@ -337,6 +345,7 @@ function checkout_list() # yep, this path is absolute. just handle it directly. if [ ! -d "$outer" ]; then continue; fi do_update $outer + test_or_die "running update on: $path" sep 28 else for inner in $list; do @@ -344,6 +353,7 @@ function checkout_list() local path="$inner/$outer" if [ ! -d "$path" ]; then continue; fi do_update $path + test_or_die "running update on: $path" sep 28 done fi @@ -382,9 +392,6 @@ function generate_rev_ctrl_filelist() # on each directory name, it performs the action (second parameter) provided. function perform_revctrl_action_on_file() { - -#hmmm: this doesn't capture any error returns! - local tempfile="$1"; shift local action="$1"; shift @@ -395,6 +402,7 @@ function perform_revctrl_action_on_file() pushd "$dirname" &>/dev/null echo "[$(pwd)]" $action . + test_or_die "performing action $action on: $(pwd)" sep 28 popd &>/dev/null done 3<"$tempfile" diff --git a/scripts/site_avenger/avcoreup.sh b/scripts/site_avenger/avcoreup.sh index 2fc6e46c..aa4af787 100644 --- a/scripts/site_avenger/avcoreup.sh +++ b/scripts/site_avenger/avcoreup.sh @@ -36,7 +36,7 @@ full_app_dir="$APPLICATION_DIR/$app_dirname" # simplistic approach here; just go to the folder and pull the changes. pushd "$full_app_dir" &>/dev/null -test_or_fail "Changing to app path '$full_app_dir'" +test_or_die "Changing to app path '$full_app_dir'" dir="avenger5/vendor/siteavenger/avcore" if [ ! -d $dir ]; then @@ -45,7 +45,7 @@ else pushd "$dir" &>/dev/null git pull - test_or_fail "Pulling git repo for avcore under '$full_app_dir'" + test_or_die "Pulling git repo for avcore under '$full_app_dir'" echo "Finished updating the avcore portion of site in ${app_dirname}." diff --git a/scripts/site_avenger/powerup.sh b/scripts/site_avenger/powerup.sh index b5cd0a89..aa1c4425 100644 --- a/scripts/site_avenger/powerup.sh +++ b/scripts/site_avenger/powerup.sh @@ -86,12 +86,12 @@ sep # this should set the site_store_path variable if everything goes well. update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name" -test_or_fail "Updating the repository storage directory" +test_or_die "Updating the repository storage directory" # update the site to load dependencies. sep composer_repuff "$site_store_path" -test_or_fail "Installing site dependencies with composer" +test_or_die "Installing site dependencies with composer" # set up the symbolic links needed to achieve siteliness. sep diff --git a/scripts/site_avenger/shared_site_mgr.sh b/scripts/site_avenger/shared_site_mgr.sh index ceefcc5b..8b18814c 100644 --- a/scripts/site_avenger/shared_site_mgr.sh +++ b/scripts/site_avenger/shared_site_mgr.sh @@ -17,7 +17,7 @@ function check_application_dir() if [ ! -d "$appdir" ]; then echo "Creating the apps directory: $appdir" mkdir "$appdir" - test_or_fail "Making apps directory when not already present" + test_or_die "Making apps directory when not already present" fi } @@ -47,7 +47,7 @@ function find_app_folder() exit 1 elif [ $numdirs -eq 1 ]; then app_dirname="$(basename $(find "$appsdir" -mindepth 1 -maxdepth 1 -type d) )" - test_or_fail "Guessing application folder" + test_or_die "Guessing application folder" else # if more than one folder, force user to choose. # Reference: https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script @@ -68,7 +68,7 @@ function find_app_folder() PS3="$holdps3" fi test_app_folder "$appsdir" "$app_dirname" - test_or_fail "Testing application folder: $app_dirname" + test_or_die "Testing application folder: $app_dirname" echo "Application folder is: $app_dirname" } @@ -84,7 +84,7 @@ function test_app_folder() if [ ! -d "$combo" ]; then echo "Creating app directory: $combo" mkdir "$combo" - test_or_fail "Making application directory when not already present" + test_or_die "Making application directory when not already present" fi } @@ -95,17 +95,17 @@ function fix_site_perms() if [ -f "$site_dir/bin/cake" ]; then chmod -R a+rx "$site_dir/bin/cake" - test_or_fail "Enabling execute bit on cake binary" + test_or_die "Enabling execute bit on cake binary" fi if [ -d "$site_dir/logs" ]; then chmod -R g+w "$site_dir/logs" - test_or_fail "Enabling group write on site's Logs directory" + test_or_die "Enabling group write on site's Logs directory" fi if [ -d "$site_dir/tmp" ]; then chmod -R g+w "$site_dir/tmp" - test_or_fail "Enabling group write on site's tmp directory" + test_or_die "Enabling group write on site's tmp directory" fi } @@ -117,7 +117,7 @@ function clear_orm_cache() if [ -f "$site_dir/bin/cake" ]; then # flush any cached objects from db. "$site_dir/bin/cake" orm_cache clear - test_or_fail "Clearing ORM cache" + test_or_die "Clearing ORM cache" fi } @@ -137,7 +137,7 @@ function update_repo() unset site_store_path pushd "$full_app_dir" &>/dev/null - test_or_fail "Switching to our app dir '$full_app_dir'" + test_or_die "Switching to our app dir '$full_app_dir'" local complete_path="$full_app_dir/$checkout_dirname" @@ -147,7 +147,7 @@ function update_repo() if [ -d "$checkout_dirname" ]; then # checkout directory exists, so let's check it. pushd "$checkout_dirname" &>/dev/null - test_or_fail "Switching to our checkout directory: $checkout_dirname" + test_or_die "Switching to our checkout directory: $checkout_dirname" # ask for repository name (without .git). if git rev-parse --git-dir > /dev/null 2>&1; then @@ -169,12 +169,12 @@ function update_repo() # a repository was found, so update the version here and leave. echo "Repository $repo_name exists. Updating it." rgetem - test_or_fail "Recursive checkout on: $complete_path" + test_or_die "Recursive checkout on: $complete_path" else # clone the repo since it wasn't found. echo "Cloning repository $repo_name now." git clone "$repo_root/$repo_name.git" $checkout_dirname - test_or_fail "Git clone of repository: $repo_name" + test_or_die "Git clone of repository: $repo_name" fi fix_site_perms "$complete_path" @@ -193,12 +193,12 @@ function composer_repuff() local site_store_path="$1"; shift pushd "$site_store_path" &>/dev/null - test_or_fail "Switching to our app dir '$site_store_path'" + test_or_die "Switching to our app dir '$site_store_path'" echo "Updating site with composer..." composer -n install - test_or_fail "Composer installation step on '$site_store_path'." + test_or_die "Composer installation step on '$site_store_path'." echo "Site updated." #hmmm: argh global @@ -232,13 +232,13 @@ function create_site_links() # jump into the site path so we can start making relative links. pushd "$site_store_path" &>/dev/null - test_or_fail "Switching to our app dir '$site_store_path'" + test_or_die "Switching to our app dir '$site_store_path'" pushd webroot &>/dev/null # remove all symlinks that might plague us. find . -maxdepth 1 -type l -exec rm -f {} ';' - test_or_fail "Cleaning out links in webroot" + test_or_die "Cleaning out links in webroot" # link in the avcore plugin. make_safe_link "../vendor/siteavenger/avcore/webroot" avcore @@ -265,18 +265,18 @@ function create_site_links() if [ -L public ]; then # public is a symlink. \rm public - test_or_fail "Removing public directory symlink" + test_or_die "Removing public directory symlink" elif [ -d public ]; then # public is a folder with default files. #hmmm: is that safe? \rm -rf public - test_or_fail "Removing public directory and contents" + test_or_die "Removing public directory and contents" fi # create the main 'public' symlink #hmmm: argh global make_safe_link $CHECKOUT_DIR_NAME/webroot public - test_or_fail "Creating link to webroot called 'public'" + test_or_die "Creating link to webroot called 'public'" #hmmm: public/$themelower/im will be created automatically by system user with appropriate permissions diff --git a/scripts/site_avenger/sitepush.sh b/scripts/site_avenger/sitepush.sh index 7d0a76a2..96358692 100644 --- a/scripts/site_avenger/sitepush.sh +++ b/scripts/site_avenger/sitepush.sh @@ -44,7 +44,7 @@ sep # this should set the site_store_path variable if everything goes well. update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name" -test_or_fail "Updating the repository storage directory" +test_or_die "Updating the repository storage directory" sep diff --git a/scripts/site_avenger/siteup.sh b/scripts/site_avenger/siteup.sh index 511a5617..c9b348c4 100644 --- a/scripts/site_avenger/siteup.sh +++ b/scripts/site_avenger/siteup.sh @@ -44,7 +44,7 @@ sep # this should set the site_store_path variable if everything goes well. update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name" -test_or_fail "Updating the repository storage directory" +test_or_die "Updating the repository storage directory" #### diff --git a/scripts/system/add_apache_site.sh b/scripts/system/add_apache_site.sh index b341c9c2..6b095634 100644 --- a/scripts/system/add_apache_site.sh +++ b/scripts/system/add_apache_site.sh @@ -96,7 +96,7 @@ function maybe_create_site_storage() local full_path="$BASE_PATH/$our_app" if [ ! -d "$full_path" ]; then mkdir -p $full_path - test_or_fail "The app storage path could not be created.\n Path in question is: $full_path" + test_or_die "The app storage path could not be created.\n Path in question is: $full_path" fi # now give the web server some access to the folder. this is crucial since the folders @@ -108,10 +108,10 @@ function maybe_create_site_storage() while [[ $chow_path != $HOME ]]; do echo chow path is now $chow_path chmod g+rx "$chow_path" - test_or_fail "Failed to add group permissions on the path: $chow_path" + test_or_die "Failed to add group permissions on the path: $chow_path" # reassert the user's ownership of any directories we might have just created. chown $(logname) "$chow_path" - test_or_fail "changing ownership to user failed on the path: $chow_path" + test_or_die "changing ownership to user failed on the path: $chow_path" chow_path="$(dirname "$chow_path")" done } diff --git a/scripts/system/add_swap_mount.sh b/scripts/system/add_swap_mount.sh index 6dacb770..593115fe 100644 --- a/scripts/system/add_swap_mount.sh +++ b/scripts/system/add_swap_mount.sh @@ -9,16 +9,16 @@ source "$WORKDIR/../core/launch_feisty_meow.sh" #hmmm: why all the hard-coded paths below? /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 -test_or_fail "creating swap file" +test_or_die "creating swap file" /bin/chmod 600 /var/swap.1 -test_or_fail "setting swap file permissions" +test_or_die "setting swap file permissions" /sbin/mkswap /var/swap.1 -test_or_fail "formatting swap file as swap partition" +test_or_die "formatting swap file as swap partition" /sbin/swapon /var/swap.1 -test_or_fail "enabling new swap partition" +test_or_die "enabling new swap partition" free diff --git a/scripts/system/naive_system_updater.sh b/scripts/system/naive_system_updater.sh index a6d65e96..b15d0efe 100644 --- a/scripts/system/naive_system_updater.sh +++ b/scripts/system/naive_system_updater.sh @@ -2,9 +2,9 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" sudo apt-get update -y -test_or_fail "problem while doing 'apt-get update'" +test_or_die "problem while doing 'apt-get update'" # new magic to tell dpkg to go with existing config files. let's see if it works! sudo apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" -test_or_fail "problem while doing 'apt-get dist-upgrade'" +test_or_die "problem while doing 'apt-get dist-upgrade'" -- 2.34.1