very tasty changes indeed
[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 source "$WORKDIR/shared_site_mgr.sh"
12
13 ############################
14
15 function print_instructions()
16 {
17   echo
18   echo "$(basename $0 .sh) {app name}"
19   echo
20   echo "
21 app name: The app name parameter is mandatory.  The configuration file for
22 this script will be derived from the app name (e.g. if the app name is MyApp,
23 then the config file will be 'MyApp.config').  The config files are by
24 convention stored in the 'config' directory.  The configuration file can be
25 overridden by setting the SITE_MANAGEMENT_CONFIG_FILE environment variable."
26   exit 0
27 }
28
29 ############################
30
31 # main body of script.
32
33 # check for parameters.
34 app_dirname="$1"; shift
35 repo_name="$1"; shift
36 theme_name="$1"; shift
37
38 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
39   print_instructions
40 fi
41
42 sep
43
44 check_application_dir "$APPLICATION_DIR"
45
46 # find proper webroot where the site will be initialized.
47 if [ -z "$app_dirname" ]; then
48   # no dir was passed, so guess it.
49   find_app_folder "$APPLICATION_DIR"
50 else
51   test_app_folder "$APPLICATION_DIR" "$app_dirname"
52 fi
53
54 # where we expect to find our checkout folder underneath.
55 full_app_dir="$APPLICATION_DIR/$app_dirname"
56
57 # use our default values for the repository and theme if they're not provided.
58 if [ -z "$repo_name" ]; then
59   repo_name="$app_dirname"
60 fi
61 if [ -z "$theme_name" ]; then
62   theme_name="$(capitalize_first_char ${app_dirname})"
63 fi
64
65 echo "Repository: $repo_name"
66 echo "Theme name: $theme_name"
67 sep
68
69 # this should set the site_store_path variable if everything goes well.
70 update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name"
71 test_or_die "Updating the repository storage directory"
72
73 # update the site to load dependencies.
74 sep
75 composer_repuff "$site_store_path"
76 test_or_die "Installing site dependencies with composer"
77
78 # set up the symbolic links needed to achieve siteliness.
79 sep
80
81 create_site_links "$site_store_path" "$theme_name"
82
83 sep
84
85 echo "Finished powering up the site in '${app_dirname}'."
86