From f8c8e666cc22c5cc3a18311ee8f534becfa23ca7 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 20 Mar 2018 16:49:41 -0400 Subject: [PATCH] new fortune, plus site avenger mods added new switchto macro, not quite right yet since can exit shell if doesn't find directory. some doc fixes in comments. turned off swap file unless special flag is present, since ssd drives do not want this. --- infobase/fortunes.dat | 21 ++++++++ scripts/core/functions.sh | 10 ++++ scripts/site_avenger/powerup.sh | 6 +-- scripts/site_avenger/revamp_cakelampvm.sh | 62 +++++++++++++---------- scripts/site_avenger/shared_site_mgr.sh | 23 +++++++++ 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/infobase/fortunes.dat b/infobase/fortunes.dat index 96ca7b79..e0afccec 100644 --- a/infobase/fortunes.dat +++ b/infobase/fortunes.dat @@ -43240,5 +43240,26 @@ always clean, the embodiment of Buddha is always seen; if the mind is polluted, the vessel breaks and the Buddha cannot be seen." -- from "The Flower Ornament Scripture: A Translation of The Avatamsaka Sutra", translated by Thomas Cleary, published by Shambhala Publications +~ +Why is endeavor necessary? If we consider material progress, we see that +research started by one person can always be continued by another. But this +is not possible with spiritual progress. The realization we talk about in the +Buddhadharma is something that has to be accomplished by the individual. No +one else can do it for us. Of course, it would be wonderful if in the future +we could attain realization through some sort of new injection or by means of +a new generation of computers, without having to go through any difficulties. +If we could be absolutely certain that such a time would come, we could simply +lie back and wait to get enlightened. But I doubt that this will ever happen. +It is better to make an effort. We have to develop endeavor. + + 1. + Thus with patience I will strive with diligence. + For in such diligence enlightenment is found. + If no wind blows, then nothing stirs, + And neither is there merit without diligence.   + -- H.H. the Fourteenth Dalai Lama, from "The Bodhisattva Guide: A Commentary + on The Way of the Bodhisattva", The Bodhisattva Guide was originally + published as For the Benefit of All Beings, also published by Shambhala + Publications diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 4ace5d80..644ce8a0 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -929,6 +929,16 @@ return 0 ############## + # site avenger aliases + function switchto() + { + WORKDIR="$FEISTY_MEOW_SCRIPTS/site_avenger" + source "$FEISTY_MEOW_SCRIPTS/site_avenger/shared_site_mgr.sh" + switch_to "$1" + } + + ############## + # NOTE: no more function definitions are allowed after this point. function function_sentinel() diff --git a/scripts/site_avenger/powerup.sh b/scripts/site_avenger/powerup.sh index 1c2b3425..46070f60 100644 --- a/scripts/site_avenger/powerup.sh +++ b/scripts/site_avenger/powerup.sh @@ -3,8 +3,8 @@ # Author: Kevin Wentworth # Author: Chris Koeritz -# This script "powers up" a cakephp site by running the database migrations, -# cleaning out the ORM cache, and fixing file permissions. +# This script "powers up" a cakephp site by checking out the code from the +# git repository and installing the composer dependencies. # This script is currently highly specific to site avenger. # General Info: @@ -13,7 +13,7 @@ # A git repository is expected to be provided, and we will get all the code # for the web site from there. The repository is expected to have a single # application "name" and one or more "themes". By convention, the name -# and the theme are often the same. +# and the theme are often the same, except the theme is capitalized. # For example, let's say our app name is "turtle" and our theme name is "box". # The repo is checked out to a folder called "~/apps/turtle". # This script will want to use "turtle" as the app name. diff --git a/scripts/site_avenger/revamp_cakelampvm.sh b/scripts/site_avenger/revamp_cakelampvm.sh index dfc656ae..fba7bb60 100644 --- a/scripts/site_avenger/revamp_cakelampvm.sh +++ b/scripts/site_avenger/revamp_cakelampvm.sh @@ -235,7 +235,7 @@ fi ############## -# fix samba configuration for (ass-headed) default of read-only in user homes. +# fix samba configuration for screwy default of read-only in user homes. # why cripple a necessary feature by default? sep @@ -247,9 +247,10 @@ replacement="read only = no" # was actually already in the file... too much subtlety can get one into trouble. sed -i "0,/$pattern/{s/$pattern/$replacement/}" /etc/samba/smb.conf test_or_die "patching samba configuration to enable write acccess on user home dirs" +echo successfully patched the samba configuration to enable writes on user home directories. + # sweet, looks like that worked... restart_samba -echo successfully patched the samba configuration to enable writes on user home directories. ############## @@ -277,47 +278,52 @@ echo Successfully configured the apache2 environment variables needed for cakela sep -echo "Checking existing swap partition configuration. +# we will only add swap now if explicitly asked for it. this is to avoid creating +# a swap file where the vm is running on an SSD, since that can use up the SSD's lifespan +# too quickly. +if [ ! -z "$ADD_SWAP" ]; then + echo "Checking existing swap partition configuration. " -# check for existing swap. -free | grep -q "Swap:[[:blank:]]*[1-9][0-9]" -if [ $? -ne 0 ]; then - # no swap in current session, so add it. - echo "Enabling ramdisk swap partition... + # check for existing swap. + free | grep -q "Swap:[[:blank:]]*[1-9][0-9]" + if [ $? -ne 0 ]; then + # no swap in current session, so add it. + echo "Enabling ramdisk swap partition... " - add_swap_mount - echo " + add_swap_mount + echo " Enabled ramdisk swap partition for current boot session." -fi + fi -# the above just gives this session a swap partition, but we want to have -# the vm boot with one also. + # the above just gives this session a swap partition, but we want to have + # the vm boot with one also. -# check if there is already swap mentioned in the root crontab. we will get root's -# crontab below since this script has to run as sudo. -crontab -l | grep -iq add_swap_mount -if [ $? -ne 0 ]; then - # no existing swap setup in crontab, so add it. - echo " + # check if there is already swap mentioned in the root crontab. we will get root's + # crontab below since this script has to run as sudo. + crontab -l | grep -iq add_swap_mount + if [ $? -ne 0 ]; then + # no existing swap setup in crontab, so add it. + echo " Adding a boot-time ramdisk swap partition... " - # need to do it carefully, since sed won't add lines to a null file. we thus - # create a temporary file to do our work in and ignore sed as a tool for this. - tmpfile="$(mktemp junk.XXXXXX)" - crontab -l 2>/dev/null >"$tmpfile" - echo " + # need to do it carefully, since sed won't add lines to a null file. we thus + # create a temporary file to do our work in and ignore sed as a tool for this. + tmpfile="$(mktemp junk.XXXXXX)" + crontab -l 2>/dev/null >"$tmpfile" + echo " # need to explicitly set any variables we will use. FEISTY_MEOW_APEX=${FEISTY_MEOW_APEX} # add swap space to increase memory available. @reboot bash $FEISTY_MEOW_APEX/scripts/system/add_swap_mount.sh " >>"$tmpfile" - # now install our new version of the crontab. - crontab "$tmpfile" - rm "$tmpfile" + # now install our new version of the crontab. + crontab "$tmpfile" + rm "$tmpfile" - echo " + echo " Added boot-time ramdisk swap partition to crontab for root." + fi fi ############## diff --git a/scripts/site_avenger/shared_site_mgr.sh b/scripts/site_avenger/shared_site_mgr.sh index 27b03b9a..6f731e69 100644 --- a/scripts/site_avenger/shared_site_mgr.sh +++ b/scripts/site_avenger/shared_site_mgr.sh @@ -381,4 +381,27 @@ function fix_appdir_ownership() fix_site_perms "$combo" } +# Jumps to an application directory given the app name. If no app name is +# given, it will show a menu to pick the app. +function switch_to() +{ + # check for parameters. + app_dirname="$1"; shift + + check_application_dir "$BASE_APPLICATION_PATH" + + # find proper webroot where the site will be initialized. + if [ -z "$app_dirname" ]; then + # no dir was passed, so guess it. + find_app_folder "$BASE_APPLICATION_PATH" + else + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" + fi + + # where we expect to find our checkout folder underneath. + full_app_dir="$BASE_APPLICATION_PATH/$app_dirname" + + cd $full_app_dir/$CHECKOUT_DIR_NAME + pwd +} -- 2.34.1