add git source: HIT
parent
eddc938bdd
commit
e9681f5595
|
@ -80,10 +80,8 @@ function GetPathSetting($event, $context)
|
||||||
|
|
||||||
function getConfig($str, $disktag = '')
|
function getConfig($str, $disktag = '')
|
||||||
{
|
{
|
||||||
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
global $slash;
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') {
|
if ($configs!='') {
|
||||||
|
@ -108,9 +106,8 @@ function setConfig($arr, $disktag = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
global $slash;
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') $envs = json_decode($configs, true);
|
if ($configs!='') $envs = json_decode($configs, true);
|
||||||
|
@ -422,7 +419,6 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
|
|
||||||
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
{
|
{
|
||||||
global $slash;
|
|
||||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||||
else {
|
else {
|
||||||
|
@ -465,8 +461,8 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') $tmp_env = json_decode($configs, true);
|
if ($configs!='') $tmp_env = json_decode($configs, true);
|
||||||
|
@ -521,39 +517,24 @@ function setConfigResponse($response)
|
||||||
return json_decode( $response, true );
|
return json_decode( $response, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取解压出的目录名
|
// 获取解压出的目录名
|
||||||
/*
|
$outPath = findIndexPath($outPath);
|
||||||
@ob_start();
|
|
||||||
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
|
||||||
$html.='状态:' . $stat . '
|
|
||||||
结果:
|
|
||||||
';
|
|
||||||
$archivefolder = ob_get_clean();
|
|
||||||
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
|
||||||
$outPath .= $archivefolder;
|
|
||||||
$html.=htmlspecialchars($archivefolder);
|
|
||||||
//return $html;
|
|
||||||
*/
|
|
||||||
$tmp = scandir($outPath);
|
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 放入配置文件
|
// 放入配置文件
|
||||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
||||||
|
@ -588,7 +569,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -598,6 +579,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define("BasicDateFormat", "Ymd\THis\Z");
|
define("BasicDateFormat", "Ymd\THis\Z");
|
||||||
define("Algorithm", "SDK-HMAC-SHA256");
|
define("Algorithm", "SDK-HMAC-SHA256");
|
||||||
define("HeaderXDate", "X-Sdk-Date");
|
define("HeaderXDate", "X-Sdk-Date");
|
||||||
|
|
Loading…
Reference in New Issue