using THISDIR instead of WORKDIR
authorChris Koeritz <fred@gruntose.com>
Fri, 18 May 2018 22:01:41 +0000 (18:01 -0400)
committerChris Koeritz <fred@gruntose.com>
Fri, 18 May 2018 22:01:41 +0000 (18:01 -0400)
for the auto-location stuff, we're now using the more self-descriptive name of THISDIR for where the script started up in.

21 files changed:
infobase/examples/bashisms/script_location.sh
scripts/archival/backup_trac.sh
scripts/core/connect_feisty_meow.sh
scripts/core/functions.sh
scripts/core/launch_feisty_meow.sh
scripts/security/cool_permissionator.sh
scripts/shunit/example_shunit_test.sh
scripts/site_avenger/avcoreup.sh
scripts/site_avenger/powerup.sh
scripts/site_avenger/revamp_cakelampvm_v002.sh
scripts/site_avenger/revamp_cakelampvm_v003.sh
scripts/site_avenger/shared_site_mgr.sh
scripts/site_avenger/sitepush.sh
scripts/site_avenger/siteup.sh
scripts/site_avenger/standup.sh
scripts/site_avenger/teardown.sh
scripts/system/add_apache_site.sh
scripts/system/add_domain.sh
scripts/system/add_swap_mount.sh
scripts/system/remove_apache_site.sh
scripts/system/remove_domain.sh

index 7fa942a6302f90daba31cd31c49a686c3ef4def4..bea06161a02477a4d30a6246a36196f42330e9b2 100644 (file)
@@ -6,5 +6,5 @@
 ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && /bin/pwd )"
 
 # another slightly tighter version:
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 
index f96e5ae5acbf4cd868a13f45dd82c231a47bd80d..dadb6219a89d6ab9cf8d285a7f5297298c0a8cc6 100644 (file)
@@ -2,12 +2,12 @@
 
 # backs up a trac repository into a tar.gz file.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 
 trac_path="$1"; shift
 archive_path="$1"; shift
 
 # call our arbitrary backer upper, since this is a simple single directory case.
-bash $WORKDIR/backup_arbitrary.sh "$trac_path" "$archive_path" "trac_bkup"
+bash $THISDIR/backup_arbitrary.sh "$trac_path" "$archive_path" "trac_bkup"
 
 
index 6f6ffd3840536016553661e94eb259b9133ac001..211bba7b975b06a7fe74da328e71d2e0cfceb8e4 100644 (file)
@@ -5,9 +5,9 @@
 # this script adds the feisty inits code to .bashrc, if we think it has not yet been added.
 
 # auto-locate the feisty meow scripts, since they supposedly are not enabled yet.
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 # normalize the path we want to cobble together.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 echo calculated apex as $FEISTY_MEOW_APEX
 
index efc7df5428303e52b9db3aa9fee300abfab4a1a1..494c43c55aa5356932891fb6e77384f222946211 100644 (file)
@@ -933,7 +933,7 @@ return 0
   # site avenger aliases
   function switchto()
   {
-    WORKDIR="$FEISTY_MEOW_SCRIPTS/site_avenger"
+    THISDIR="$FEISTY_MEOW_SCRIPTS/site_avenger"
     source "$FEISTY_MEOW_SCRIPTS/site_avenger/shared_site_mgr.sh"
     switch_to "$1"
   }
index f793c6d9d412d4ed80afc8663f686e7a8dffd090..0d7d54beb9d4ed27a880d33b229d29314a573dd5 100644 (file)
@@ -19,7 +19,7 @@
 ##############
 
 # this script cannot handle figuring out where it lives, so approaches that
-# get the WORKDIR will fail.  this is a consequence of this always being used
+# get the THISDIR will fail.  this is a consequence of this always being used
 # in bash's 'source' directive, which does not pass the script name as
 # argument 0.  instead, we just check for the bad condition of a malconfigured
 # script system and try to repair it.
index 340e224209d85640977dc7d7a8110d9d02029ac2..e66cab8656e14aaaea91e05ec44d0655d8cd7ebb 100644 (file)
@@ -28,11 +28,18 @@ function reapply_cool_permissions()
   fi
 
   # fix some permissions for important security considerations.
-  harsh_perm $HOME/.ssh
+  if [ -d $HOME/.ssh ]; then
+    harsh_perm $HOME/.ssh
+  fi
+
+#hmmm: consider adding feisty meow apex to the dirname list below.
 
-#hmmm: consider adding feisty meow apex to the list below.
   # iterate across the list of dirs we want cooluser to own and change their ownership.
-  for dirname in $HOME $DEFAULT_FEISTYMEOW_ORG_DIR /usr/local/${cooluser} /home/games $arch_addin; do
+  for dirname in $HOME \
+        $DEFAULT_FEISTYMEOW_ORG_DIR \
+        /usr/local/${cooluser} \
+        /home/games \
+        $arch_addin; do
     if [ -d "$dirname" ]; then
       echo "revising ownership on '$dirname'"
       sudo chown -R ${cooluser}:${cooluser} "$dirname"
@@ -40,19 +47,19 @@ function reapply_cool_permissions()
     fi
   done
 
-  # special case for archives directory.
+  # special case for archives directory in stuffing.
   if [ -d /z/stuffing -o -L /z/stuffing ]; then
-    sudo chown ${cooluser}:${cooluser} /z
+    sudo chown ${cooluser}:${cooluser} /z/
     test_or_die "chowning /z for ${cooluser}"
     sudo chmod g+rx,o+rx /z
     test_or_die "chmodding /z/ for ${cooluser}"
-    sudo chown ${cooluser}:${cooluser} /z/stuffing
+    sudo chown ${cooluser}:${cooluser} /z/stuffing/
     test_or_die "chowning /z/stuffing for ${cooluser}"
     sudo chmod g+rx,o-rwx /z/stuffing
     test_or_die "chmodding /z/stuffing for ${cooluser}"
     pushd /z/stuffing &>/dev/null
     if [ -d archives -o -L archives ]; then
-      sudo chown ${cooluser}:${cooluser} archives
+      sudo chown ${cooluser}:${cooluser} archives/
       test_or_die "chowning /z/stuffing/archives for ${cooluser}"
       sudo chmod -R g+rwx archives
       test_or_die "chmodding /z/stuffing/archives for ${cooluser}"
@@ -60,7 +67,7 @@ function reapply_cool_permissions()
     popd &>/dev/null
   fi
 
-  # make the logs readable by normal humans.
+  # make the log files readable by normal humans.
   sudo bash $FEISTY_MEOW_SCRIPTS/security/normal_perm.sh /var/log
   test_or_die "setting normal perms on /var/log"
 }
@@ -69,11 +76,17 @@ function reapply_cool_permissions()
 # than when it's just being sourced.
 
 # this runs the cool permission applier on the current user.
-if [[ $0 =~ .*reapply_cool_permissions\.sh.* ]]; then
+if [[ $0 =~ .*cool_permissionator\.sh.* ]]; then
+echo A
   THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
+echo B
+  export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
+echo B.2
   source "$THISDIR/../core/launch_feisty_meow.sh"
   test_or_die "sourcing the feisty meow launcher"
+echo C
   reapply_cool_permissions $(logname)
   test_or_die "reapplying cool permissions on $(logname)"
+echo D
 fi
 
index 17b3dd89509b1b45424654a679748e7aa58abc10..8931aef130e2e904ef09bc3cf977ca511f849ac6 100644 (file)
@@ -5,13 +5,13 @@
 # Author: Chris Koeritz
 # license gnu gpl v3
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
 if [[ ! "$0" =~ ^/.* ]]; then
   # re-run the script with an absolute path if it didn't start out that way; otherwise,
   # shunit is not happy with finding the script.
-  exec "$WORKDIR/$(basename $0)" $*
+  exec "$THISDIR/$(basename $0)" $*
 fi
-cd $WORKDIR
+cd $THISDIR
 
 oneTimeSetUp()
 {
index 33c3daafe142c01b70412268dd0ef332e8392e4a..106c1fd3ef76be3234ac92d7a03637ddb180c240 100644 (file)
@@ -5,7 +5,7 @@
 
 # updates just the site avenger core portion of an app.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 
 ############################
 
@@ -14,7 +14,7 @@ export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's work
 # check for parameters.
 app_dirname="$1"; shift
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index eccb0b6aefd33f6ace6af024be3390c88fcc1843..28e03240535621e09910b5bba5223a51ba31cf78 100644 (file)
@@ -20,8 +20,8 @@
 # It will have to be told the theme name, but will assume it's 'Turtle' to
 # start with.  The concept of the theme comes from cakephp.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 
@@ -55,7 +55,7 @@ if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
   print_instructions
 fi
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index b71d8835fc59d35daa3de0b53a646573cd673ffe..20f721c14db856fb6aefdd25ce14c02787483f2e 100644 (file)
@@ -16,8 +16,8 @@ fi
 
 ##############
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 export NO_HELLO=right
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
index 771f81e2fc04e84ea1e6c327e64673d8166fa417..ccd406598d55e6e1e06ae5c7259615695790db2e 100644 (file)
@@ -16,8 +16,8 @@ fi
 
 ##############
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 export NO_HELLO=right
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
index b0ce7d6dcc7a5f379a9331a7e566ca7994b37b63..4f35016d0c7b59a165f4fdd2063923b10974c2b5 100644 (file)
@@ -5,7 +5,7 @@
 
 # This contains a bunch of reusable functions that help out in managing websites.
 
-# This script is sourced, and relies on the value of WORKDIR, which should
+# This script is sourced, and relies on the value of THISDIR, which should
 # point at the directory where the site management scripts are stored,
 # especially this one.
 
@@ -17,7 +17,7 @@ export SSM_LOG_FILE="$TMP/$(logname)-siteavenger-script.log"
 # if there is none, we will use our default version.
 export SITE_MANAGEMENT_CONFIG_FILE
 if [ -z "$SITE_MANAGEMENT_CONFIG_FILE" ]; then
-  SITE_MANAGEMENT_CONFIG_FILE="$WORKDIR/config/default.app"
+  SITE_MANAGEMENT_CONFIG_FILE="$THISDIR/config/default.app"
   echo "$(date_stringer): Site management config file was not set.  Using default:" >> "$SSM_LOG_FILE"
   echo "$(date_stringer):   $SITE_MANAGEMENT_CONFIG_FILE" >> "$SSM_LOG_FILE"
 fi
@@ -45,7 +45,7 @@ function locate_config_file()
 {
   local app_dirname="$1"; shift
 
-  local configfile="$WORKDIR/config/${app_dirname}.app"
+  local configfile="$THISDIR/config/${app_dirname}.app"
   echo "$(date_stringer): config file guessed?: $configfile" >> "$SSM_LOG_FILE"
   if [ ! -f "$configfile" ]; then
     # this is not a good config file.  we can't auto-guess the config.
index 52e2e13d6b701455695ec0f970f356ecc0ea59e2..8a69d5daa2ddb37d9ff44f8537f35f6657467395 100644 (file)
@@ -5,7 +5,7 @@
 
 # checks the chosen site into the online git repository.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 
 ############################
 
@@ -15,7 +15,7 @@ export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's work
 app_dirname="$1"; shift
 repo_name="$1"; shift
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index e2a70593334ebffa4a30416fa5f377eedab1e567..8c186ad904da0b05d1af6fdefeda797f2d1b845f 100644 (file)
@@ -5,7 +5,7 @@
 
 # updates a site avenger app.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
 
 ############################
 
@@ -15,7 +15,7 @@ export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's work
 app_dirname="$1"; shift
 repo_name="$1"; shift
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index 3ba100f36a7471bf39cc9bec7f7da9550c489387..72378ca8d4c48b78fdd7673639c6cdf0292d1c82 100644 (file)
@@ -6,8 +6,8 @@
 # management scripts.  So far, the scripts rely on at least php.  The support
 # is much more powerful if the site is based on cakephp and site avenger.
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 
@@ -51,7 +51,7 @@ fi
 # through to ask for access.
 sudo bash -c 'echo sudo permissions acquired.'
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index 91de942005a0ffaec25ae9e863ece47a97924d7d..68fa0e14e979bfd32b283d05539359df92d989ef 100644 (file)
@@ -5,8 +5,8 @@
 #
 # Author: Chris Koeritz
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 
@@ -43,7 +43,7 @@ fi
 # through to ask for access.
 sudo bash -c 'echo sudo permissions acquired.'
 
-source "$WORKDIR/shared_site_mgr.sh"
+source "$THISDIR/shared_site_mgr.sh"
 
 sep
 
index 778b22d57d69733837dd271125e25a1d6c87bf96..d3d4595d454bd82869da551a3593098c0936a3c4 100644 (file)
@@ -3,8 +3,8 @@
 # creates a new apache website for a specified domain.
 
 # auto-find the scripts, since we might want to run this as sudo.
-export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
index e12faa7be928ddaa8cba56bc9babc60ac2d5e040..7800904230a77b6eaf3bbe71ae5068a832564162 100644 (file)
@@ -10,8 +10,8 @@
 #
 # Author: Chris Koeritz
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
index 608ffc5c3306cef0a4f241f934a784e4f948a7c2..b400fcb98f556d52faf28ab2794f439800745dad 100644 (file)
@@ -1,8 +1,8 @@
 #!/bin/bash
 
 # auto-find the scripts, since we might want to run this as sudo.
-export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 
 if [[ $EUID != 0 ]]; then
index ef6c8b6d79915b608f44707f9e6094bcca87a23c..6d23e7ab7205e3a146ee0e359a8627a4bc914ff7 100644 (file)
@@ -3,8 +3,8 @@
 # uninstalls the apache website for a specified domain.
 
 # auto-find the scripts, since we might want to run this as sudo.
-export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
index f734878a3aa026635321fe596d0ea237dbda271b..45bb487cae14275105877e5d2bfd62ea7528f092 100644 (file)
@@ -6,8 +6,8 @@
 #
 # Author: Chris Koeritz
 
-export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
 
 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"