@@ -5,27 +5,18 @@ usage ()
55{
66 cat << EOT
77
8- ${0##*/ }
9- Searches the Config/ folder for any files matching the pattern
8+ ${0##*/ }
9+ Searches the Config/ folder for any files matching the pattern
1010 *.ENV.* and copies them to the same file name minus ".ENV". Should
1111 be run from the project root folder.
12-
12+
1313 For example, where ENV="prod":
1414 Config/core.prod.php -> Config/core.php
1515 Config/database.prod.php -> Config/database.php
1616
17- Note that "dashed" config files are loaded in place, not renamed.
18- So core-dev.php should be loaded by core.php when the APP_ENV=dev,
19- but this script would have to be used to copy core.dev.php to
20- core.php. The two methods are not entirely compatible since
21- core.php is probably configured to load core-dev.php in the former
22- case but would be overwritten by core.dev.php in the latter.
23-
24-
2517Usage:
26- bin/${0##*/ } [ ENV]
18+ bin/${0##*/ } < ENV>
2719
28- \$ 1 = Environment name for which to load configs. Default: $APP_ENV .
2920
3021EOT
3122
3728
3829
3930DIR=" $( cd -P " $( dirname " $0 " ) " /.. > /dev/null 2>&1 && pwd ) "
40- CONFIG_DIR=" $DIR /Config" ;
31+ APP_DIR=" ${DIR} "
32+ CONFIG_DIR=" ${APP_DIR} /Config" ;
4133
42- # Copy config files in place
34+ # Select the correct env, first from command line, then environment,
35+ # then default to production.
4336if [ $1 ]; then
4437 ARG_ENV=$1 ;
38+ elif [ -n " $APP_ENV " ]; then
39+ ARG_ENV=$APP_ENV ;
4540else
46- ARG_ENV=" $APP_ENV " ;
41+ ARG_ENV=" prod " ;
4742fi
4843
44+ # Copy config files in place.
4945echo " ## Copying config files into place for environment: $ARG_ENV " ;
5046for CFG_FILE in $( ls -1 ${CONFIG_DIR} | grep -F " .${ARG_ENV} ." ) ; do
5147 cp -fv ${CONFIG_DIR} /${CFG_FILE} ${CONFIG_DIR} /${CFG_FILE/ \. ${ARG_ENV} / } | sed " s|${DIR} \/||g"
0 commit comments