Skip to content

Commit cfcede5

Browse files
committed
Merge branch 'rsync_and_run_local'
2 parents 0a0a089 + e7cd750 commit cfcede5

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/Pomander.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function run()
8080
$cmd = implode(" && ",$cmd);
8181
$app = builder()->get_application();
8282

83-
list($status, $output) = !isset($app->env)? exec_cmd($cmd) : $app->env->exec($cmd);
83+
list($status, $output) = !isset($app->env)? run_local($cmd) : $app->env->exec($cmd);
8484
if(!$silent && count($output)) puts(implode("\n", $output));
8585

8686
if($status > 0)
@@ -98,23 +98,29 @@ function run()
9898
return $output;
9999
}
100100

101-
function exec_cmd($cmd)
101+
function run_local($cmd)
102102
{
103103
$cmd = is_array($cmd)? implode(" && ",$cmd) : $cmd;
104104
exec($cmd, $output, $status);
105-
return array($status, $output);
105+
return array($status, $output);
106+
}
107+
108+
// Deprecated: use run_local()
109+
function exec_cmd($cmd)
110+
{
111+
return run_local($cmd);
106112
}
107113

108114
function put($what,$where)
109115
{
110116
if(!isset(builder()->get_application()->env))
111-
return exec_cmd("cp -R $what $where");
117+
return run_local("cp -R $what $where");
112118
builder()->get_application()->env->put($what,$where);
113119
}
114120

115121
function get($what,$where)
116122
{
117123
if(!isset(builder()->get_application()->env))
118-
return exec_cmd("cp -R $what $where");
124+
return run_local("cp -R $what $where");
119125
builder()->get_application()->env->get($what,$where);
120126
}

lib/Pomander/Environment.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function multi_role_support($role,$app)
115115

116116
public function exec($cmd)
117117
{
118-
if(!$this->target) return exec_cmd($cmd);
118+
if(!$this->target) return run_local($cmd);
119119
if(!$this->shell)
120120
{
121121
$keypass = $this->key_password;
@@ -129,19 +129,19 @@ public function exec($cmd)
129129
public function put($what,$where)
130130
{
131131
if($this->target)
132-
$cmd = "{$this->rsync_cmd} {$this->rsync_flags} $what {$this->user}@{$this->target}:$where";
132+
$cmd = "{$this->rsync_cmd} -e \"ssh -i {$this->key_path}\" {$this->rsync_flags} $what {$this->user}@{$this->target}:$where";
133133
else
134134
$cmd = "cp -r $what $where";
135-
return exec_cmd($cmd);
135+
return run_local($cmd);
136136
}
137137

138138
public function get($what,$where)
139139
{
140140
if($this->target)
141-
$cmd = "{$this->rsync_cmd} {$this->rsync_flags} {$this->user}@{$this->target}:$what $where";
141+
$cmd = "{$this->rsync_cmd} -e \"ssh -i {$this->key_path}\" {$this->rsync_flags} {$this->user}@{$this->target}:$what $where";
142142
else
143143
$cmd = "cp -r $what $where";
144-
return exec_cmd($cmd);
144+
return run_local($cmd);
145145
}
146146

147147
private function defaults()

lib/tasks/default.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
desc("Set it up");
219219
task('init', function($app) {
220220
info("init","Creating deploy directory");
221-
exec_cmd("mkdir -p ./deploy");
221+
run_local("mkdir -p ./deploy");
222222
info("init","Creating development configuration");
223223
$app->invoke("config");
224224
info("init","Done!");

0 commit comments

Comments
 (0)