From 200c9a1cf6727241b663fc21ed4fa7a25ced3fdb Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Wed, 15 Nov 2017 00:08:43 -0500 Subject: [PATCH] nice. teardown working now --- scripts/site_avenger/shared_site_mgr.sh | 2 +- scripts/site_avenger/teardown.sh | 76 +++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/scripts/site_avenger/shared_site_mgr.sh b/scripts/site_avenger/shared_site_mgr.sh index 56e658e2..3f73b3a8 100644 --- a/scripts/site_avenger/shared_site_mgr.sh +++ b/scripts/site_avenger/shared_site_mgr.sh @@ -44,7 +44,7 @@ function locate_config_file() local app_dirname="$1"; shift local configfile="$WORKDIR/config/${app_dirname}.app" -echo hoping config file would be: $configfile + echo "config file?: $configfile" if [ ! -f "$configfile" ]; then # this is not a good config file. we can't auto-guess the config. echo -e " diff --git a/scripts/site_avenger/teardown.sh b/scripts/site_avenger/teardown.sh index b72aa8e0..3e194083 100644 --- a/scripts/site_avenger/teardown.sh +++ b/scripts/site_avenger/teardown.sh @@ -1,12 +1,78 @@ #!/bin/bash -echo "sorry--this script is not implemented yet." +# this performs the inverse operation of standup, by relying on the +# remove_domain and remove_apache_site scripts. +# +# Author: Chris Koeritz +export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory. +export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )" +source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh" -# need the inverse of add_domain and add_apache_site. -# can use the same machinery as standup, just need to invoke these two new removal methods. +############################ -# the decommissioning of the app is a question though. we don't want to delete it, i'm pretty sure. -# so how about that part is to do nothing? +function print_instructions() +{ + echo + echo "$(basename $0 .sh) {app name}" + echo + echo " +$(basename $0 .sh) will drop a web site out of apache server and out of the +DNS server, as if it never existed. The site storage is left untouched; we +don't know what valuable assets lurk there. +This script must be run as sudo or root; it makes changes to system files. +" + exit 0 +} + +############################ + +# main body of script. + +# check for parameters. +app_dirname="$1"; shift + +if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then + print_instructions +elif [ -z "$app_dirname" ]; then + print_instructions +fi + +# force the sudo at the start of the script, rather than waiting halfway +# through to ask for access. +sudo bash -c 'echo sudo permissions acquired.' + +source "$WORKDIR/shared_site_mgr.sh" + +sep + +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 + +sep + +sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_apache_site.sh" "$DOMAIN_NAME" +test_or_die "dropping apache site for: $DOMAIN_NAME" + +sep + +#echo "!! domain being removed is: $DOMAIN_NAME" + +sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_domain.sh" "$DOMAIN_NAME" +test_or_die "dropping domain: $DOMAIN_NAME" + +sep + +echo " +Finished tearing down the domain name and apache site for: + $DOMAIN_NAME +" -- 2.34.1