found issue where config wasn't checked for test
[feisty_meow.git] / scripts / site_avenger / shared_site_mgr.sh
index 3c03ccbe6002aeb52223f952b8150b83f1bc471d..d4c5c95a55bf69cadf0ec56c551916f8f77741bf 100644 (file)
@@ -16,6 +16,8 @@ source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 export SITE_MANAGEMENT_CONFIG_FILE
 if [ -z "$SITE_MANAGEMENT_CONFIG_FILE" ]; then
   SITE_MANAGEMENT_CONFIG_FILE="$WORKDIR/config/default.app"
+  echo "Site management config file was not set.  Using default:"
+  echo "  $SITE_MANAGEMENT_CONFIG_FILE"
 fi
 
 # load in at least the default version to get us moving.
@@ -36,6 +38,33 @@ function check_application_dir()
   fi
 }
 
+# tries to find an appropriate config file for the application.
+function locate_config_file()
+{
+  local app_dirname="$1"; shift
+
+  local configfile="$WORKDIR/config/${app_dirname}.app"
+echo hoping config file would be: $configfile
+  if [ ! -f "$configfile" ]; then
+    # this is not a good config file.  we can't auto-guess the config.
+    echo -e "
+There is no specific site configuration file in:
+  $configfile
+We will continue onward using the default and hope that this project follows
+the standard pattern for cakephp projects."
+    # we'll pull in the default config file we set earlier; this will
+    # reinitialize some variables based on the app name.
+  else
+    # they gave us a valid config file.  let's try using it.
+    export SITE_MANAGEMENT_CONFIG_FILE="$configfile"
+  fi
+
+  # try to load the config.
+  source "$SITE_MANAGEMENT_CONFIG_FILE"
+  test_or_die "loading site management configuration from: $SITE_MANAGEMENT_CONFIG_FILE"
+
+}
+
 # this function will seek out top-level directories in the target directory passed in.
 # if there is only one directory, then it is returned (in the app_dirname variable).
 # otherwise, the user is asked which directory to use.
@@ -86,25 +115,6 @@ function find_app_folder()
   test_or_die "Testing application folder: $app_dirname"
 
   echo "Application folder is: $app_dirname"
-
-  local configfile="$WORKDIR/config/${app_dirname}.app"
-  if [ ! -f "$configfile" ]; then
-    # this is not a good config file.  we can't auto-guess the config.
-    echo -e "
-There is no specific site configuration file in:
-  $configfile
-We will continue onward using the default and hope that this project follows
-the standard pattern for cakephp projects."
-    # we'll pull in the default config file we set earlier; this will
-    # reinitialize some variables based on the app name.
-  else
-    # they gave us a valid config file.  let's try using it.
-    SITE_MANAGEMENT_CONFIG_FILE="$configfile"
-  fi
-
-  # try to load the config.
-  source "$SITE_MANAGEMENT_CONFIG_FILE"
-  test_or_die "loading site management configuration from: $SITE_MANAGEMENT_CONFIG_FILE"
 }
 
 # ensures that the app directory name is valid.
@@ -120,6 +130,8 @@ function test_app_folder()
     mkdir "$combo"
     test_or_die "Making application directory when not already present"
   fi
+
+  locate_config_file "$dir"
 }
 
 # eases some permissions to enable apache to write log files and do other shopkeeping.