X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fsite_avenger%2Fteardown.sh;h=5bfcbd4699b9a01696af8f4a85ebd8e6b9bb2252;hb=6d4552cd3fca6d9c2f38f96bd2f7fde8d54c3bf2;hp=b72aa8e0fff5a5e5d1ed7a356262de225604dbb1;hpb=c53d13827ddead7cdc1c959890829296a0e7f0f4;p=feisty_meow.git diff --git a/scripts/site_avenger/teardown.sh b/scripts/site_avenger/teardown.sh index b72aa8e0..5bfcbd46 100644 --- a/scripts/site_avenger/teardown.sh +++ b/scripts/site_avenger/teardown.sh @@ -1,12 +1,85 @@ #!/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" + +# drop the shadow site too. +shadow_domain="${APPLICATION_NAME}.cakelampvm.com" +if [ "$shadow_domain" != "$DOMAIN_NAME" ]; then + sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_apache_site.sh" "$shadow_domain" + test_or_die "dropping shadow apache site on '$shadow_domain'" +fi + +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 +"