added shadow site and more vamps
[feisty_meow.git] / scripts / site_avenger / teardown.sh
1 #!/bin/bash
2
3 # this performs the inverse operation of standup, by relying on the
4 # remove_domain and remove_apache_site scripts.
5 #
6 # Author: Chris Koeritz
7
8 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
9 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
10
11 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
12
13 ############################
14
15 function print_instructions()
16 {
17   echo
18   echo "$(basename $0 .sh) {app name}"
19   echo
20   echo "
21 $(basename $0 .sh) will drop a web site out of apache server and out of the
22 DNS server, as if it never existed.  The site storage is left untouched; we
23 don't know what valuable assets lurk there.
24 This script must be run as sudo or root; it makes changes to system files.
25 "
26   exit 0
27 }
28
29 ############################
30
31 # main body of script.
32
33 # check for parameters.
34 app_dirname="$1"; shift
35
36 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
37   print_instructions
38 elif [ -z "$app_dirname" ]; then
39   print_instructions
40 fi
41
42 # force the sudo at the start of the script, rather than waiting halfway
43 # through to ask for access.
44 sudo bash -c 'echo sudo permissions acquired.'
45
46 source "$WORKDIR/shared_site_mgr.sh"
47
48 sep
49
50 check_application_dir "$BASE_APPLICATION_PATH"
51
52 # find proper webroot where the site will be initialized.
53 if [ -z "$app_dirname" ]; then
54   # no dir was passed, so guess it.
55   find_app_folder "$BASE_APPLICATION_PATH"
56 else
57   test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname"
58 fi
59
60 sep
61
62 sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_apache_site.sh" "$DOMAIN_NAME"
63 test_or_die "dropping apache site for: $DOMAIN_NAME"
64
65 # drop the shadow site too.
66 shadow_domain="${APPLICATION_NAME}.cakelampvm.com"
67 if [ "$shadow_domain" != "$DOMAIN_NAME" ]; then
68   sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_apache_site.sh" "$shadow_domain"
69   test_or_die "dropping shadow apache site on '$shadow_domain'"
70 fi
71
72 sep
73
74 #echo "!! domain being removed is: $DOMAIN_NAME"
75
76 sudo bash "$FEISTY_MEOW_SCRIPTS/system/remove_domain.sh" "$DOMAIN_NAME"
77 test_or_die "dropping domain: $DOMAIN_NAME"
78
79 sep
80
81 echo "
82 Finished tearing down the domain name and apache site for:
83   $DOMAIN_NAME
84 "
85