3 # Author: Kevin Wentworth
4 # Author: Chris Koeritz
6 # This script "powers up" a cakephp site by checking out the code from the
7 # git repository and installing the composer dependencies.
8 # This script is currently highly specific to site avenger.
12 # The naming scheme here is a little complex, but it's basically this...
13 # A git repository is expected to be provided, and we will get all the code
14 # for the web site from there. The repository is expected to have a single
15 # application "name" and one or more "themes". By convention, the name
16 # and the theme are often the same, except the theme is capitalized.
17 # For example, let's say our app name is "turtle" and our theme name is "box".
18 # The repo is checked out to a folder called "~/apps/turtle".
19 # This script will want to use "turtle" as the app name.
20 # It will have to be told the theme name, but will assume it's 'Turtle' to
21 # start with. The concept of the theme comes from cakephp.
23 export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
24 export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
26 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
28 ############################
30 function print_instructions()
33 echo "$(basename $0 .sh) [app dirname] [repository] [theme name] "
36 echo "All parameters are optional, and intelligent guesses for them will be made."
38 echo "app dirname: The folder where the app will be stored."
39 echo "repository: The name of the git repository (short version, no URL)."
40 echo "theme name: The name to use for the cakephp theme."
45 ############################
47 # main body of script.
49 # check for parameters.
50 app_dirname="$1"; shift
52 theme_name="$1"; shift
54 if [ "$app_dirname" == "-help" -o "$app_dirname" == "--help" ]; then
58 source "$THISDIR/shared_site_mgr.sh"
62 check_apps_root "$app_dirname"
64 echo fixing some things here...
65 echo "apps root is now '$BASE_APPLICATION_PATH'"
66 echo " => this should be just above the app dir name if we got no parms!"
68 # find proper webroot where the site will be initialized.
69 if [ -z "$app_dirname" ]; then
70 # no dir was passed, so guess it.
71 find_app_folder "$BASE_APPLICATION_PATH"
73 test_app_folder "$BASE_APPLICATION_PATH" "$app_dirname"
75 exit_on_error "finding and testing app folder"
77 # where we expect to find our checkout folder underneath.
78 full_app_dir="$BASE_APPLICATION_PATH/$app_dirname"
80 # use our default values for the repository and theme if they're not provided.
81 if [ -z "$repo_name" ]; then
82 repo_name="$REPO_NAME"
83 if [ -z "$repo_name" ]; then
84 repo_name="$app_dirname"
87 if [ -z "$theme_name" ]; then
88 theme_name="$THEME_NAME"
89 if [ -z "$theme_name" ]; then
90 theme_name="$(capitalize_first_char ${app_dirname})"
94 echo "Repository: $repo_name"
95 echo "Theme name: $theme_name"
98 log_feisty_meow_event "in powerup before update repo with: $(var CHECKOUT_DIR_NAME DEFAULT_REPOSITORY_ROOT)"
100 # this should set the site_store_path variable if everything goes well.
101 update_repo "$full_app_dir" "$CHECKOUT_DIR_NAME" "$DEFAULT_REPOSITORY_ROOT" "$repo_name"
102 exit_on_error "Updating the repository storage directory"
104 # update the site to load dependencies.
106 composer_repuff "$site_store_path"
107 exit_on_error "Installing site dependencies with composer"
109 # set up the symbolic links needed to achieve siteliness.
112 create_site_links "$site_store_path" "$theme_name"
116 echo "Finished powering up the site in '${app_dirname}'."