fb915d7e7bce887981756ccbfeba1bb4e8d1ea69
[feisty_meow.git] / scripts / system / remove_apache_site.sh
1 #!/bin/bash
2
3 # uninstalls the apache website for a specified domain.
4
5 # auto-find the scripts, since we might want to run this as sudo.
6 export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
7 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
8
9 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
10 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
11
12 # some convenient defaults for our current usage.
13
14 if [ -z "$BASE_APPLICATION_PATH" ]; then
15   BASE_APPLICATION_PATH="$HOME/apps"
16 fi
17 if [ -z "$STORAGE_SUFFIX" ]; then
18   STORAGE_SUFFIX="/public"
19 fi
20
21 # main body of script.
22
23 if [[ $EUID != 0 ]]; then
24   echo "This script must be run as root or sudo."
25   exit 1
26 fi
27
28 appname="$1"; shift
29 site="$1"; shift
30 site_path="$1"; shift
31
32 if [ -z "$appname" -o -z "$site" ]; then
33 #hmmm: move to a print_instructions function.
34   echo "
35 $(basename $0): {app name} 
36
37 This script needs to know (1) the application name for the site and
38 (2) the DNS name for the apache virtual host.  The appname should be an
39 appropriate name for a file-system compatible folder name.
40 The script will uninstall that site's configuration files for apache2.
41 "
42   exit 1
43 fi
44
45 disable_site "$site"
46 remove_apache_config "$appname" "$site"
47 restart_apache
48