git-hacks

git-hacks Commit Details

Date:2014-09-10 15:39:49 (3 years 7 months ago)
Author:Nicola Fontana
Branch:master
Commit:98e052469b2404e84d32ebc9ef37da407cee7c2b
Parents: 89437b1a3e12303e92bb48c3f889baa89fa14575
Message:gitdeploy: try to improve portability

Disabling the cache does not work anymore with SilverStripe 3.1. Try to
improve the script portability by providing an environment similar to
the one effectively used for the web, i.e. change the current directory
to the one used by the web server.
Changes:
Mgitdeploy (2 diffs)

File differences

gitdeploy
1111
1212
1313
14
14
1515
1616
1717
1818
19
19
2020
2121
2222
......
6969
7070
7171
72
72
7373
74
75
76
77
78
79
74
75
8076
8177
8278
8379
8480
85
81
82
8683
8784
8885
86
8987
9088
9189
# EXAMPLE:
# In the remote repository, create two hooks:
#
# #! /bin/sh
# #!/bin/sh
# # pre-receive hook
# source /path/to/gitdeploy /var/vhosts/mysite silverstripe
# public2remote
#
# #! /bin/sh
# #!/bin/sh
# # post-receive hook
# source /path/to/gitdeploy /var/vhosts/mysite silverstripe
# remote2public
local code cfg type server username password database
local php="
define('BASE_PATH', realpath('$dir'));
define('BASE_PATH', realpath('.'));
define('FRAMEWORK_DIR', file_exists(BASE_PATH . '/framework') ? 'framework' : 'sapphire');
define('TEMP_FOLDER', '/tmp');
set_include_path(BASE_PATH . '/' . FRAMEWORK_DIR . PATH_SEPARATOR . get_include_path());
// Disable cache entirely
require_once('cache/Cache.php');
SS_Cache::add_backend('default', 'black_hole');
require_once('core/Core.php');
//define('TEMP_FOLDER', '/tmp');
require_once(BASE_PATH . '/' . FRAMEWORK_DIR . '/core/Core.php');
foreach (\$databaseConfig as \$k => \$v) {
\$v = addcslashes(\$v, '\\'');
echo \"\$k='\$v'\n\";
}"
for cfg in "$dir"/*/_config.php; do
cd "$dir"
for cfg in */_config.php; do
code=$(php -r "$php" 2>/dev/null)
[ "$?" = "0" ] && eval "$code" && [ -n "$database" ] && break
done
cd - >/dev/null
if [ -z "$server" -o -z "$username" -o -z "$password" -o -z "$database" ]; then
return 1

Archive Download the corresponding diff file

Branches