bc109031138fbc3544cb6eb7c9f4e5d5f034e8fd
[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 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
11
12 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
13
14 ############################
15
16 function print_instructions()
17 {
18   echo
19   echo "$(basename $0 .sh) {app name}"
20   echo
21   echo "
22 app name: The app name parameter is mandatory.  The configuration file for
23 this script will be derived from the app name (e.g. if the app name is MyApp,
24 then the config file will be 'MyApp.config').  The config files are by
25 convention stored in the 'config' directory.  The configuration file can be
26 overridden by setting the SITE_MANAGEMENT_CONFIG_FILE environment variable."
27   exit 0
28 }
29
30 ############################
31
32 # main body of script.
33
34 # check for parameters.
35 app_dirname="$1"; shift
36
37 if (( $EUID != 0 )); then
38   echo "This script must be run as root or sudo."
39   exit 1
40 fi
41
42 if [ -z "$app_dirname" ]; then
43   print_instructions
44 fi
45
46 source "$WORKDIR/shared_site_mgr.sh"
47
48 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
49   print_instructions
50 fi
51
52 sep
53
54 check_application_dir "$APPLICATION_DIR"
55
56 add_domain "$DOMAIN_NAME"
57 test_or_die "Setting up domain: $DOMAIN_NAME"
58
59 sep
60
61 add_apache_site "$APPLICATION_NAME" "$DOMAIN_NAME"
62 test_or_die "Setting up apache site for: $APPLICATION_NAME"
63
64 sep
65
66 powerup "$APPLICATION_NAME" "$REPO_NAME" "$THEME_NAME"
67
68 sep
69
70 echo "
71 Finished standing up the full domain and site in:
72 ${app_dirname}"
73