app\components\Folder::getFileMd5 PHP Method

getFileMd5() public method

获取文件的MD5
public getFileMd5 ( $file ) : boolean
$file
return boolean
    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);
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 获取线上文件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)));
 }