|
|
@@ -195,26 +195,35 @@ jQuery(document).ready(function () {
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
- $this->_gitResetHard($appLicenceInfo);
|
|
|
+ if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
+ if (empty($appLicenceInfo->installPath)) throw new Exception("Install path not found");
|
|
|
+ UI::startContainer();
|
|
|
+ $this->gitResetHard($appLicenceInfo->installPath);
|
|
|
+ UI::endContainer();
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
- public function _gitResetHard($appLicenceInfo) {
|
|
|
- if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
- if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
- $installPath = $appLicenceInfo->installPath;
|
|
|
+ public function gitResetHard($installPath) {
|
|
|
if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
$cmds = array();
|
|
|
- $cmds[] = "cd {$installPath} && git reset --hard";
|
|
|
- $cmds[] = "cd {$installPath} && git pull";
|
|
|
- $cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
+ $cmds[] = "git reset --hard";
|
|
|
+ $cmds[] = "git pull";
|
|
|
+ $cmds[] = "echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
+ $hasError = false;
|
|
|
foreach ($cmds as $cmd) {
|
|
|
$out = ''; $ret = '';
|
|
|
- exec($cmd, $out, $ret);
|
|
|
- echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
+ exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ if (0 !== $ret) $hasError = true;
|
|
|
+ DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
|
|
|
+ }
|
|
|
+ if (!$hasError) {
|
|
|
+ UI::alert('success', "OK");
|
|
|
+ } else {
|
|
|
+ UI::alert('danger', "errors");
|
|
|
}
|
|
|
}
|
|
|
|