public function getFileMd5($file)
{
$cmd[] = "test -f /usr/bin/md5sum && md5sum {$file}";
$command = join(' && ', $cmd);
if (Project::getAnsibleStatus()) {
// ansible 并发执行远程命令
return $this->runRemoteCommandByAnsibleShell($command);
} else {
return $this->runRemoteCommand($command);
}
}
/** * 获取线上文件md5 * * @param $projectId */ public function actionFileMd5($projectId, $file) { // 配置 $this->conf = Project::getConf($projectId); $cmd = new Folder(); $cmd->setConfig($this->conf); $projectDir = $this->conf->release_to; $file = sprintf("%s/%s", rtrim($projectDir, '/'), $file); $cmd->getFileMd5($file); $log = $cmd->getExeLog(); $this->renderJson(join("<br>", explode(PHP_EOL, $log))); }