Merge branch 'release-2.140.93'
[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 [ -z "$app_dirname" ]; then
35   print_instructions
36 fi
37
38 source "$WORKDIR/shared_site_mgr.sh"
39
40 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
41   print_instructions
42 fi
43
44 sep
45
46 check_application_dir "$APPLICATION_DIR"
47
48 add_domain "$DOMAIN_NAME"
49 test_or_die "Setting up domain: $DOMAIN_NAME"
50
51 add_apache_site "$APPLICATION_NAME" "$DOMAIN_NAME"
52 test_or_die "Setting up apache site for: $APPLICATION_NAME"
53
54 powerup "$APPLICATION_NAME" "$REPO_NAME" "$THEME_NAME"
55
56
57
58
59
60 sep
61
62 echo "
63 Finished standing up the full domain and site in:
64 ${app_dirname}"
65
66 #leave before old crud below
67 exit 0
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 #below is probably not needed.
89 # find proper webroot where the site will be initialized.
90 if [ -z "$app_dirname" ]; then
91   # no dir was passed, so guess it.
92   find_app_folder "$APPLICATION_DIR"
93 else
94   test_app_folder "$APPLICATION_DIR" "$app_dirname"
95 fi
96
97 # where we expect to find our checkout folder underneath.
98 full_app_dir="$APPLICATION_DIR/$app_dirname"
99
100 # use our default values for the repository and theme if they're not provided.
101 if [ -z "$repo_name" ]; then
102   repo_name="$app_dirname"
103 fi
104 if [ -z "$theme_name" ]; then
105   theme_name="$(capitalize_first_char ${app_dirname})"
106 fi
107
108 echo "Repository: $repo_name"
109 echo "Theme name: $theme_name"
110 sep
111
112 # this should set the site_store_path variable if everything goes well.
113 update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name"
114 test_or_die "Updating the repository storage directory"
115
116 # update the site to load dependencies.
117 sep
118 composer_repuff "$site_store_path"
119 test_or_die "Installing site dependencies with composer"
120
121 # set up the symbolic links needed to achieve siteliness.
122 sep
123
124 create_site_links "$site_store_path" "$theme_name"
125
126 sep
127
128 echo "Finished powering up the site in '${app_dirname}'."
129