From fc51448ac8c18804d3cfc1997af3eaca5fad4c2e Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 6 Nov 2017 22:44:11 +0000 Subject: [PATCH] nice, first bit of auto-help added a diagnostic for when the recustomize script cannot run (when perl doesn't have File::Diff or File::Which yet). --- readme.txt | 20 +++++----- scripts/buildor/refresh_gffs_build.sh | 4 +- scripts/core/functions.sh | 23 +++++++++-- .../scripts/disk_synch/update_barkuptree.sh | 8 ++-- .../fred/scripts/email/filter_grabber.sh | 4 +- .../customize/fred/scripts/games/gamesaver.sh | 2 +- 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 +- 14 files changed, 72 insertions(+), 57 deletions(-) diff --git a/readme.txt b/readme.txt index bfb4793a..9516af62 100644 --- a/readme.txt +++ b/readme.txt @@ -13,7 +13,7 @@ How to get the feisty meow codebase | https://feistymeow.org/feisty_meow/documentation/cygwin_install_list.txt (web) Retrieve a clone of the feisty meow code: -=> git clone git://feistymeow.org/feisty_meow +# git clone git://feistymeow.org/feisty_meow The remainder of these notes assume that the code is stored in ~/feisty_meow (aka $HOME/feisty_meow). @@ -23,10 +23,10 @@ How to load the feisty meow script environment Set up the feisty_meow scripts; this is only needed once, when you first get the codebase. It can also regenerate the scripts using the latest version. -=> bash ~/feisty_meow/scripts/core/reconfigure_feisty_meow.sh +# bash ~/feisty_meow/scripts/core/reconfigure_feisty_meow.sh Load the script environment into the current shell. -=> source ~/feisty_meow/scripts/core/launch_feisty_meow.sh +# source ~/feisty_meow/scripts/core/launch_feisty_meow.sh With the feisty meow script environment loaded, several aliases are now available for building the codebase and they are used in the sections below. @@ -44,19 +44,19 @@ differ utility and the feisty meow customization system). They can be installed with either apt-get or CPAN. Install using apt-get: -=> sudo apt-get install libfile-which-perl libtext-diff-perl +# sudo apt-get install libfile-which-perl libtext-diff-perl or Install using perl's CPAN: -=> sudo cpan install Text::Diff File::Which +# sudo cpan install Text::Diff File::Which ============== How to install the build dependencies for feisty meow | Ubuntu / Debian: -| => sudo apt-get install build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev +| # sudo apt-get install build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev | Centos / Redhat / Fedora: -| => sudo yum install gcc gcc-c++ openssl-devel.x86_64 curl-devel +| # sudo yum install gcc gcc-c++ openssl-devel.x86_64 curl-devel | Microsoft Windows: | Download and install the Cygwin environment first from cygwin.com, which is @@ -66,17 +66,17 @@ How to install the build dependencies for feisty meow How to build the feisty meow codebase Run the following command to build the feisty meow libraries and applications. -=> bash ~/feisty_meow/scripts/generator/produce_feisty_meow.sh +# bash ~/feisty_meow/scripts/generator/produce_feisty_meow.sh After the build is complete, the feisty meow applications can be found in $FEISTY_MEOW_BINARIES (environment variable). -=> ls $FEISTY_MEOW_BINARIES +# ls $FEISTY_MEOW_BINARIES ============== How to clean up the files generated by the build This command cleans out all the generated files: -=> bash ~/feisty_meow/scripts/generator/whack_build.sh clean +# bash ~/feisty_meow/scripts/generator/whack_build.sh clean ============== What are the feisty meow dependencies? diff --git a/scripts/buildor/refresh_gffs_build.sh b/scripts/buildor/refresh_gffs_build.sh index 22118795..3476b1ba 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" - check_result Making GFFS logs directory. + test_or_fail Making GFFS logs directory. fi echo building the code freshly, although not with a clean first... build_gffs -check_result Building GFFS source code. +test_or_fail 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 7240866c..5c8f430e 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -121,15 +121,24 @@ 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 check_result() + function test_or_fail() { if [ $? -ne 0 ]; then - echo -e "failed on: $*" + echo -e "\n\nfailed on: $*" error_sound exit 1 fi } + # like test_or_fail, but will keep going after complaining. + function test_or_continue() + { + if [ $? -ne 0 ]; then + echo -e "\n\nfailed on: $*" + error_sound + fi + } + # wraps secure shell with some parameters we like, most importantly to enable X forwarding. function ssh() { @@ -423,18 +432,24 @@ if [ -z "$skip_all" ]; then regenerate >/dev/null pushd "$FEISTY_MEOW_LOADING_DOCK/custom" &>/dev/null incongruous_files="$(bash "$FEISTY_MEOW_SCRIPTS/files/list_non_dupes.sh" "$FEISTY_MEOW_SCRIPTS/customize/$custom_user" "$FEISTY_MEOW_LOADING_DOCK/custom")" + + local fail_message="\nare the perl dependencies installed? if you're on ubuntu or debian, try this:\n + $(grep "apt.*perl" $FEISTY_MEOW_APEX/readme.txt)\n" #echo "the incongruous files list is: $incongruous_files" # disallow a single character result, since we get "*" as result when nothing exists yet. if [ ${#incongruous_files} -ge 2 ]; then echo "cleaning unknown older overrides..." perl "$FEISTY_MEOW_SCRIPTS/files/safedel.pl" $incongruous_files + test_or_continue "running safedel. $fail_message" echo fi popd &>/dev/null echo "copying custom overrides for $custom_user" mkdir -p "$FEISTY_MEOW_LOADING_DOCK/custom" 2>/dev/null perl "$FEISTY_MEOW_SCRIPTS/text/cpdiff.pl" "$FEISTY_MEOW_SCRIPTS/customize/$custom_user" "$FEISTY_MEOW_LOADING_DOCK/custom" + test_or_continue "running cpdiff. $fail_message" + if [ -d "$FEISTY_MEOW_SCRIPTS/customize/$custom_user/scripts" ]; then echo "copying custom scripts for $custom_user" \cp -R "$FEISTY_MEOW_SCRIPTS/customize/$custom_user/scripts" "$FEISTY_MEOW_LOADING_DOCK/custom/" @@ -721,7 +736,7 @@ return 0 if [ -d "$src" ]; then ln -s "$src" "$target" - check_result "Creating symlink from '$src' to '$target'" + test_or_fail "Creating symlink from '$src' to '$target'" fi echo "Created symlink from '$src' to '$target'." } @@ -745,7 +760,7 @@ return 0 echo running tests on set_var_if_undefined. flagrant=petunia set_var_if_undefined flagrant forknordle - check_result "testing if defined variable would be whacked" + test_or_fail "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 d87999cc..bb549231 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/ -check_result "synching archons" +test_or_fail "synching archons" # copy over our somewhat attenuated but still important walrus archives. netcp /z/walrus/* $BARKY/walrus/ -check_result "synching walrus" +test_or_fail "synching walrus" # copy all the music files for future reference. netcp /z/musix/* $BARKY/musix/ -check_result "synching musix" +test_or_fail "synching musix" # back up the photo archives. netcp /z/imaginations/* $BARKY/imaginations/ -check_result "synching imaginations" +test_or_fail "synching imaginations" diff --git a/scripts/customize/fred/scripts/email/filter_grabber.sh b/scripts/customize/fred/scripts/email/filter_grabber.sh index 7cff38f3..5261c8c5 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 -check_result "copying feistymeow.org filters" +test_or_fail "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 -check_result "copying UVa filters" +test_or_fail "copying UVa filters" diff --git a/scripts/customize/fred/scripts/games/gamesaver.sh b/scripts/customize/fred/scripts/games/gamesaver.sh index 43aa8d41..767ded0b 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" - check_result Creating spooling output directory. + test_or_fail Creating spooling output directory. fi # copies the files for a particular game out to a spooling folder. diff --git a/scripts/site_avenger/avcoreup.sh b/scripts/site_avenger/avcoreup.sh index 7ae0b6ba..2fc6e46c 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 -check_result "Changing to app path '$full_app_dir'" +test_or_fail "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 - check_result "Pulling git repo for avcore under '$full_app_dir'" + test_or_fail "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 93ae3d42..b5cd0a89 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" -check_result "Updating the repository storage directory" +test_or_fail "Updating the repository storage directory" # update the site to load dependencies. sep composer_repuff "$site_store_path" -check_result "Installing site dependencies with composer" +test_or_fail "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 3bd96658..ceefcc5b 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" - check_result "Making apps directory when not already present" + test_or_fail "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) )" - check_result "Guessing application folder" + test_or_fail "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" - check_result "Testing application folder: $app_dirname" + test_or_fail "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" - check_result "Making application directory when not already present" + test_or_fail "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" - check_result "Enabling execute bit on cake binary" + test_or_fail "Enabling execute bit on cake binary" fi if [ -d "$site_dir/logs" ]; then chmod -R g+w "$site_dir/logs" - check_result "Enabling group write on site's Logs directory" + test_or_fail "Enabling group write on site's Logs directory" fi if [ -d "$site_dir/tmp" ]; then chmod -R g+w "$site_dir/tmp" - check_result "Enabling group write on site's tmp directory" + test_or_fail "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 - check_result "Clearing ORM cache" + test_or_fail "Clearing ORM cache" fi } @@ -137,7 +137,7 @@ function update_repo() unset site_store_path pushd "$full_app_dir" &>/dev/null - check_result "Switching to our app dir '$full_app_dir'" + test_or_fail "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 - check_result "Switching to our checkout directory: $checkout_dirname" + test_or_fail "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 - check_result "Recursive checkout on: $complete_path" + test_or_fail "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 - check_result "Git clone of repository: $repo_name" + test_or_fail "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 - check_result "Switching to our app dir '$site_store_path'" + test_or_fail "Switching to our app dir '$site_store_path'" echo "Updating site with composer..." composer -n install - check_result "Composer installation step on '$site_store_path'." + test_or_fail "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 - check_result "Switching to our app dir '$site_store_path'" + test_or_fail "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 {} ';' - check_result "Cleaning out links in webroot" + test_or_fail "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 - check_result "Removing public directory symlink" + test_or_fail "Removing public directory symlink" elif [ -d public ]; then # public is a folder with default files. #hmmm: is that safe? \rm -rf public - check_result "Removing public directory and contents" + test_or_fail "Removing public directory and contents" fi # create the main 'public' symlink #hmmm: argh global make_safe_link $CHECKOUT_DIR_NAME/webroot public - check_result "Creating link to webroot called 'public'" + test_or_fail "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 b88689b6..7d0a76a2 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" -check_result "Updating the repository storage directory" +test_or_fail "Updating the repository storage directory" sep diff --git a/scripts/site_avenger/siteup.sh b/scripts/site_avenger/siteup.sh index 205f342e..511a5617 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" -check_result "Updating the repository storage directory" +test_or_fail "Updating the repository storage directory" #### diff --git a/scripts/system/add_apache_site.sh b/scripts/system/add_apache_site.sh index 909604bb..b341c9c2 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 - check_result "The app storage path could not be created.\n Path in question is: $full_path" + test_or_fail "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" - check_result "Failed to add group permissions on the path: $chow_path" + test_or_fail "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" - check_result "changing ownership to user failed on the path: $chow_path" + test_or_fail "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 f20c5cb6..6dacb770 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 -check_result "creating swap file" +test_or_fail "creating swap file" /bin/chmod 600 /var/swap.1 -check_result "setting swap file permissions" +test_or_fail "setting swap file permissions" /sbin/mkswap /var/swap.1 -check_result "formatting swap file as swap partition" +test_or_fail "formatting swap file as swap partition" /sbin/swapon /var/swap.1 -check_result "enabling new swap partition" +test_or_fail "enabling new swap partition" free diff --git a/scripts/system/naive_system_updater.sh b/scripts/system/naive_system_updater.sh index 08cd5266..a6d65e96 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 -check_result "problem while doing 'apt-get update'" +test_or_fail "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" -check_result "problem while doing 'apt-get dist-upgrade'" +test_or_fail "problem while doing 'apt-get dist-upgrade'" -- 2.34.1