Skip to content

Commit d6cedc0

Browse files
committed
moved optional choices from settings file to interactive prompt
1 parent 1e7d969 commit d6cedc0

File tree

3 files changed

+45
-24
lines changed

3 files changed

+45
-24
lines changed

local_mamp.php

+43-18
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/php
22
<?php
33

4-
#The following files must exist in the same directory as this-here local_mamp.php script:
4+
# INTERNAL SETTINGS ###########################################################
5+
define('MYSQL_BIN', '/Applications/MAMP/Library/bin/mysql');
6+
7+
define('STARTING_POINT_NAME_SAMPLE_CONTENT', 'standard');
8+
define('STARTING_POINT_NAME_EMPTY_CONTENT', 'blank');
9+
10+
//The following files must exist in the same directory as this-here local_mamp.php script:
511
define('FILENAME_SETTINGS', 'settings.php'); //required
612
define('FILENAME_INSTALL_C5_CLI', 'install-concrete5.php'); //required
713
define('FILENAME_ADD_TO_CONFIG', 'append_to_config_site_php.txt'); //optional (use empty string if none)
814
define('FILENAME_CLI_LOGIN', 'temp_cli_login.html'); //optional (use empty string if none)
9-
define('FILENAME_ZENDLOCALEDATA_BLACKLIST', 'remove_zend_locale_data.txt'); //required if REMOVE_NONENGLIGH_ZEND_LOCALE_DATA is TRUE
10-
11-
require(dirname(__FILE__) . '/' . FILENAME_SETTINGS);
12-
define('STARTING_POINT_NAME_SAMPLE_CONTENT', 'standard');
13-
define('STARTING_POINT_NAME_EMPTY_CONTENT', 'blank');
14-
define('MYSQL_BIN', '/Applications/MAMP/Library/bin/mysql');
15+
define('FILENAME_ZENDLOCALEDATA_BLACKLIST', 'remove_zend_locale_data.txt'); //optional (use empty string if none).
1516

1617
//Available C5 versions for installation (note that 5.5.1 was the first version to allow CLI installation).
1718
//First one in list becomes default option.
@@ -52,6 +53,15 @@
5253
);
5354

5455

56+
# LOAD USER SETTINGS ##########################################################
57+
$settings_file_path = dirname(__FILE__) . '/' . FILENAME_SETTINGS;
58+
if (!is_file($settings_file_path)) {
59+
echo "ABORTING INSTALLATION: CANNOT LOCATE SETTINGS FILE ({$settings_file_path})!\n";
60+
exit;
61+
}
62+
require($settings_file_path);
63+
64+
5565
# VALIDATE CONFIG SETTINGS ####################################################
5666
$c5_cli_script_path = dirname(__FILE__) . '/' . FILENAME_INSTALL_C5_CLI;
5767
if (!is_file($c5_cli_script_path)) {
@@ -64,6 +74,15 @@
6474
exit;
6575
}
6676

77+
$zend_locale_data_blacklist = '';
78+
if (FILENAME_ZENDLOCALEDATA_BLACKLIST !== '') {
79+
$zend_locale_data_blacklist = dirname(__FILE__) . '/' . FILENAME_ZENDLOCALEDATA_BLACKLIST;
80+
if (!is_file($zend_locale_data_blacklist)) {
81+
echo "ABORTING INSTALLATION: CANNOT LOCATE ZEND LOCALE DATA BLACKLIST ({$zend_locale_data_blacklist})!\n";
82+
exit;
83+
}
84+
}
85+
6786

6887
# ASK USER FOR PARAMS #########################################################
6988
system('clear');
@@ -86,9 +105,9 @@
86105
# Get target directory
87106
$htdocs_dir = '/' . trim(HTDOCS_DIR, '/') . '/';
88107
$htdocs_url = rtrim(BASE_URL, '/') . '/';
89-
$target = stdin("Enter target directory (trailing slash will be stripped):\n" . $htdocs_dir);
90-
$target_dir = $htdocs_dir . trim($target, '/');
91-
$target_url = $htdocs_url . trim($target, '/');
108+
$response = stdin("Enter target directory (trailing slash will be stripped):\n" . $htdocs_dir);
109+
$target_dir = $htdocs_dir . trim($response, '/');
110+
$target_url = $htdocs_url . trim($response, '/');
92111
if (is_dir($target_dir)) {
93112
echo "ABORTING INSTALLATION: TARGET DIRECTORY ({$target_dir}) ALREADY EXISTS!\n";
94113
exit;
@@ -104,11 +123,18 @@
104123
$site = strip_unsafe_cli_chars($site);
105124

106125
# Ask for sample content or blank
107-
$do_install_sample_content = stdin("Install C5 sample content (Y/n)?\ny/n (default y): ", false);
108-
if (strtolower($do_install_sample_content) == "n") {
109-
$starting_point = STARTING_POINT_NAME_EMPTY_CONTENT;
126+
$response = stdin("Install C5 sample content (Y/n)?\ny/n (default y): ", false);
127+
$starting_point = (strtolower($response) == "n") ? STARTING_POINT_NAME_EMPTY_CONTENT : STARTING_POINT_NAME_SAMPLE_CONTENT;
128+
129+
# Ask about optional functionality
130+
$response = stdin("Remove empty top-level folders (y/N)?\ny/n (default: n): ", false);
131+
$remove_empty_toplevel_folders = (strtolower($response) == 'y');
132+
133+
if (empty($zend_locale_data_blacklist)) {
134+
echo "Zend Locale Data: All files will remain in the installation because no blacklist file was specified.\n\n";
110135
} else {
111-
$starting_point = STARTING_POINT_NAME_SAMPLE_CONTENT;
136+
$response = stdin("Remove non-english Zend Locale Data (y/N)?\ny/n (default: n): ", false);
137+
$remove_nonengligh_zend_locale_data = (strtolower($response) == 'y');
112138
}
113139

114140

@@ -196,11 +222,10 @@
196222

197223

198224
# REMOVE NON-ENGLISH ZEND_LOCALE_DATA #########################################
199-
if (REMOVE_NONENGLIGH_ZEND_LOCALE_DATA) {
225+
if ($remove_nonengligh_zend_locale_data) {
200226
echo "Removing non-english Zend/Locale/Data files...\n";
201227

202-
$blacklist_file = dirname(__FILE__) . '/' . FILENAME_ZENDLOCALEDATA_BLACKLIST;
203-
$blacklist_contents = file_get_contents($blacklist_file);
228+
$blacklist_contents = file_get_contents($zend_locale_data_blacklist);
204229
$blacklist_contents = str_replace("\r\n", "\n", $blacklist_contents);
205230
$blacklist_contents = str_replace("\r", "\n", $blacklist_contents);
206231
$remove_filenames = explode("\n", $blacklist_contents);
@@ -216,7 +241,7 @@
216241

217242

218243
# REMOVE EMPTY TOP-LEVEL FOLDERS ##############################################
219-
if (REMOVE_EMPTY_TOPLEVEL_FOLDERS) {
244+
if ($remove_empty_toplevel_folders) {
220245
echo "Removing empty top-level folders...\n";
221246
rmdir("{$target_dir}/controllers");
222247
rmdir("{$target_dir}/css");

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This will save you a lot of time if you build sites for clients or test addons a
1111

1212
## Installing The Installer
1313
1. Fork and clone the repo to your local OSX machine, or download the files directly by clicking the "ZIP" button above (then unzip the download).
14-
2. Edit the `settings.php` file and enter your database and server information (and enable optional settings if desired).
14+
2. Edit the `settings.php` file and enter your database and server information.
1515
3. Edit the `append_to_config_site_php.txt` file and modify as needed (the contents of this file will be appended to the `config/site.php` file of installed sites) -- for example, to disable marketplace/newsflow.
1616
4. Figure out where your command-line php is installed by entering the following command in the Terminal: `which php`. If it says `/usr/bin/php`, they you're good to go. If it says something else, you'll want to change the first line in these 2 files: `install-concrete5.php` and `local_mamp.php` from `#!/usr/bin/php` to `#!/whatever/your/path/is/to/php`.
1717
5. Make the `local_mamp.php` file executable by navigating to its directory in the Terminal and entering `chmod +x ./local_mamp.php`.

settings.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
define('DB_USERNAME', 'root');
44
define('DB_PASSWORD', 'root');
55

6-
define('HTDOCS_DIR', '/Applications/MAMP/htdocs'); //Must be the top-level htdocs directory (not a subdirectory -- that can be entered later during the installation process)
6+
define('HTDOCS_DIR', '/Applications/MAMP/htdocs/'); //Must be the top-level htdocs directory (not a subdirectory -- that can be entered later during the installation process)
77
define('BASE_URL', 'http://localhost:8888'); //Must be the url to the top-level htdocs directory
88

99
define('ADMIN_EMAIL', '[email protected]');
1010
define('ADMIN_PASSWORD', 'admin'); //<--DON'T USE A REAL PASSWORD! (see note below)
1111

12-
define('REMOVE_NONENGLIGH_ZEND_LOCALE_DATA', false); //If set to true, installer removes ~10MB of non-english-language files from /concrete/libraries/3rdparty/Zend/Locale/Data
13-
define('REMOVE_EMPTY_TOPLEVEL_FOLDERS', false); //If set to true, installer removes most of the empty top-level folders (/controllers, /css, /elements, /helpers, /jobs, /js, /languages, /libraries, /mail, /models, /page_types, /single_pages, /tools, /updates)
14-
15-
1612
/**
1713
* NOTE: For security purposes, the ADMIN_PASSWORD should be something generic (e.g. "admin" or "password")
1814
* because it gets sent in the url querystring to the temp login page (which will stick around in browser history).

0 commit comments

Comments
 (0)