@whyour/qinglong 0.20.4 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +3 -5
- package/README.md +3 -5
- package/docker/310.Dockerfile +6 -6
- package/docker/Dockerfile +6 -6
- package/package.json +1 -1
- package/shell/bot.sh +9 -1
- package/shell/share.sh +3 -1
- package/shell/start.sh +2 -5
- package/static/build/api/env.js +4 -0
- package/static/build/config/const.js +27 -1
- package/static/build/config/index.js +6 -0
- package/static/build/config/util.js +113 -1
- package/static/build/data/dependence.js +3 -3
- package/static/build/services/cron.js +8 -1
- package/static/build/services/dependence.js +36 -8
- package/static/build/services/env.js +6 -0
- package/static/build/services/system.js +7 -14
- package/static/build/services/user.js +1 -1
- package/static/dist/index.html +1 -1
- package/static/dist/src__pages__setting__dependence.9dd181cb.async.js +1 -0
- package/static/dist/src__pages__setting__index.d655075d.async.js +1 -0
- package/static/dist/{umi.e3c4ba8e.js → umi.03b3fd83.js} +1 -1
- package/version.yaml +7 -6
- package/static/dist/src__pages__setting__dependence.737c7b12.async.js +0 -1
- package/static/dist/src__pages__setting__index.c8f7affa.async.js +0 -1
package/README-en.md
CHANGED
|
@@ -48,7 +48,7 @@ docker pull whyour/qinglong:debian
|
|
|
48
48
|
|
|
49
49
|
### npm
|
|
50
50
|
|
|
51
|
-
The npm version supports `debian/ubuntu/
|
|
51
|
+
The npm version supports `debian/ubuntu/alpine` systems and requires `node/npm/python3/pip3/pnpm` to be installed.
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
npm i @whyour/qinglong
|
|
@@ -105,15 +105,13 @@ podman run -dit \
|
|
|
105
105
|
docker.io/whyour/qinglong:latest
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
###
|
|
108
|
+
### Npm
|
|
109
109
|
|
|
110
|
-
It is recommended to use a pure system installation to avoid losing the original system data, you need to install node/npm/python3/pip3 yourself
|
|
110
|
+
It is recommended to use a pure system installation to avoid losing the original system data, you need to install node/npm/python3/pip3/pnpm yourself
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
113
|
# Debian/Ubuntu
|
|
114
114
|
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
115
|
-
# Centos
|
|
116
|
-
curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
|
|
117
115
|
```
|
|
118
116
|
|
|
119
117
|
```bash
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ docker pull whyour/qinglong:debian
|
|
|
50
50
|
|
|
51
51
|
### npm
|
|
52
52
|
|
|
53
|
-
npm 版本支持 `debian/ubuntu/
|
|
53
|
+
npm 版本支持 `debian/ubuntu/alpine` 系统,需要自行安装 `node/npm/python3/pip3/pnpm`
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
56
|
npm i @whyour/qinglong
|
|
@@ -107,15 +107,13 @@ podman run -dit \
|
|
|
107
107
|
docker.io/whyour/qinglong:latest
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
###
|
|
110
|
+
### npm
|
|
111
111
|
|
|
112
|
-
建议使用纯净系统安装,避免系统原有数据丢失,需要自己安装 node/npm/python3/pip3
|
|
112
|
+
建议使用纯净系统安装,避免系统原有数据丢失,需要自己安装 node/npm/python3/pip3/pnpm
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
115
|
# Debian/Ubuntu
|
|
116
116
|
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
117
|
-
# Centos
|
|
118
|
-
curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
|
|
119
117
|
```
|
|
120
118
|
|
|
121
119
|
```bash
|
package/docker/310.Dockerfile
CHANGED
|
@@ -6,8 +6,8 @@ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
|
|
6
6
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
7
7
|
RUN set -x && \
|
|
8
8
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
9
|
-
apt update && \
|
|
10
|
-
apt install --no-install-recommends -y libatomic1 && \
|
|
9
|
+
apt-get update && \
|
|
10
|
+
apt-get install --no-install-recommends -y libatomic1 && \
|
|
11
11
|
npm i -g pnpm@8.3.1 && \
|
|
12
12
|
cd /tmp/build && \
|
|
13
13
|
pnpm install --prod
|
|
@@ -33,9 +33,9 @@ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_module
|
|
|
33
33
|
|
|
34
34
|
RUN set -x && \
|
|
35
35
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
36
|
-
apt update && \
|
|
37
|
-
apt upgrade -y && \
|
|
38
|
-
apt install --no-install-recommends -y git \
|
|
36
|
+
apt-get update && \
|
|
37
|
+
apt-get upgrade -y && \
|
|
38
|
+
apt-get install --no-install-recommends -y git \
|
|
39
39
|
curl \
|
|
40
40
|
wget \
|
|
41
41
|
tzdata \
|
|
@@ -48,7 +48,7 @@ RUN set -x && \
|
|
|
48
48
|
netcat \
|
|
49
49
|
unzip \
|
|
50
50
|
libatomic1 && \
|
|
51
|
-
apt clean && \
|
|
51
|
+
apt-get clean && \
|
|
52
52
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
53
53
|
echo "Asia/Shanghai" >/etc/timezone && \
|
|
54
54
|
git config --global user.email "qinglong@@users.noreply.github.com" && \
|
package/docker/Dockerfile
CHANGED
|
@@ -6,8 +6,8 @@ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
|
|
6
6
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
|
7
7
|
RUN set -x && \
|
|
8
8
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
9
|
-
apt update && \
|
|
10
|
-
apt install --no-install-recommends -y libatomic1 && \
|
|
9
|
+
apt-get update && \
|
|
10
|
+
apt-get install --no-install-recommends -y libatomic1 && \
|
|
11
11
|
npm i -g pnpm@8.3.1 && \
|
|
12
12
|
cd /tmp/build && \
|
|
13
13
|
pnpm install --prod
|
|
@@ -34,9 +34,9 @@ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_module
|
|
|
34
34
|
RUN set -x && \
|
|
35
35
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
36
36
|
ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
|
|
37
|
-
apt update && \
|
|
38
|
-
apt upgrade -y && \
|
|
39
|
-
apt install --no-install-recommends -y git \
|
|
37
|
+
apt-get update && \
|
|
38
|
+
apt-get upgrade -y && \
|
|
39
|
+
apt-get install --no-install-recommends -y git \
|
|
40
40
|
curl \
|
|
41
41
|
wget \
|
|
42
42
|
tzdata \
|
|
@@ -49,7 +49,7 @@ RUN set -x && \
|
|
|
49
49
|
netcat \
|
|
50
50
|
unzip \
|
|
51
51
|
libatomic1 && \
|
|
52
|
-
apt clean && \
|
|
52
|
+
apt-get clean && \
|
|
53
53
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
54
54
|
echo "Asia/Shanghai" >/etc/timezone && \
|
|
55
55
|
git config --global user.email "qinglong@@users.noreply.github.com" && \
|
package/package.json
CHANGED
package/shell/bot.sh
CHANGED
|
@@ -9,7 +9,15 @@ else
|
|
|
9
9
|
fi
|
|
10
10
|
|
|
11
11
|
echo -e "\n1、安装bot依赖...\n"
|
|
12
|
-
|
|
12
|
+
os_name=$(source /etc/os-release && echo "$ID")
|
|
13
|
+
if [[ $os_name == 'alpine' ]]; then
|
|
14
|
+
apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
|
|
15
|
+
elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
|
|
16
|
+
apt-get install -y gcc python3-dev musl-dev
|
|
17
|
+
else
|
|
18
|
+
echo -e "暂不支持此系统 $os_name"
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
13
21
|
echo -e "\nbot依赖安装成功...\n"
|
|
14
22
|
|
|
15
23
|
echo -e "2、下载bot所需文件...\n"
|
package/shell/share.sh
CHANGED
|
@@ -74,7 +74,9 @@ init_env() {
|
|
|
74
74
|
|
|
75
75
|
import_config() {
|
|
76
76
|
[[ -f $file_config_user ]] && . $file_config_user
|
|
77
|
-
[[
|
|
77
|
+
if [[ $LOAD_ENV != 'false' ]] && [[ -f $file_env ]]; then
|
|
78
|
+
. $file_env
|
|
79
|
+
fi
|
|
78
80
|
|
|
79
81
|
ql_base_url=${QlBaseUrl:-"/"}
|
|
80
82
|
ql_port=${QlPort:-"5700"}
|
package/shell/start.sh
CHANGED
|
@@ -46,11 +46,8 @@ if [[ $os_name == 'alpine' ]]; then
|
|
|
46
46
|
procps \
|
|
47
47
|
netcat-openbsd
|
|
48
48
|
elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
|
|
49
|
-
apt update
|
|
50
|
-
apt install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
|
|
51
|
-
elif [[ $os_name == 'centos' ]]; then
|
|
52
|
-
yum update
|
|
53
|
-
yum install -y epel-release git curl wget tzdata perl openssl jq nginx procps nc openssh-client
|
|
49
|
+
apt-get update
|
|
50
|
+
apt-get install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
|
|
54
51
|
else
|
|
55
52
|
echo -e "暂不支持此系统部署 $os_name"
|
|
56
53
|
exit 1
|
package/static/build/api/env.js
CHANGED
|
@@ -44,9 +44,13 @@ exports.default = (app) => {
|
|
|
44
44
|
remarks: celebrate_1.Joi.string().optional().allow(''),
|
|
45
45
|
})),
|
|
46
46
|
}), async (req, res, next) => {
|
|
47
|
+
var _a;
|
|
47
48
|
const logger = typedi_1.Container.get('logger');
|
|
48
49
|
try {
|
|
49
50
|
const envService = typedi_1.Container.get(env_1.default);
|
|
51
|
+
if (!((_a = req.body) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
52
|
+
return res.send({ code: 400, message: '参数不正确' });
|
|
53
|
+
}
|
|
50
54
|
const data = await envService.create(req.body);
|
|
51
55
|
return res.send({ code: 200, data });
|
|
52
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
|
|
3
|
+
exports.LINUX_DEPENDENCE_COMMAND = exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
|
|
4
4
|
exports.LOG_END_SYMBOL = ' ';
|
|
5
5
|
exports.TASK_COMMAND = 'task';
|
|
6
6
|
exports.QL_COMMAND = 'ql';
|
|
@@ -23,4 +23,30 @@ exports.SAMPLE_FILES = [
|
|
|
23
23
|
target: 'data/scripts/notify.py',
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
|
+
exports.LINUX_DEPENDENCE_COMMAND = {
|
|
27
|
+
Debian: {
|
|
28
|
+
install: 'apt-get install -y',
|
|
29
|
+
uninstall: 'apt-get remove -y',
|
|
30
|
+
info: 'dpkg-query -s',
|
|
31
|
+
check(info) {
|
|
32
|
+
return info.includes('install ok installed');
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
Ubuntu: {
|
|
36
|
+
install: 'apt-get install -y',
|
|
37
|
+
uninstall: 'apt-get remove -y',
|
|
38
|
+
info: 'dpkg-query -s',
|
|
39
|
+
check(info) {
|
|
40
|
+
return info.includes('install ok installed');
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
Alpine: {
|
|
44
|
+
install: 'apk add --no-check-certificate',
|
|
45
|
+
uninstall: 'apk del',
|
|
46
|
+
info: 'apk info -es',
|
|
47
|
+
check(info) {
|
|
48
|
+
return info.includes('installed');
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
26
52
|
//# sourceMappingURL=const.js.map
|
|
@@ -35,6 +35,8 @@ const uploadPath = path_1.default.join(dataPath, 'upload/');
|
|
|
35
35
|
const sshdPath = path_1.default.join(dataPath, 'ssh.d/');
|
|
36
36
|
const systemLogPath = path_1.default.join(dataPath, 'syslog/');
|
|
37
37
|
const envFile = path_1.default.join(configPath, 'env.sh');
|
|
38
|
+
const jsEnvFile = path_1.default.join(configPath, 'env.js');
|
|
39
|
+
const pyEnvFile = path_1.default.join(configPath, 'env.py');
|
|
38
40
|
const confFile = path_1.default.join(configPath, 'config.sh');
|
|
39
41
|
const crontabFile = path_1.default.join(configPath, 'crontab.list');
|
|
40
42
|
const authConfigFile = path_1.default.join(configPath, 'auth.json');
|
|
@@ -81,6 +83,8 @@ exports.default = {
|
|
|
81
83
|
sampleFile,
|
|
82
84
|
confFile,
|
|
83
85
|
envFile,
|
|
86
|
+
jsEnvFile,
|
|
87
|
+
pyEnvFile,
|
|
84
88
|
dbPath,
|
|
85
89
|
uploadPath,
|
|
86
90
|
configPath,
|
|
@@ -93,6 +97,8 @@ exports.default = {
|
|
|
93
97
|
'crontab.list',
|
|
94
98
|
'dependence-proxy.sh',
|
|
95
99
|
'env.sh',
|
|
100
|
+
'env.js',
|
|
101
|
+
'env.py',
|
|
96
102
|
'token.json',
|
|
97
103
|
],
|
|
98
104
|
writePathList: [configPath, scriptPath],
|
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getNetIp = exports.getToken = exports.getLastModifyFilePath = exports.getFileContentByName = void 0;
|
|
32
|
+
exports.updateLinuxMirrorFile = exports.detectOS = exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getNetIp = exports.getToken = exports.getLastModifyFilePath = exports.getFileContentByName = void 0;
|
|
33
33
|
const fs = __importStar(require("fs/promises"));
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const got_1 = __importDefault(require("got"));
|
|
@@ -42,7 +42,9 @@ const js_yaml_1 = require("js-yaml");
|
|
|
42
42
|
const index_1 = __importDefault(require("./index"));
|
|
43
43
|
const const_1 = require("./const");
|
|
44
44
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
45
|
+
const os_1 = __importDefault(require("os"));
|
|
45
46
|
__exportStar(require("./share"), exports);
|
|
47
|
+
let osType;
|
|
46
48
|
async function getFileContentByName(fileName) {
|
|
47
49
|
const _exsit = await fileExist(fileName);
|
|
48
50
|
if (_exsit) {
|
|
@@ -487,4 +489,114 @@ async function rmPath(path) {
|
|
|
487
489
|
}
|
|
488
490
|
}
|
|
489
491
|
exports.rmPath = rmPath;
|
|
492
|
+
async function getOSReleaseInfo() {
|
|
493
|
+
const osRelease = await fs.readFile('/etc/os-release', 'utf8');
|
|
494
|
+
return osRelease;
|
|
495
|
+
}
|
|
496
|
+
function isDebian(osReleaseInfo) {
|
|
497
|
+
return osReleaseInfo.includes('Debian');
|
|
498
|
+
}
|
|
499
|
+
function isUbuntu(osReleaseInfo) {
|
|
500
|
+
return osReleaseInfo.includes('Ubuntu');
|
|
501
|
+
}
|
|
502
|
+
function isCentOS(osReleaseInfo) {
|
|
503
|
+
return osReleaseInfo.includes('CentOS') || osReleaseInfo.includes('Red Hat');
|
|
504
|
+
}
|
|
505
|
+
function isAlpine(osReleaseInfo) {
|
|
506
|
+
return osReleaseInfo.includes('Alpine');
|
|
507
|
+
}
|
|
508
|
+
async function detectOS() {
|
|
509
|
+
if (osType)
|
|
510
|
+
return osType;
|
|
511
|
+
const platform = os_1.default.platform();
|
|
512
|
+
if (platform === 'linux') {
|
|
513
|
+
const osReleaseInfo = await getOSReleaseInfo();
|
|
514
|
+
if (isDebian(osReleaseInfo)) {
|
|
515
|
+
osType = 'Debian';
|
|
516
|
+
}
|
|
517
|
+
else if (isUbuntu(osReleaseInfo)) {
|
|
518
|
+
osType = 'Ubuntu';
|
|
519
|
+
}
|
|
520
|
+
else if (isAlpine(osReleaseInfo)) {
|
|
521
|
+
osType = 'Alpine';
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
logger_1.default.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
|
|
525
|
+
console.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
logger_1.default.error(`Unsupported platform: ${platform}`);
|
|
530
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
531
|
+
}
|
|
532
|
+
return osType;
|
|
533
|
+
}
|
|
534
|
+
exports.detectOS = detectOS;
|
|
535
|
+
async function getCurrentMirrorDomain(filePath) {
|
|
536
|
+
const fileContent = await fs.readFile(filePath, 'utf8');
|
|
537
|
+
const lines = fileContent.split('\n');
|
|
538
|
+
for (const line of lines) {
|
|
539
|
+
if (line.trim().startsWith('#')) {
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
const match = line.match(/https?:\/\/[^\/]+/);
|
|
543
|
+
if (match) {
|
|
544
|
+
return match[0];
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
async function replaceDomainInFile(filePath, oldDomainWithScheme, newDomainWithScheme) {
|
|
550
|
+
let fileContent = await fs.readFile(filePath, 'utf8');
|
|
551
|
+
let updatedContent = fileContent.replace(new RegExp(oldDomainWithScheme, 'g'), newDomainWithScheme);
|
|
552
|
+
if (!newDomainWithScheme.endsWith('/')) {
|
|
553
|
+
newDomainWithScheme += '/';
|
|
554
|
+
}
|
|
555
|
+
await fs.writeFile(filePath, updatedContent, 'utf8');
|
|
556
|
+
}
|
|
557
|
+
async function _updateLinuxMirror(osType, mirrorDomainWithScheme) {
|
|
558
|
+
let filePath, currentDomainWithScheme;
|
|
559
|
+
switch (osType) {
|
|
560
|
+
case 'Debian':
|
|
561
|
+
filePath = '/etc/apt/sources.list';
|
|
562
|
+
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
|
563
|
+
if (currentDomainWithScheme) {
|
|
564
|
+
await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://deb.debian.org');
|
|
565
|
+
return 'apt-get update';
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
throw Error(`Current mirror domain not found.`);
|
|
569
|
+
}
|
|
570
|
+
case 'Ubuntu':
|
|
571
|
+
filePath = '/etc/apt/sources.list';
|
|
572
|
+
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
|
573
|
+
if (currentDomainWithScheme) {
|
|
574
|
+
await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://archive.ubuntu.com');
|
|
575
|
+
return 'apt-get update';
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
throw Error(`Current mirror domain not found.`);
|
|
579
|
+
}
|
|
580
|
+
case 'Alpine':
|
|
581
|
+
filePath = '/etc/apk/repositories';
|
|
582
|
+
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
|
583
|
+
if (currentDomainWithScheme) {
|
|
584
|
+
await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://dl-cdn.alpinelinux.org');
|
|
585
|
+
return 'apk update';
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
throw Error(`Current mirror domain not found.`);
|
|
589
|
+
}
|
|
590
|
+
default:
|
|
591
|
+
throw Error('Unsupported OS type for updating mirrors.');
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
async function updateLinuxMirrorFile(mirror) {
|
|
595
|
+
const detectedOS = await detectOS();
|
|
596
|
+
if (!detectedOS) {
|
|
597
|
+
throw Error(`Unknown Linux Distribution`);
|
|
598
|
+
}
|
|
599
|
+
return await _updateLinuxMirror(detectedOS, mirror);
|
|
600
|
+
}
|
|
601
|
+
exports.updateLinuxMirrorFile = updateLinuxMirrorFile;
|
|
490
602
|
//# sourceMappingURL=util.js.map
|
|
@@ -39,13 +39,13 @@ var InstallDependenceCommandTypes;
|
|
|
39
39
|
(function (InstallDependenceCommandTypes) {
|
|
40
40
|
InstallDependenceCommandTypes[InstallDependenceCommandTypes["pnpm add -g"] = 0] = "pnpm add -g";
|
|
41
41
|
InstallDependenceCommandTypes[InstallDependenceCommandTypes["pip3 install --disable-pip-version-check --root-user-action=ignore"] = 1] = "pip3 install --disable-pip-version-check --root-user-action=ignore";
|
|
42
|
-
InstallDependenceCommandTypes[InstallDependenceCommandTypes["apt install -y"] = 2] = "apt install -y";
|
|
42
|
+
InstallDependenceCommandTypes[InstallDependenceCommandTypes["apt-get install -y"] = 2] = "apt-get install -y";
|
|
43
43
|
})(InstallDependenceCommandTypes || (exports.InstallDependenceCommandTypes = InstallDependenceCommandTypes = {}));
|
|
44
44
|
var GetDependenceCommandTypes;
|
|
45
45
|
(function (GetDependenceCommandTypes) {
|
|
46
46
|
GetDependenceCommandTypes[GetDependenceCommandTypes["pnpm ls -g "] = 0] = "pnpm ls -g ";
|
|
47
47
|
GetDependenceCommandTypes[GetDependenceCommandTypes["pip3 show --disable-pip-version-check"] = 1] = "pip3 show --disable-pip-version-check";
|
|
48
|
-
GetDependenceCommandTypes[GetDependenceCommandTypes["apt info"] = 2] = "apt info";
|
|
48
|
+
GetDependenceCommandTypes[GetDependenceCommandTypes["apt-get info"] = 2] = "apt-get info";
|
|
49
49
|
})(GetDependenceCommandTypes || (exports.GetDependenceCommandTypes = GetDependenceCommandTypes = {}));
|
|
50
50
|
var versionDependenceCommandTypes;
|
|
51
51
|
(function (versionDependenceCommandTypes) {
|
|
@@ -57,7 +57,7 @@ var unInstallDependenceCommandTypes;
|
|
|
57
57
|
(function (unInstallDependenceCommandTypes) {
|
|
58
58
|
unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["pnpm remove -g"] = 0] = "pnpm remove -g";
|
|
59
59
|
unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y"] = 1] = "pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y";
|
|
60
|
-
unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["apt remove -y"] = 2] = "apt remove -y";
|
|
60
|
+
unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["apt-get remove -y"] = 2] = "apt-get remove -y";
|
|
61
61
|
})(unInstallDependenceCommandTypes || (exports.unInstallDependenceCommandTypes = unInstallDependenceCommandTypes = {}));
|
|
62
62
|
exports.DependenceModel = _1.sequelize.define('Dependence', {
|
|
63
63
|
name: sequelize_1.DataTypes.STRING,
|
|
@@ -92,7 +92,14 @@ let CronService = class CronService {
|
|
|
92
92
|
options.last_running_time = last_running_time;
|
|
93
93
|
}
|
|
94
94
|
for (const id of ids) {
|
|
95
|
-
|
|
95
|
+
let cron;
|
|
96
|
+
try {
|
|
97
|
+
cron = await this.getDb({ id });
|
|
98
|
+
}
|
|
99
|
+
catch (err) { }
|
|
100
|
+
if (!cron) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
96
103
|
if (status === cron_1.CrontabStatus.idle && log_path !== cron.log_path) {
|
|
97
104
|
options = (0, omit_1.default)(options, ['status', 'log_path', 'pid']);
|
|
98
105
|
}
|
|
@@ -36,6 +36,8 @@ const sequelize_1 = require("sequelize");
|
|
|
36
36
|
const util_1 = require("../config/util");
|
|
37
37
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
38
38
|
const pLimit_1 = __importDefault(require("../shared/pLimit"));
|
|
39
|
+
const util_2 = require("../config/util");
|
|
40
|
+
const const_1 = require("../config/const");
|
|
39
41
|
let DependenceService = class DependenceService {
|
|
40
42
|
constructor(logger, sockService) {
|
|
41
43
|
this.logger = logger;
|
|
@@ -118,8 +120,18 @@ let DependenceService = class DependenceService {
|
|
|
118
120
|
const docs = await dependence_1.DependenceModel.findAll({ where: { id: ids } });
|
|
119
121
|
for (const doc of docs) {
|
|
120
122
|
pLimit_1.default.removeQueuedDependency(doc);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
let depInstallCommand = dependence_1.InstallDependenceCommandTypes[doc.type];
|
|
124
|
+
let depUnInstallCommand = dependence_1.unInstallDependenceCommandTypes[doc.type];
|
|
125
|
+
const isLinuxDependence = doc.type === dependence_1.DependenceTypes.linux;
|
|
126
|
+
if (isLinuxDependence) {
|
|
127
|
+
const osType = await (0, util_2.detectOS)();
|
|
128
|
+
if (!osType) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const linuxCommand = const_1.LINUX_DEPENDENCE_COMMAND[osType];
|
|
132
|
+
depInstallCommand = linuxCommand.install;
|
|
133
|
+
depUnInstallCommand = linuxCommand.uninstall;
|
|
134
|
+
}
|
|
123
135
|
const installCmd = `${depInstallCommand} ${doc.name.trim()}`;
|
|
124
136
|
const unInstallCmd = `${depUnInstallCommand} ${doc.name.trim()}`;
|
|
125
137
|
const pids = await Promise.all([
|
|
@@ -163,6 +175,17 @@ let DependenceService = class DependenceService {
|
|
|
163
175
|
if (pLimit_1.default.firstDependencyId !== dependency.id) {
|
|
164
176
|
return resolve(null);
|
|
165
177
|
}
|
|
178
|
+
const isNodeDependence = dependency.type === dependence_1.DependenceTypes.nodejs;
|
|
179
|
+
const isLinuxDependence = dependency.type === dependence_1.DependenceTypes.linux;
|
|
180
|
+
const isPythonDependence = dependency.type === dependence_1.DependenceTypes.python3;
|
|
181
|
+
const osType = await (0, util_2.detectOS)();
|
|
182
|
+
let linuxCommand = {};
|
|
183
|
+
if (isLinuxDependence) {
|
|
184
|
+
if (!osType) {
|
|
185
|
+
return resolve(null);
|
|
186
|
+
}
|
|
187
|
+
linuxCommand = const_1.LINUX_DEPENDENCE_COMMAND[osType];
|
|
188
|
+
}
|
|
166
189
|
pLimit_1.default.removeQueuedDependency(dependency);
|
|
167
190
|
const depIds = [dependency.id];
|
|
168
191
|
const status = isInstall
|
|
@@ -173,9 +196,14 @@ let DependenceService = class DependenceService {
|
|
|
173
196
|
? 'installDependence'
|
|
174
197
|
: 'uninstallDependence';
|
|
175
198
|
let depName = dependency.name.trim();
|
|
176
|
-
|
|
199
|
+
let depRunCommand = (isInstall
|
|
177
200
|
? dependence_1.InstallDependenceCommandTypes
|
|
178
201
|
: dependence_1.unInstallDependenceCommandTypes)[dependency.type];
|
|
202
|
+
if (isLinuxDependence) {
|
|
203
|
+
depRunCommand = isInstall
|
|
204
|
+
? linuxCommand.install
|
|
205
|
+
: linuxCommand.uninstall;
|
|
206
|
+
}
|
|
179
207
|
const actionText = isInstall ? '安装' : '删除';
|
|
180
208
|
const startTime = (0, dayjs_1.default)();
|
|
181
209
|
const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format('YYYY-MM-DD HH:mm:ss')}\n\n`;
|
|
@@ -187,8 +215,11 @@ let DependenceService = class DependenceService {
|
|
|
187
215
|
this.updateLog(depIds, message);
|
|
188
216
|
// 判断是否已经安装过依赖
|
|
189
217
|
if (isInstall && !force) {
|
|
190
|
-
|
|
218
|
+
let getCommandPrefix = dependence_1.GetDependenceCommandTypes[dependency.type];
|
|
191
219
|
const depVersionStr = dependence_1.versionDependenceCommandTypes[dependency.type];
|
|
220
|
+
if (isLinuxDependence) {
|
|
221
|
+
getCommandPrefix = linuxCommand.info;
|
|
222
|
+
}
|
|
192
223
|
let depVersion = '';
|
|
193
224
|
if (depName.includes(depVersionStr)) {
|
|
194
225
|
const symbolRegx = new RegExp(`(.*)${depVersionStr}([0-9\\.\\-\\+a-zA-Z]*)`);
|
|
@@ -198,9 +229,6 @@ let DependenceService = class DependenceService {
|
|
|
198
229
|
depVersion = _depVersion;
|
|
199
230
|
}
|
|
200
231
|
}
|
|
201
|
-
const isNodeDependence = dependency.type === dependence_1.DependenceTypes.nodejs;
|
|
202
|
-
const isLinuxDependence = dependency.type === dependence_1.DependenceTypes.linux;
|
|
203
|
-
const isPythonDependence = dependency.type === dependence_1.DependenceTypes.python3;
|
|
204
232
|
const depInfo = (await (0, util_1.promiseExecSuccess)(isNodeDependence
|
|
205
233
|
? `${getCommandPrefix} | grep "${depName}" | head -1`
|
|
206
234
|
: `${getCommandPrefix} ${depName}`))
|
|
@@ -209,7 +237,7 @@ let DependenceService = class DependenceService {
|
|
|
209
237
|
if (depInfo &&
|
|
210
238
|
((isNodeDependence && ((_a = depInfo.split(' ')) === null || _a === void 0 ? void 0 : _a[0]) === depName) ||
|
|
211
239
|
(isLinuxDependence &&
|
|
212
|
-
depInfo.toLocaleLowerCase()
|
|
240
|
+
linuxCommand.check(depInfo.toLocaleLowerCase())) ||
|
|
213
241
|
isPythonDependence) &&
|
|
214
242
|
(!depVersion || depInfo.includes(depVersion))) {
|
|
215
243
|
const endTime = (0, dayjs_1.default)();
|
|
@@ -193,6 +193,8 @@ let EnvService = class EnvService {
|
|
|
193
193
|
});
|
|
194
194
|
const groups = (0, groupBy_1.default)(envs, 'name');
|
|
195
195
|
let env_string = '';
|
|
196
|
+
let js_env_string = '';
|
|
197
|
+
let py_env_string = 'import os\n';
|
|
196
198
|
for (const key in groups) {
|
|
197
199
|
if (Object.prototype.hasOwnProperty.call(groups, key)) {
|
|
198
200
|
const group = groups[key];
|
|
@@ -204,10 +206,14 @@ let EnvService = class EnvService {
|
|
|
204
206
|
.replace(/'/g, "'\\''")
|
|
205
207
|
.trim();
|
|
206
208
|
env_string += `export ${key}='${value}'\n`;
|
|
209
|
+
js_env_string += `process.env.${key}='${value}';\n`;
|
|
210
|
+
py_env_string += `os.environ['${key}'] = '${value}'\n`;
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
await fs.writeFile(config_1.default.envFile, env_string);
|
|
215
|
+
await fs.writeFile(config_1.default.jsEnvFile, js_env_string);
|
|
216
|
+
await fs.writeFile(config_1.default.pyEnvFile, py_env_string);
|
|
211
217
|
}
|
|
212
218
|
};
|
|
213
219
|
EnvService = __decorate([
|
|
@@ -31,6 +31,7 @@ const pLimit_1 = __importDefault(require("../shared/pLimit"));
|
|
|
31
31
|
const notify_1 = __importDefault(require("./notify"));
|
|
32
32
|
const schedule_1 = __importDefault(require("./schedule"));
|
|
33
33
|
const sock_1 = __importDefault(require("./sock"));
|
|
34
|
+
const util_2 = require("../config/util");
|
|
34
35
|
let SystemService = class SystemService {
|
|
35
36
|
constructor(logger, scheduleService, sockService) {
|
|
36
37
|
this.logger = logger;
|
|
@@ -155,20 +156,8 @@ let SystemService = class SystemService {
|
|
|
155
156
|
}
|
|
156
157
|
async updateLinuxMirror(info, res, onEnd) {
|
|
157
158
|
const oDoc = await this.getSystemConfig();
|
|
158
|
-
|
|
159
|
-
let
|
|
160
|
-
let targetDomain = 'http://deb.debian.org';
|
|
161
|
-
const content = await fs_1.default.promises.readFile('/etc/apt/sources.list', {
|
|
162
|
-
encoding: 'utf-8',
|
|
163
|
-
});
|
|
164
|
-
const domainMatch = content.match(/(http.*)\/debian /);
|
|
165
|
-
if (domainMatch) {
|
|
166
|
-
defaultDomain = domainMatch[1];
|
|
167
|
-
}
|
|
168
|
-
if (info.linuxMirror) {
|
|
169
|
-
targetDomain = info.linuxMirror;
|
|
170
|
-
}
|
|
171
|
-
const command = `sed -i 's/${defaultDomain.replace(/\//g, '\\/')}/${targetDomain.replace(/\//g, '\\/')}/g' /etc/apt/sources.list && apt update`;
|
|
159
|
+
const command = await (0, util_2.updateLinuxMirrorFile)(info.linuxMirror || '');
|
|
160
|
+
let hasError = false;
|
|
172
161
|
this.scheduleService.runTask(command, {
|
|
173
162
|
onStart: async (cp) => {
|
|
174
163
|
res === null || res === void 0 ? void 0 : res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
|
@@ -180,8 +169,12 @@ let SystemService = class SystemService {
|
|
|
180
169
|
message: 'update linux mirror end',
|
|
181
170
|
});
|
|
182
171
|
onEnd === null || onEnd === void 0 ? void 0 : onEnd();
|
|
172
|
+
if (!hasError) {
|
|
173
|
+
await this.updateAuthDb(Object.assign(Object.assign({}, oDoc), { info: Object.assign(Object.assign({}, oDoc.info), info) }));
|
|
174
|
+
}
|
|
183
175
|
},
|
|
184
176
|
onError: async (message) => {
|
|
177
|
+
hasError = true;
|
|
185
178
|
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
|
186
179
|
},
|
|
187
180
|
onLog: async (message) => {
|
|
@@ -228,7 +228,7 @@ let UserService = class UserService {
|
|
|
228
228
|
async getUserInfo() {
|
|
229
229
|
const authFileExist = await (0, util_1.fileExist)(config_1.default.authConfigFile);
|
|
230
230
|
if (!authFileExist) {
|
|
231
|
-
await
|
|
231
|
+
await (0, util_1.createFile)(config_1.default.authConfigFile, JSON.stringify({
|
|
232
232
|
username: 'admin',
|
|
233
233
|
password: 'admin',
|
|
234
234
|
}));
|