Browse Source

更新升级程序

docker-svn
witersen 3 years ago
parent
commit
d9659e24ff
  1. 7
      02.php/config/update.php
  2. 95
      02.php/server/install.php
  3. 37
      02.php/server/svnadmind.php
  4. 23
      02.php/server/update.json

7
02.php/config/update.php

@ -3,7 +3,7 @@
* @Author: witersen * @Author: witersen
* @Date: 2022-04-24 23:37:06 * @Date: 2022-04-24 23:37:06
* @LastEditors: witersen * @LastEditors: witersen
* @LastEditTime: 2022-05-08 15:18:04 * @LastEditTime: 2022-05-09 00:26:12
* @Description: QQ:1801168257 * @Description: QQ:1801168257
*/ */
@ -12,7 +12,8 @@
*/ */
return [ return [
'update_server' => [ 'update_server' => [
'https://gitee.com/witersen/update/raw/master/SvnAdmin/update2.json', // 'https://gitee.com/witersen/update/raw/master/SvnAdmin/update2.json',
'https://raw.githubusercontent.com/witersen/update/master/SvnAdmin/update2.json' // 'https://raw.githubusercontent.com/witersen/update/master/SvnAdmin/update2.json',
'http://dev.witersen.com/server/update.json'
] ]
]; ];

95
02.php/server/install.php

@ -3,7 +3,7 @@
* @Author: witersen * @Author: witersen
* @Date: 2022-05-08 13:31:07 * @Date: 2022-05-08 13:31:07
* @LastEditors: witersen * @LastEditors: witersen
* @LastEditTime: 2022-05-08 23:48:45 * @LastEditTime: 2022-05-09 01:23:06
* @Description: QQ:1801168257 * @Description: QQ:1801168257
*/ */
@ -63,6 +63,7 @@ class Install
$this->config_update = Config::get('update'); $this->config_update = Config::get('update');
$this->config_version = Config::get('version'); $this->config_version = Config::get('version');
} }
/** /**
* 检测SVNAdmin的新版本并选择更新 * 检测SVNAdmin的新版本并选择更新
*/ */
@ -73,29 +74,57 @@ class Install
//获取当前版本可升级的版本信息 //获取当前版本可升级的版本信息
foreach ($this->config_update['update_server'] as $value) { foreach ($this->config_update['update_server'] as $value) {
//检测
$versionInfo = FunCurlRequest($value); $result = FunCurlRequest($value);
//未超时
if ($versionInfo != null) { if ($result == null) {
//json转换 echo '节点访问超时,切换下一节点' . PHP_EOL;
$versionInfo = json_decode($versionInfo, true); continue;
$latestVersion = $versionInfo['latestVersion']; }
if ($latestVersion == $this->config_version['version']) {
return message(200, 1, '当前版本为最新版'); //json转换
} else if ($latestVersion > $this->config_version['version']) { $result = json_decode($result, true);
return message(200, 1, '有更新', [
'latestVersion' => $versionInfo['latestVersion'], $version = $result['version'];
'fixedContent' => implode('<br>', $versionInfo['fixedContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['fixedContent']), if ($this->config_version['version'] == $version) {
'newContent' => implode('<br>', $versionInfo['newContent']) == '' ? '暂无内容' : implode('<br>', $versionInfo['newContent']), exit('当前为最新版:' . $version . PHP_EOL);
'updateType' => $versionInfo['updateType'], }
'updateStep' => $versionInfo['updateStep'] if ($this->config_version['version'] < $version) {
]); echo '有新版本:' . $version . PHP_EOL;
} else if ($latestVersion < $this->config_version['version']) {
return message(200, 0, '系统版本错误'); echo '修复内容如下:' . PHP_EOL;
foreach ($result['fixd']['con'] as $value) {
echo ' [' . $value['title'] . ']' . ' ' . $value['content'] . PHP_EOL;
}
echo '新增内容如下:' . PHP_EOL;
foreach ($result['add']['con'] as $value) {
echo ' [' . $value['title'] . ']' . ' ' . $value['content'] . PHP_EOL;
} }
echo '移除内容如下:' . PHP_EOL;
foreach ($result['remove']['con'] as $value) {
echo ' [' . $value['title'] . ']' . ' ' . $value['content'] . PHP_EOL;
}
echo "确定要升级到 $version 版本吗[y/n]:";
$answer = strtolower(trim(fgets(STDIN)));
if (!in_array($answer, ['y', 'n'])) {
exit('不正确的选项!' . PHP_EOL);
}
if ($answer == 'n') {
exit('已取消!' . PHP_EOL);
}
//下载并执行升级脚本
echo '===============================================' . PHP_EOL;
} }
} }
return message(200, 0, '检测更新超时');
} }
/** /**
@ -133,13 +162,6 @@ class Install
{ {
} }
/**
* 获取当前安装的Subversion信息
*/
function DetectSubversion()
{
}
/** /**
* 修改已经安装的Subversion配置以适合SVNAdmin的管理 * 修改已经安装的Subversion配置以适合SVNAdmin的管理
*/ */
@ -181,6 +203,8 @@ class Install
*/ */
$templete_path = BASE_PATH . '../templete/'; $templete_path = BASE_PATH . '../templete/';
echo '创建相关目录' . PHP_EOL;
//创建SVNAdmin软件配置信息的主目录 //创建SVNAdmin软件配置信息的主目录
mkdir($this->config_svn['home_path'], 0700, true); mkdir($this->config_svn['home_path'], 0700, true);
@ -196,6 +220,8 @@ class Install
//创建临时数据目录 //创建临时数据目录
mkdir($this->config_svn['home_path'], 0700, true); mkdir($this->config_svn['home_path'], 0700, true);
echo '创建相关文件' . PHP_EOL;
//写入svnserve环境变量文件 //写入svnserve环境变量文件
$con_svnserve_env_file = file_get_contents($templete_path . 'svnserve/svnserve'); $con_svnserve_env_file = file_get_contents($templete_path . 'svnserve/svnserve');
$con_svnserve_env_file = sprintf($con_svnserve_env_file, $this->config_svn['rep_base_path'], $this->config_svn['svn_conf_file'], $this->config_svn['svnserve_log_file']); $con_svnserve_env_file = sprintf($con_svnserve_env_file, $this->config_svn['rep_base_path'], $this->config_svn['svn_conf_file'], $this->config_svn['svnserve_log_file']);
@ -222,41 +248,29 @@ class Install
/** /**
* 将svnserve注册为系统服务 * 将svnserve注册为系统服务
*/ */
echo '===============================================' . PHP_EOL;
echo '清理之前注册的svnserve服务' . PHP_EOL; echo '清理之前注册的svnserve服务' . PHP_EOL;
shell_exec('systemctl stop svnserve.service'); shell_exec('systemctl stop svnserve.service');
shell_exec('systemctl disable svnserve.service'); shell_exec('systemctl disable svnserve.service');
echo '===============================================' . PHP_EOL;
$con_svnserve_service_file = file_get_contents($templete_path . 'svnserve/svnserve.service'); $con_svnserve_service_file = file_get_contents($templete_path . 'svnserve/svnserve.service');
$con_svnserve_service_file = sprintf($con_svnserve_service_file, $this->config_svn['svnserve_env_file'], trim($installPath), $this->config_svn['svnserve_pid_file']); $con_svnserve_service_file = sprintf($con_svnserve_service_file, $this->config_svn['svnserve_env_file'], trim($installPath), $this->config_svn['svnserve_pid_file']);
file_put_contents($this->config_svn['svnserve_service_file'], $con_svnserve_service_file); file_put_contents($this->config_svn['svnserve_service_file'], $con_svnserve_service_file);
//启动 //启动
echo '===============================================' . PHP_EOL;
echo '开始启动svnserve服务' . PHP_EOL; echo '开始启动svnserve服务' . PHP_EOL;
passthru('systemctl start svnserve'); passthru('systemctl start svnserve');
echo '===============================================' . PHP_EOL;
//开机自启动 //开机自启动
echo '===============================================' . PHP_EOL;
echo '将svnserve服务加入到开机自启动' . PHP_EOL; echo '将svnserve服务加入到开机自启动' . PHP_EOL;
passthru('systemctl enable svnserve'); passthru('systemctl enable svnserve');
echo '===============================================' . PHP_EOL;
//查看状态 //查看状态
echo '===============================================' . PHP_EOL;
echo 'svnserve安装成功,打印运行状态:' . PHP_EOL; echo 'svnserve安装成功,打印运行状态:' . PHP_EOL;
passthru('systemctl status svnserve'); passthru('systemctl status svnserve');
echo '===============================================' . PHP_EOL;
} }
/** /**
@ -334,6 +348,7 @@ class Install
$this->ConfigSubversion(); $this->ConfigSubversion();
} else if ($answer == 3) { } else if ($answer == 3) {
//检测SVNAdmin的新版本 //检测SVNAdmin的新版本
$this->DetectUpdate();
} }
} }
} }

37
02.php/server/svnadmind.php

@ -3,7 +3,7 @@
* @Author: witersen * @Author: witersen
* @Date: 2022-04-24 23:37:06 * @Date: 2022-04-24 23:37:06
* @LastEditors: witersen * @LastEditors: witersen
* @LastEditTime: 2022-05-08 21:45:35 * @LastEditTime: 2022-05-09 00:00:19
* @Description: QQ:1801168257 * @Description: QQ:1801168257
*/ */
@ -229,41 +229,6 @@ class Daemon
file_put_contents(BASE_PATH . '/../config/sign.php', $signCon); file_put_contents(BASE_PATH . '/../config/sign.php', $signCon);
} }
/**
* 检测升级
*/
private function SelectUpdate()
{
}
/**
* 升级到指定版本
*/
private function Update()
{
}
/**
* 安装SVNAdmin
*/
private function InstallSVNAdmin()
{
}
/**
* 安装Subversion
*/
private function InstallSubversion()
{
}
/**
* 初始化Subversion
*/
private function InitSubversion()
{
}
/** /**
* 以守护进程模式工作 * 以守护进程模式工作
*/ */

23
02.php/server/update.json

@ -1,6 +1,5 @@
{ {
"version": "2.3", "version": "2.4",
"number": 8,
"fixd": { "fixd": {
"con": [ "con": [
{ {
@ -50,11 +49,6 @@
] ]
}, },
"update": { "update": {
"rely": {
"version": {
"SVNAdmin": []
}
},
"step": [ "step": [
{ {
"title": "1", "title": "1",
@ -65,17 +59,24 @@
"download": [ "download": [
{ {
"nodeName": "gitee.com", "nodeName": "gitee.com",
"releaseUrl": "" "package": ""
}, },
{ {
"nodeName": "github.com", "nodeName": "github.com",
"releaseUrl": "" "package": ""
}, },
{ {
"nodeName": "witersen.com", "nodeName": "witersen.com",
"releaseUrl": "https://download.witersen.com/SVNAdmin/SVNAdmin-2.3.zip" "package": "https://download.witersen.com/SVNAdmin/SVNAdmin-2.3.zip"
} }
] ]
} },
"update": [
{
"source": "2.3",
"dest": "2.4",
"package": ""
}
]
} }
} }
Loading…
Cancel
Save