ee4a0026e7f613ba091b9ef1dca6ece6a5c066b4
[feisty_meow.git] / scripts / site_avenger / standup.sh
1 #!/bin/bash
2
3 # Author: Chris Koeritz
4
5 # This is the full orchestrator for bringing up a web site using our site
6 # management scripts.  So far, the scripts rely on at least php.  The support
7 # is much more powerful if the site is based on cakephp and site avenger.
8
9 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
10
11 ############################
12
13 function print_instructions()
14 {
15   echo
16   echo "$(basename $0 .sh) {app name}"
17   echo
18   echo "
19 app name: The app name parameter is mandatory.  The configuration file for
20 this script will be derived from the app name (e.g. if the app name is MyApp,
21 then the config file will be 'MyApp.config').  The config files are by
22 convention stored in the 'config' directory.  The configuration file can be
23 overridden by setting the SITE_MANAGEMENT_CONFIG_FILE environment variable."
24   exit 0
25 }
26
27 ############################
28
29 # main body of script.
30
31 # check for parameters.
32 app_dirname="$1"; shift
33
34 if (( $EUID != 0 )); then
35   echo "This script must be run as root or sudo."
36   exit 1
37 fi
38
39 if [ -z "$app_dirname" ]; then
40   print_instructions
41 fi
42
43 source "$WORKDIR/shared_site_mgr.sh"
44
45 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
46   print_instructions
47 fi
48
49 sep
50
51 check_application_dir "$APPLICATION_DIR"
52
53 add_domain "$DOMAIN_NAME"
54 test_or_die "Setting up domain: $DOMAIN_NAME"
55
56 add_apache_site "$APPLICATION_NAME" "$DOMAIN_NAME"
57 test_or_die "Setting up apache site for: $APPLICATION_NAME"
58
59 powerup "$APPLICATION_NAME" "$REPO_NAME" "$THEME_NAME"
60
61 sep
62
63 echo "
64 Finished standing up the full domain and site in:
65 ${app_dirname}"
66