|
|
@@ -312,4 +312,40 @@ class V {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public function exec($cmd, &$out, &$ret) {
|
|
|
+ $out = null;
|
|
|
+ $ret = null;
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function execRemote($host, $login, $password, $command, &$out, &$ret) {
|
|
|
+ $out = null;
|
|
|
+ $ret = null;
|
|
|
+ $pass = $password;
|
|
|
+ $pass = str_replace('!', '\!', $pass);
|
|
|
+ $cmd = '/opt/local/bin/sshpass -p ' . $pass . ' ssh -o StrictHostKeyChecking=no -o ConnectTimeout=99999 ' . $login . '@' . $host . ' -t <<EOF
|
|
|
+declare PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/lib/mysql55/bin/:/Applications/Server.app/Contents/ServerRoot/usr/sbin/
|
|
|
+
|
|
|
+'.$command.'
|
|
|
+
|
|
|
+EOF';
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function execRootRemote($host, $login, $password, $command, &$out, &$ret) {
|
|
|
+ $out = null;
|
|
|
+ $ret = null;
|
|
|
+ $cmd = '/opt/local/bin/sshpass -p '.str_replace('!','\!',$password).' ssh -o StrictHostKeyChecking=no -o ConnectTimeout=99999 '.$login.'@'.$host.' -t <<EOF
|
|
|
+sudo -n su -
|
|
|
+declare PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/lib/mysql55/bin/:/Applications/Server.app/Contents/ServerRoot/usr/sbin/
|
|
|
+
|
|
|
+'.$command.'
|
|
|
+
|
|
|
+EOF';
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
}
|