added shadow site and more vamps
[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 $(basename $0 .sh) will completely set up a web site, including a domain
23 name and an apache configuration file.  The site will be acquired from a
24 git repository and configured.  At the end of this script, the result should 
25 be an almost working website; you may need to fix the site configuration,
26 create databases and so forth.
27
28 This script must be run as sudo or root; it makes changes to system files.
29 app name: The app name parameter is mandatory.  The configuration file for
30 this script will be derived from the app name (e.g. if the app name is MyApp,
31 then the config file will be 'MyApp.config').  The config files are by
32 convention stored in the 'config' directory.  The configuration file can be
33 overridden by setting the SITE_MANAGEMENT_CONFIG_FILE environment variable."
34   exit 0
35 }
36
37 ############################
38
39 # main body of script.
40
41 # check for parameters.
42 app_dirname="$1"; shift
43
44 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
45   print_instructions
46 elif [ -z "$app_dirname" ]; then
47   print_instructions
48 fi
49
50 # force the sudo at the start of the script, rather than waiting halfway
51 # through to ask for access.
52 sudo bash -c 'echo sudo permissions acquired.'
53
54 source "$WORKDIR/shared_site_mgr.sh"
55
56 sep
57
58 check_application_dir "$BASE_APPLICATION_PATH"
59
60 # find proper webroot where the site will be initialized.
61 if [ -z "$app_dirname" ]; then
62   # no dir was passed, so guess it.
63   find_app_folder "$BASE_APPLICATION_PATH"
64 else
65   test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname"
66 fi
67
68 #echo "!! domain being added is: $DOMAIN_NAME"
69
70 sudo bash "$FEISTY_MEOW_SCRIPTS/system/add_domain.sh" "$DOMAIN_NAME"
71 test_or_die "Setting up domain: $DOMAIN_NAME"
72
73 sep
74
75 # add the main website as specified by the domain name they gave us.
76 sudo bash "$FEISTY_MEOW_SCRIPTS/system/add_apache_site.sh" "$APPLICATION_NAME" "$DOMAIN_NAME"
77 test_or_die "Setting up apache site for: $APPLICATION_NAME"
78
79 # make the shadow site also, which always ends in cakelampvm.com.
80 shadow_domain="${APPLICATION_NAME}.cakelampvm.com"
81 if [ "$shadow_domain" != "$DOMAIN_NAME" ]; then
82   sudo bash "$FEISTY_MEOW_SCRIPTS/system/add_apache_site.sh" "$APPLICATION_NAME" "$shadow_domain"
83   test_or_die "Setting up shadow apache site on '$shadow_domain'"
84 fi
85
86 sep
87
88 #echo about to do powerup with: app="$APPLICATION_NAME" repo="$REPO_NAME" theme="$THEME_NAME"
89 #echo default repo is "$DEFAULT_REPOSITORY_ROOT" 
90
91 powerup "$APPLICATION_NAME" "$REPO_NAME" "$THEME_NAME"
92 # pass the real user name who should own the files.
93 # "$(logname)"
94
95 sep
96
97 echo "
98 Finished standing up the full domain and site for: ${app_dirname}
99 The domain name is: $DOMAIN_NAME
100 "
101