From 04e93c92f5208d4c4b195493bb6cbc4549969851 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 14 Nov 2017 18:00:23 -0500 Subject: [PATCH] improved variable cohesion in site avenger scripts config file should be able to provide everything now. --- scripts/site_avenger/avcoreup.sh | 8 +++--- scripts/site_avenger/config/default.app | 24 +++++++++++++++++- scripts/site_avenger/powerup.sh | 12 ++++----- scripts/site_avenger/sitepush.sh | 8 +++--- scripts/site_avenger/siteup.sh | 8 +++--- scripts/site_avenger/standup.sh | 6 ++--- scripts/system/add_apache_site.sh | 16 +++++++----- scripts/system/add_domain.sh | 33 ++++++++++++++++--------- 8 files changed, 75 insertions(+), 40 deletions(-) diff --git a/scripts/site_avenger/avcoreup.sh b/scripts/site_avenger/avcoreup.sh index f7594949..2ae511cb 100644 --- a/scripts/site_avenger/avcoreup.sh +++ b/scripts/site_avenger/avcoreup.sh @@ -18,18 +18,18 @@ source "$WORKDIR/shared_site_mgr.sh" sep -check_application_dir "$APPLICATION_DIR" +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 "$APPLICATION_DIR" + find_app_folder "$BASE_APPLICATION_PATH" else - test_app_folder "$APPLICATION_DIR" "$app_dirname" + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" fi # where we expect to find our checkout folder underneath. -full_app_dir="$APPLICATION_DIR/$app_dirname" +full_app_dir="$BASE_APPLICATION_PATH/$app_dirname" # simplistic approach here; just go to the folder and pull the changes. diff --git a/scripts/site_avenger/config/default.app b/scripts/site_avenger/config/default.app index a7b9e909..0235eb50 100644 --- a/scripts/site_avenger/config/default.app +++ b/scripts/site_avenger/config/default.app @@ -11,9 +11,31 @@ # basic information that is constant for all site avenger sites. -export APPLICATION_DIR="$HOME/apps" +# the top level of the user's application storage. +export BASE_APPLICATION_PATH="$HOME/apps" +# where the code should come from. export DEFAULT_REPOSITORY_ROOT="git@github.com:kwentworth" +# we checkout the git repository to a directory underneath the +# app storage directory named this: export CHECKOUT_DIR_NAME="avenger5" +# the subfolder that the web browser will look for the site in, +# underneath the application's specific path. +export STORAGE_SUFFIX="/public" + +#### + +# constants within our cakelampvm machine. + +# in our scheme, the single IP address that all our domains map to. +export IP_ADDRESS="10.28.42.20" +# the email address (where first dot is replaced by @) for the administrator of the domain. +export SERVER_ADMIN="developer.cakelampvm.com" +# the name of the name server for the new domains (should already be configured). +export MAIN_NAME_SERVER="ns.cakelampvm.com" +# the name of the mail server for a new domain (should already be configured). +export MAIL_SERVER="mail.cakelampvm.com" +# the distribution name to be listed in info for the new domain or subdomain. +export DISTRO="ubuntu" #### diff --git a/scripts/site_avenger/powerup.sh b/scripts/site_avenger/powerup.sh index c67bd25a..c2ed28d5 100644 --- a/scripts/site_avenger/powerup.sh +++ b/scripts/site_avenger/powerup.sh @@ -63,18 +63,18 @@ source "$WORKDIR/shared_site_mgr.sh" sep -check_application_dir "$APPLICATION_DIR" +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 "$APPLICATION_DIR" + find_app_folder "$BASE_APPLICATION_PATH" else - test_app_folder "$APPLICATION_DIR" "$app_dirname" + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" fi # where we expect to find our checkout folder underneath. -full_app_dir="$APPLICATION_DIR/$app_dirname" +full_app_dir="$BASE_APPLICATION_PATH/$app_dirname" # use our default values for the repository and theme if they're not provided. if [ -z "$repo_name" ]; then @@ -110,8 +110,8 @@ sep #if [ ! -z "$user_name" ]; then # echo "Chowning the apps folder to be owned by: $user_name" ##hmmm: have to hope for now for standard group named after user -# chown -R "$user_name:$user_name" "$APPLICATION_DIR" -# test_or_die "Chowning $APPLICATION_DIR to be owned by $user_name" +# chown -R "$user_name:$user_name" "$BASE_APPLICATION_PATH" +# test_or_die "Chowning $BASE_APPLICATION_PATH to be owned by $user_name" #fi sep diff --git a/scripts/site_avenger/sitepush.sh b/scripts/site_avenger/sitepush.sh index 79156ea2..1336a891 100644 --- a/scripts/site_avenger/sitepush.sh +++ b/scripts/site_avenger/sitepush.sh @@ -19,18 +19,18 @@ source "$WORKDIR/shared_site_mgr.sh" sep -check_application_dir "$APPLICATION_DIR" +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 "$APPLICATION_DIR" + find_app_folder "$BASE_APPLICATION_PATH" else - test_app_folder "$APPLICATION_DIR" "$app_dirname" + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" fi # where we expect to find our checkout folder underneath. -full_app_dir="$APPLICATION_DIR/$app_dirname" +full_app_dir="$BASE_APPLICATION_PATH/$app_dirname" # use our default values for the repository and theme if they're not provided. if [ -z "$repo_name" ]; then diff --git a/scripts/site_avenger/siteup.sh b/scripts/site_avenger/siteup.sh index a63744be..282d0cdc 100644 --- a/scripts/site_avenger/siteup.sh +++ b/scripts/site_avenger/siteup.sh @@ -19,18 +19,18 @@ source "$WORKDIR/shared_site_mgr.sh" sep -check_application_dir "$APPLICATION_DIR" +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 "$APPLICATION_DIR" + find_app_folder "$BASE_APPLICATION_PATH" else - test_app_folder "$APPLICATION_DIR" "$app_dirname" + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" fi # where we expect to find our checkout folder underneath. -full_app_dir="$APPLICATION_DIR/$app_dirname" +full_app_dir="$BASE_APPLICATION_PATH/$app_dirname" # use our default values for the repository and theme if they're not provided. if [ -z "$repo_name" ]; then diff --git a/scripts/site_avenger/standup.sh b/scripts/site_avenger/standup.sh index ae64d2b8..7752c59c 100644 --- a/scripts/site_avenger/standup.sh +++ b/scripts/site_avenger/standup.sh @@ -57,14 +57,14 @@ source "$WORKDIR/shared_site_mgr.sh" sep -check_application_dir "$APPLICATION_DIR" +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 "$APPLICATION_DIR" + find_app_folder "$BASE_APPLICATION_PATH" else - test_app_folder "$APPLICATION_DIR" "$app_dirname" + test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname" fi #echo "!! domain being added is: $DOMAIN_NAME" diff --git a/scripts/system/add_apache_site.sh b/scripts/system/add_apache_site.sh index 57b5d519..203b0ebd 100644 --- a/scripts/system/add_apache_site.sh +++ b/scripts/system/add_apache_site.sh @@ -10,8 +10,12 @@ source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh" # some convenient defaults for our current usage. -BASE_PATH="$HOME/apps" -STORAGE_SUFFIX="/public" +if [ -z "$BASE_APPLICATION_PATH" ]; then + BASE_APPLICATION_PATH="$HOME/apps" +fi +if [ -z "$STORAGE_SUFFIX" ]; then + STORAGE_SUFFIX="/public" +fi # this function writes out the new configuration file for the site. function write_apache_config() @@ -39,7 +43,7 @@ function write_apache_config() if [ -z "$site_path" ]; then # path where site gets checked out, in some arcane manner, and which happens to be # above the path where we put webroot (in the storage suffix, if defined). - local path_above="${BASE_PATH}/${appname}" + local path_above="${BASE_APPLICATION_PATH}/${appname}" # no slash between appname and suffix, in case suffix is empty. local full_path="${path_above}${STORAGE_SUFFIX}" #echo really full path is $full_path @@ -106,8 +110,8 @@ function restart_apache() function maybe_create_site_storage() { local our_app="$1"; shift - # make sure the base path for storage of all the apps for this user exists. - local full_path="$BASE_PATH/$our_app" + # make sure the path for storage this app exists for the user. + local full_path="$BASE_APPLICATION_PATH/$our_app" if [ ! -d "$full_path" ]; then mkdir -p $full_path test_or_die "The app storage path could not be created.\n Path in question is: $full_path" @@ -151,7 +155,7 @@ This script needs to know (1) the application name for the new site and appropriate name for a file-system compatible folder name. There is an optional third parameter (3) the path for site storage. If the site path is not provided, we'll use this path: - $BASE_PATH/{app name}/$STORAGE_SUFFIX" + $BASE_APPLICATION_PATH/{app name}/$STORAGE_SUFFIX" exit 1 fi diff --git a/scripts/system/add_domain.sh b/scripts/system/add_domain.sh index 80ebb2f3..9a524f4e 100644 --- a/scripts/system/add_domain.sh +++ b/scripts/system/add_domain.sh @@ -14,19 +14,28 @@ export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )" source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh" # some defaults that are convenient for current purposes. +# existing values will be respected over our defaults. -# hmmm: !!! these would need to be parameterized somehow for this script to become really general. - -# in our scheme, the single IP address that all our domains map to. -IP_ADDRESS="10.28.42.20" -# the email address (where first dot is replaced by @) for the administrator of the domain. -SERVER_ADMIN="developer.cakelampvm.com" -# the name of the name server for the new domains (should already be configured). -MAIN_NAME_SERVER="ns.cakelampvm.com" -# the name of the mail server for a new domain (should already be configured). -MAIL_SERVER="mail.cakelampvm.com" -# the distribution name to be listed in info for the new domain or subdomain. -DISTRO="ubuntu" +if [ -z "$IP_ADDRESS" ]; then + # in our scheme, the single IP address that all our domains map to. + IP_ADDRESS="10.28.42.20" +fi +if [ -z "$SERVER_ADMIN" ]; then + # the email address (where first dot is replaced by @) for the administrator of the domain. + SERVER_ADMIN="developer.cakelampvm.com" +fi +if [ -z "$MAIN_NAME_SERVER" ]; then + # the name of the name server for the new domains (should already be configured). + MAIN_NAME_SERVER="ns.cakelampvm.com" +fi +if [ -z "$MAIL_SERVER" ]; then + # the name of the mail server for a new domain (should already be configured). + MAIL_SERVER="mail.cakelampvm.com" +fi +if [ -z "$DISTRO" ]; then + # the distribution name to be listed in info for the new domain or subdomain. + DISTRO="ubuntu" +fi # creates a totally new domain config file for DNS. function write_new_domain_file() -- 2.34.1