mirror of
https://github.com/whyour/qinglong.git
synced 2026-05-02 12:17:19 +08:00
Compare commits
61 Commits
develop
...
v2.20.1-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb23e109cc | ||
|
|
2e7e454c59 | ||
|
|
ddd89dbf97 | ||
|
|
ba46128ea7 | ||
|
|
1c41b72e46 | ||
|
|
243aa16e7a | ||
|
|
89766e538f | ||
|
|
c62972bfde | ||
|
|
063834c6e4 | ||
|
|
9bda6351cc | ||
|
|
5ce523b41b | ||
|
|
c3183a01a9 | ||
|
|
e022018087 | ||
|
|
df94aeca88 | ||
|
|
0072646a49 | ||
|
|
584ca10331 | ||
|
|
3b570eea47 | ||
|
|
29b3b7c93e | ||
|
|
db1b2896fe | ||
|
|
e533623636 | ||
|
|
aebcfcfe1c | ||
|
|
b2fdbc0d71 | ||
|
|
82a6467e37 | ||
|
|
d0d8a5b2c0 | ||
|
|
356c29b0c7 | ||
|
|
5c4e434aa7 | ||
|
|
1dcf9dae2f | ||
|
|
fca7c46e6a | ||
|
|
d1a4e92d0f | ||
|
|
bf6a4de5c6 | ||
|
|
5f41904f53 | ||
|
|
1ff1dcf4c2 | ||
|
|
fc5977de1f | ||
|
|
f79820e5f0 | ||
|
|
29896b8c94 | ||
|
|
d6be908a2c | ||
|
|
6c88523d91 | ||
|
|
45b42a415f | ||
|
|
cfe1bdff07 | ||
|
|
34b11aaa65 | ||
|
|
167b83ecc6 | ||
|
|
578fa874d3 | ||
|
|
4e1401eb27 | ||
|
|
043934b9fc | ||
|
|
ec06db53e1 | ||
|
|
9f8c6fe811 | ||
|
|
de78d9840a | ||
|
|
67244bde92 | ||
|
|
525e6ff2aa | ||
|
|
99993a3b2b | ||
|
|
6d87206ec9 | ||
|
|
4d3fa6b0d4 | ||
|
|
9372d2030f | ||
|
|
8892a4a816 | ||
|
|
2bf5c2c3c9 | ||
|
|
e8a35dd5ee | ||
|
|
51a4408c19 | ||
|
|
360a35d70d | ||
|
|
28a95d1e1c | ||
|
|
609d554cd4 | ||
|
|
e9804c51f8 |
52
.github/workflows/build-docker-image.yml
vendored
52
.github/workflows/build-docker-image.yml
vendored
|
|
@ -7,6 +7,8 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- "master"
|
- "master"
|
||||||
- "develop"
|
- "develop"
|
||||||
|
- "debian"
|
||||||
|
- "debian-dev"
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
@ -163,9 +165,9 @@ jobs:
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=false
|
latest=false
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
|
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'debian-dev') }}
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=${{ steps.version.outputs.version }}-debian,enable=${{ github.ref == format('refs/heads/{0}', 'debian') }}
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
|
|
@ -183,22 +185,21 @@ jobs:
|
||||||
QL_BRANCH=${{ github.ref_name }}
|
QL_BRANCH=${{ github.ref_name }}
|
||||||
SOURCE_COMMIT=${{ github.sha }}
|
SOURCE_COMMIT=${{ github.sha }}
|
||||||
network: host
|
network: host
|
||||||
# linux/s390x npm 暂不可用
|
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
|
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/Dockerfile
|
file: ./docker/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache
|
cache-from: type=registry,ref=whyour/qinglong:cache-debian
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache,mode=max
|
cache-to: type=registry,ref=whyour/qinglong:cache-debian,mode=max
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.docker_build.outputs.digest }}
|
echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
||||||
build310:
|
build310:
|
||||||
if: ${{ github.ref_name == 'master' }}
|
if: ${{ github.ref_name == 'debian' }}
|
||||||
needs: build-static
|
needs: build-static
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
@ -256,17 +257,42 @@ jobs:
|
||||||
QL_BRANCH=${{ github.ref_name }}
|
QL_BRANCH=${{ github.ref_name }}
|
||||||
SOURCE_COMMIT=${{ github.sha }}
|
SOURCE_COMMIT=${{ github.sha }}
|
||||||
network: host
|
network: host
|
||||||
# linux/s390x npm 暂不可用
|
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
|
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/310.Dockerfile
|
file: ./docker/310.Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
whyour/qinglong:python3.10
|
whyour/qinglong:debian-python3.10
|
||||||
whyour/qinglong:${{ steps.version.outputs.version }}-python3.10
|
whyour/qinglong:${{ steps.version.outputs.version }}-debian-python3.10
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
cache-from: type=registry,ref=whyour/qinglong:cache-debian-python3.10
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
cache-to: type=registry,ref=whyour/qinglong:cache-debian-python3.10,mode=max
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.docker_build_310.outputs.digest }}
|
echo ${{ steps.docker_build_310.outputs.digest }}
|
||||||
|
|
||||||
|
publish:
|
||||||
|
if: ${{ github.ref_name == 'debian' }}
|
||||||
|
needs: build
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v3
|
||||||
|
with:
|
||||||
|
version: "8.3.1"
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: build front and back
|
||||||
|
run: |
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
pnpm build:front
|
||||||
|
pnpm build:back
|
||||||
|
|
||||||
|
- name: publich npm package
|
||||||
|
run: |
|
||||||
|
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
|
||||||
|
npm publish
|
||||||
|
|
|
||||||
22
.npmignore
Normal file
22
.npmignore
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/.tmp/
|
||||||
|
/.github/
|
||||||
|
/.vscode/
|
||||||
|
/.history/
|
||||||
|
/back/**/*.ts
|
||||||
|
/back/**/*.json
|
||||||
|
/cli/
|
||||||
|
/data/
|
||||||
|
/src/
|
||||||
|
/static/**/*.js.map
|
||||||
|
/static/**/*.gz
|
||||||
|
/.editorconfig
|
||||||
|
/.gitignore
|
||||||
|
/.prettierignore
|
||||||
|
/.prettierrc
|
||||||
|
/.umirc.ts
|
||||||
|
/nodemon.json
|
||||||
|
/pnpm-lock.yaml
|
||||||
|
/tsconfig.back.json
|
||||||
|
/tsconfig.json
|
||||||
|
/typings.d.ts
|
||||||
|
/.env
|
||||||
|
|
@ -14,7 +14,7 @@ export default (app: Router) => {
|
||||||
app.use('/configs', route);
|
app.use('/configs', route);
|
||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
'/sample',
|
'/samples',
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
res.send({
|
res.send({
|
||||||
|
|
|
||||||
|
|
@ -49,3 +49,38 @@ export const NotificationModeStringMap = {
|
||||||
19: 'ntfy',
|
19: 'ntfy',
|
||||||
20: 'wxPusherBot',
|
20: 'wxPusherBot',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const LINUX_DEPENDENCE_COMMAND: Record<
|
||||||
|
'Debian' | 'Ubuntu' | 'Alpine',
|
||||||
|
{
|
||||||
|
install: string;
|
||||||
|
uninstall: string;
|
||||||
|
info: string;
|
||||||
|
check(info: string): boolean;
|
||||||
|
}
|
||||||
|
> = {
|
||||||
|
Debian: {
|
||||||
|
install: 'apt-get install -y',
|
||||||
|
uninstall: 'apt-get remove -y',
|
||||||
|
info: 'dpkg-query -s',
|
||||||
|
check(info: string) {
|
||||||
|
return info.includes('install ok installed');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Ubuntu: {
|
||||||
|
install: 'apt-get install -y',
|
||||||
|
uninstall: 'apt-get remove -y',
|
||||||
|
info: 'dpkg-query -s',
|
||||||
|
check(info: string) {
|
||||||
|
return info.includes('install ok installed');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Alpine: {
|
||||||
|
install: 'apk add --no-check-certificate',
|
||||||
|
uninstall: 'apk del',
|
||||||
|
info: 'apk info -es',
|
||||||
|
check(info: string) {
|
||||||
|
return info.includes('installed');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@ import Logger from '../loaders/logger';
|
||||||
import { writeFileWithLock } from '../shared/utils';
|
import { writeFileWithLock } from '../shared/utils';
|
||||||
import { DependenceTypes } from '../data/dependence';
|
import { DependenceTypes } from '../data/dependence';
|
||||||
import { FormData } from 'undici';
|
import { FormData } from 'undici';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
export * from './share';
|
export * from './share';
|
||||||
|
|
||||||
|
let osType: 'Debian' | 'Ubuntu' | 'Alpine' | undefined;
|
||||||
|
|
||||||
export async function getFileContentByName(fileName: string) {
|
export async function getFileContentByName(fileName: string) {
|
||||||
const _exsit = await fileExist(fileName);
|
const _exsit = await fileExist(fileName);
|
||||||
if (_exsit) {
|
if (_exsit) {
|
||||||
|
|
@ -550,7 +553,7 @@ except:
|
||||||
spec=u.find_spec(name)
|
spec=u.find_spec(name)
|
||||||
print(name if spec else '')
|
print(name if spec else '')
|
||||||
''')"`,
|
''')"`,
|
||||||
[DependenceTypes.linux]: `apk info -es ${name}`,
|
[DependenceTypes.linux]: `apt-get info ${name}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
return baseCommands[type];
|
return baseCommands[type];
|
||||||
|
|
@ -561,7 +564,7 @@ export function getInstallCommand(type: DependenceTypes, name: string): string {
|
||||||
[DependenceTypes.nodejs]: 'pnpm add -g',
|
[DependenceTypes.nodejs]: 'pnpm add -g',
|
||||||
[DependenceTypes.python3]:
|
[DependenceTypes.python3]:
|
||||||
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
'pip3 install --disable-pip-version-check --root-user-action=ignore',
|
||||||
[DependenceTypes.linux]: 'apk add --no-check-certificate',
|
[DependenceTypes.linux]: 'apt install -y',
|
||||||
};
|
};
|
||||||
|
|
||||||
let command = baseCommands[type];
|
let command = baseCommands[type];
|
||||||
|
|
@ -581,7 +584,7 @@ export function getUninstallCommand(
|
||||||
[DependenceTypes.nodejs]: 'pnpm remove -g',
|
[DependenceTypes.nodejs]: 'pnpm remove -g',
|
||||||
[DependenceTypes.python3]:
|
[DependenceTypes.python3]:
|
||||||
'pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y',
|
'pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y',
|
||||||
[DependenceTypes.linux]: 'apk del',
|
[DependenceTypes.linux]: 'apt remove -y',
|
||||||
};
|
};
|
||||||
|
|
||||||
return `${baseCommands[type]} ${name.trim()}`;
|
return `${baseCommands[type]} ${name.trim()}`;
|
||||||
|
|
@ -590,3 +593,145 @@ export function getUninstallCommand(
|
||||||
export function isDemoEnv() {
|
export function isDemoEnv() {
|
||||||
return process.env.DeployEnv === 'demo';
|
return process.env.DeployEnv === 'demo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getOSReleaseInfo(): Promise<string> {
|
||||||
|
const osRelease = await fs.readFile('/etc/os-release', 'utf8');
|
||||||
|
return osRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDebian(osReleaseInfo: string): boolean {
|
||||||
|
return osReleaseInfo.includes('Debian');
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUbuntu(osReleaseInfo: string): boolean {
|
||||||
|
return osReleaseInfo.includes('Ubuntu');
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCentOS(osReleaseInfo: string): boolean {
|
||||||
|
return osReleaseInfo.includes('CentOS') || osReleaseInfo.includes('Red Hat');
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAlpine(osReleaseInfo: string): boolean {
|
||||||
|
return osReleaseInfo.includes('Alpine');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function detectOS(): Promise<
|
||||||
|
'Debian' | 'Ubuntu' | 'Alpine' | undefined
|
||||||
|
> {
|
||||||
|
if (osType) return osType;
|
||||||
|
const platform = os.platform();
|
||||||
|
|
||||||
|
if (platform === 'linux') {
|
||||||
|
const osReleaseInfo = await getOSReleaseInfo();
|
||||||
|
if (isDebian(osReleaseInfo)) {
|
||||||
|
osType = 'Debian';
|
||||||
|
} else if (isUbuntu(osReleaseInfo)) {
|
||||||
|
osType = 'Ubuntu';
|
||||||
|
} else if (isAlpine(osReleaseInfo)) {
|
||||||
|
osType = 'Alpine';
|
||||||
|
} else {
|
||||||
|
Logger.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
|
||||||
|
console.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
|
||||||
|
}
|
||||||
|
} else if (platform === 'darwin') {
|
||||||
|
osType = undefined;
|
||||||
|
} else {
|
||||||
|
Logger.error(`Unsupported platform: ${platform}`);
|
||||||
|
console.error(`Unsupported platform: ${platform}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return osType;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCurrentMirrorDomain(
|
||||||
|
filePath: string,
|
||||||
|
): Promise<string | null> {
|
||||||
|
const fileContent = await fs.readFile(filePath, 'utf8');
|
||||||
|
const lines = fileContent.split('\n');
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.trim().startsWith('#')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const match = line.match(/https?:\/\/[^\/]+/);
|
||||||
|
if (match) {
|
||||||
|
return match[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function replaceDomainInFile(
|
||||||
|
filePath: string,
|
||||||
|
oldDomainWithScheme: string,
|
||||||
|
newDomainWithScheme: string,
|
||||||
|
): Promise<void> {
|
||||||
|
let fileContent = await fs.readFile(filePath, 'utf8');
|
||||||
|
let updatedContent = fileContent.replace(
|
||||||
|
new RegExp(oldDomainWithScheme, 'g'),
|
||||||
|
newDomainWithScheme,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!newDomainWithScheme.endsWith('/')) {
|
||||||
|
newDomainWithScheme += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
await writeFileWithLock(filePath, updatedContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function _updateLinuxMirror(
|
||||||
|
osType: string,
|
||||||
|
mirrorDomainWithScheme: string,
|
||||||
|
): Promise<string> {
|
||||||
|
let filePath: string, currentDomainWithScheme: string | null;
|
||||||
|
switch (osType) {
|
||||||
|
case 'Debian':
|
||||||
|
filePath = '/etc/apt/sources.list.d/debian.sources';
|
||||||
|
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
||||||
|
if (currentDomainWithScheme) {
|
||||||
|
await replaceDomainInFile(
|
||||||
|
filePath,
|
||||||
|
currentDomainWithScheme,
|
||||||
|
mirrorDomainWithScheme || 'http://deb.debian.org',
|
||||||
|
);
|
||||||
|
return 'apt-get update';
|
||||||
|
} else {
|
||||||
|
throw Error(`Current mirror domain not found.`);
|
||||||
|
}
|
||||||
|
case 'Ubuntu':
|
||||||
|
filePath = '/etc/apt/sources.list.d/ubuntu.sources';
|
||||||
|
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
||||||
|
if (currentDomainWithScheme) {
|
||||||
|
await replaceDomainInFile(
|
||||||
|
filePath,
|
||||||
|
currentDomainWithScheme,
|
||||||
|
mirrorDomainWithScheme || 'http://archive.ubuntu.com',
|
||||||
|
);
|
||||||
|
return 'apt-get update';
|
||||||
|
} else {
|
||||||
|
throw Error(`Current mirror domain not found.`);
|
||||||
|
}
|
||||||
|
case 'Alpine':
|
||||||
|
filePath = '/etc/apk/repositories';
|
||||||
|
currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
|
||||||
|
if (currentDomainWithScheme) {
|
||||||
|
await replaceDomainInFile(
|
||||||
|
filePath,
|
||||||
|
currentDomainWithScheme,
|
||||||
|
mirrorDomainWithScheme || 'http://dl-cdn.alpinelinux.org',
|
||||||
|
);
|
||||||
|
return 'apk update';
|
||||||
|
} else {
|
||||||
|
throw Error(`Current mirror domain not found.`);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw Error('Unsupported OS type for updating mirrors.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateLinuxMirrorFile(mirror: string): Promise<string> {
|
||||||
|
const detectedOS = await detectOS();
|
||||||
|
if (!detectedOS) {
|
||||||
|
throw Error(`Unknown Linux Distribution`);
|
||||||
|
}
|
||||||
|
return await _updateLinuxMirror(detectedOS, mirror);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ export enum NotificationMode {
|
||||||
'chronocat' = 'Chronocat',
|
'chronocat' = 'Chronocat',
|
||||||
'ntfy' = 'ntfy',
|
'ntfy' = 'ntfy',
|
||||||
'wxPusherBot' = 'wxPusherBot',
|
'wxPusherBot' = 'wxPusherBot',
|
||||||
'openiLink' = 'openiLink',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class NotificationBaseInfo {
|
abstract class NotificationBaseInfo {
|
||||||
|
|
@ -162,12 +161,6 @@ export class WxPusherBotNotification extends NotificationBaseInfo {
|
||||||
public wxPusherBotUids = '';
|
public wxPusherBotUids = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OpeniLinkNotification extends NotificationBaseInfo {
|
|
||||||
public openiLinkAppToken = '';
|
|
||||||
public openiLinkHubUrl = '';
|
|
||||||
public openiLinkContextToken = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NotificationInfo
|
export interface NotificationInfo
|
||||||
extends GoCqHttpBotNotification,
|
extends GoCqHttpBotNotification,
|
||||||
GotifyNotification,
|
GotifyNotification,
|
||||||
|
|
@ -189,5 +182,4 @@ export interface NotificationInfo
|
||||||
ChronocatNotification,
|
ChronocatNotification,
|
||||||
LarkNotification,
|
LarkNotification,
|
||||||
NtfyNotification,
|
NtfyNotification,
|
||||||
WxPusherBotNotification,
|
WxPusherBotNotification {}
|
||||||
OpeniLinkNotification {}
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import { AuthDataType, SystemModel } from '../data/system';
|
||||||
import SystemService from '../services/system';
|
import SystemService from '../services/system';
|
||||||
import UserService from '../services/user';
|
import UserService from '../services/user';
|
||||||
import { writeFile, readFile } from 'fs/promises';
|
import { writeFile, readFile } from 'fs/promises';
|
||||||
import { createRandomString, fileExist, isDemoEnv, safeJSONParse } from '../config/util';
|
import { createRandomString, fileExist, safeJSONParse } from '../config/util';
|
||||||
import OpenService from '../services/open';
|
import OpenService from '../services/open';
|
||||||
import { shareStore } from '../shared/store';
|
import { shareStore } from '../shared/store';
|
||||||
import Logger from './logger';
|
import Logger from './logger';
|
||||||
|
|
@ -50,7 +50,7 @@ export default async () => {
|
||||||
const [authConfig] = await SystemModel.findOrCreate({
|
const [authConfig] = await SystemModel.findOrCreate({
|
||||||
where: { type: AuthDataType.authConfig },
|
where: { type: AuthDataType.authConfig },
|
||||||
});
|
});
|
||||||
if (!authConfig?.info || isDemoEnv()) {
|
if (!authConfig?.info) {
|
||||||
let authInfo = {
|
let authInfo = {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'admin',
|
password: 'admin',
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ export default class CronService {
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isNodeCron(doc) && !this.isSpecialSchedule(doc.schedule)) {
|
if (!this.isSpecialSchedule(doc.schedule)) {
|
||||||
await cronClient.addCron([
|
await cronClient.addCron([
|
||||||
{
|
{
|
||||||
name: doc.name || '',
|
name: doc.name || '',
|
||||||
|
|
@ -111,11 +111,9 @@ export default class CronService {
|
||||||
return newDoc;
|
return newDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isNodeCron(doc)) {
|
await cronClient.delCron([String(newDoc.id)]);
|
||||||
await cronClient.delCron([String(doc.id)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isNodeCron(newDoc) && !this.isSpecialSchedule(newDoc.schedule)) {
|
if (!this.isSpecialSchedule(newDoc.schedule)) {
|
||||||
await cronClient.addCron([
|
await cronClient.addCron([
|
||||||
{
|
{
|
||||||
name: doc.name || '',
|
name: doc.name || '',
|
||||||
|
|
@ -577,9 +575,7 @@ export default class CronService {
|
||||||
public async enabled(ids: number[]) {
|
public async enabled(ids: number[]) {
|
||||||
await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } });
|
await CrontabModel.update({ isDisabled: 0 }, { where: { id: ids } });
|
||||||
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
||||||
const sixCron = docs
|
const crons = docs.map((doc) => ({
|
||||||
.filter((x) => this.isNodeCron(x) && !this.isSpecialSchedule(x.schedule))
|
|
||||||
.map((doc) => ({
|
|
||||||
name: doc.name || '',
|
name: doc.name || '',
|
||||||
id: String(doc.id),
|
id: String(doc.id),
|
||||||
schedule: doc.schedule!,
|
schedule: doc.schedule!,
|
||||||
|
|
@ -590,7 +586,8 @@ export default class CronService {
|
||||||
if (isDemoEnv()) {
|
if (isDemoEnv()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await cronClient.addCron(sixCron);
|
|
||||||
|
await cronClient.addCron(crons);
|
||||||
await this.setCrontab();
|
await this.setCrontab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,13 +687,6 @@ export default class CronService {
|
||||||
|
|
||||||
await writeFileWithLock(config.crontabFile, crontab_string);
|
await writeFileWithLock(config.crontabFile, crontab_string);
|
||||||
|
|
||||||
try {
|
|
||||||
execSync(`crontab ${config.crontabFile}`);
|
|
||||||
} catch (error: any) {
|
|
||||||
const errorMsg = error.message || String(error);
|
|
||||||
this.logger.error('[crontab] Failed to update system crontab:', errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
await CrontabModel.update({ saved: true }, { where: {} });
|
await CrontabModel.update({ saved: true }, { where: {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -742,12 +732,7 @@ export default class CronService {
|
||||||
public async autosave_crontab() {
|
public async autosave_crontab() {
|
||||||
const tabs = await this.crontabs();
|
const tabs = await this.crontabs();
|
||||||
const regularCrons = tabs.data
|
const regularCrons = tabs.data
|
||||||
.filter(
|
.filter((x) => x.isDisabled !== 1 && !this.isSpecialSchedule(x.schedule))
|
||||||
(x) =>
|
|
||||||
x.isDisabled !== 1 &&
|
|
||||||
this.isNodeCron(x) &&
|
|
||||||
!this.isSpecialSchedule(x.schedule),
|
|
||||||
)
|
|
||||||
.map((doc) => ({
|
.map((doc) => ({
|
||||||
name: doc.name || '',
|
name: doc.name || '',
|
||||||
id: String(doc.id),
|
id: String(doc.id),
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import {
|
||||||
} from '../config/util';
|
} from '../config/util';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import taskLimit from '../shared/pLimit';
|
import taskLimit from '../shared/pLimit';
|
||||||
|
import { detectOS } from '../config/util';
|
||||||
|
import { LINUX_DEPENDENCE_COMMAND } from '../config/const';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class DependenceService {
|
export default class DependenceService {
|
||||||
|
|
@ -159,8 +161,19 @@ export default class DependenceService {
|
||||||
const docs = await DependenceModel.findAll({ where: { id: ids } });
|
const docs = await DependenceModel.findAll({ where: { id: ids } });
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
taskLimit.removeQueuedDependency(doc);
|
taskLimit.removeQueuedDependency(doc);
|
||||||
const depInstallCommand = getInstallCommand(doc.type, doc.name);
|
let depInstallCommand = getInstallCommand(doc.type, doc.name);
|
||||||
const depUnInstallCommand = getUninstallCommand(doc.type, doc.name);
|
let depUnInstallCommand = getUninstallCommand(doc.type, doc.name);
|
||||||
|
const isLinuxDependence = doc.type === DependenceTypes.linux;
|
||||||
|
|
||||||
|
if (isLinuxDependence) {
|
||||||
|
const osType = await detectOS();
|
||||||
|
if (!osType) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const linuxCommand = LINUX_DEPENDENCE_COMMAND[osType];
|
||||||
|
depInstallCommand = `${linuxCommand.install} ${doc.name.trim()}`;
|
||||||
|
depUnInstallCommand = `${linuxCommand.uninstall} ${doc.name.trim()}`;
|
||||||
|
}
|
||||||
const pids = await Promise.all([
|
const pids = await Promise.all([
|
||||||
getPid(depInstallCommand),
|
getPid(depInstallCommand),
|
||||||
getPid(depUnInstallCommand),
|
getPid(depUnInstallCommand),
|
||||||
|
|
@ -217,23 +230,54 @@ export default class DependenceService {
|
||||||
if (taskLimit.firstDependencyId !== dependency.id) {
|
if (taskLimit.firstDependencyId !== dependency.id) {
|
||||||
return resolve(null);
|
return resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
taskLimit.removeQueuedDependency(dependency);
|
|
||||||
|
|
||||||
const depIds = [dependency.id!];
|
const depIds = [dependency.id!];
|
||||||
|
let depName = dependency.name.trim();
|
||||||
|
const actionText = isInstall ? '安装' : '删除';
|
||||||
|
const socketMessageType = isInstall
|
||||||
|
? 'installDependence'
|
||||||
|
: 'uninstallDependence';
|
||||||
|
const isNodeDependence = dependency.type === DependenceTypes.nodejs;
|
||||||
|
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
||||||
|
const isPythonDependence = dependency.type === DependenceTypes.python3;
|
||||||
|
const osType = await detectOS();
|
||||||
|
let linuxCommand = {} as typeof LINUX_DEPENDENCE_COMMAND.Alpine;
|
||||||
|
taskLimit.removeQueuedDependency(dependency);
|
||||||
|
if (isLinuxDependence) {
|
||||||
|
if (!osType) {
|
||||||
|
await DependenceModel.update(
|
||||||
|
{ status: DependenceStatus.installFailed },
|
||||||
|
{ where: { id: depIds } },
|
||||||
|
);
|
||||||
|
const startTime = dayjs();
|
||||||
|
const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format(
|
||||||
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
|
)}\n\n当前系统不支持\n\n依赖${actionText}失败,结束时间 ${startTime.format(
|
||||||
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
|
)},耗时 ${startTime.diff(startTime, 'second')} 秒`;
|
||||||
|
this.sockService.sendMessage({
|
||||||
|
type: socketMessageType,
|
||||||
|
message,
|
||||||
|
references: depIds,
|
||||||
|
});
|
||||||
|
this.updateLog(depIds, message);
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
linuxCommand = LINUX_DEPENDENCE_COMMAND[osType];
|
||||||
|
}
|
||||||
|
|
||||||
const status = isInstall
|
const status = isInstall
|
||||||
? DependenceStatus.installing
|
? DependenceStatus.installing
|
||||||
: DependenceStatus.removing;
|
: DependenceStatus.removing;
|
||||||
await DependenceModel.update({ status }, { where: { id: depIds } });
|
await DependenceModel.update({ status }, { where: { id: depIds } });
|
||||||
|
|
||||||
const socketMessageType = isInstall
|
let command = isInstall
|
||||||
? 'installDependence'
|
|
||||||
: 'uninstallDependence';
|
|
||||||
let depName = dependency.name.trim();
|
|
||||||
const command = isInstall
|
|
||||||
? getInstallCommand(dependency.type, depName)
|
? getInstallCommand(dependency.type, depName)
|
||||||
: getUninstallCommand(dependency.type, depName);
|
: getUninstallCommand(dependency.type, depName);
|
||||||
const actionText = isInstall ? '安装' : '删除';
|
if (isLinuxDependence) {
|
||||||
|
command = isInstall
|
||||||
|
? `${linuxCommand.install} ${depName.trim()}`
|
||||||
|
: `${linuxCommand.uninstall} ${depName.trim()}`;
|
||||||
|
}
|
||||||
const startTime = dayjs();
|
const startTime = dayjs();
|
||||||
|
|
||||||
const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format(
|
const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format(
|
||||||
|
|
@ -248,8 +292,12 @@ export default class DependenceService {
|
||||||
|
|
||||||
// 判断是否已经安装过依赖
|
// 判断是否已经安装过依赖
|
||||||
if (isInstall && !force) {
|
if (isInstall && !force) {
|
||||||
const getCommand = getGetCommand(dependency.type, depName);
|
let getCommand = getGetCommand(dependency.type, depName);
|
||||||
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
||||||
|
if (isLinuxDependence) {
|
||||||
|
getCommand = `${linuxCommand.info} ${depName}`;
|
||||||
|
}
|
||||||
|
|
||||||
let depVersion = '';
|
let depVersion = '';
|
||||||
if (depName.includes(depVersionStr)) {
|
if (depName.includes(depVersionStr)) {
|
||||||
const symbolRegx = new RegExp(
|
const symbolRegx = new RegExp(
|
||||||
|
|
@ -261,10 +309,6 @@ export default class DependenceService {
|
||||||
depVersion = _depVersion;
|
depVersion = _depVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const isNodeDependence = dependency.type === DependenceTypes.nodejs;
|
|
||||||
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
|
||||||
const isPythonDependence =
|
|
||||||
dependency.type === DependenceTypes.python3;
|
|
||||||
const depInfo = (await promiseExecSuccess(getCommand))
|
const depInfo = (await promiseExecSuccess(getCommand))
|
||||||
.replace(/\s{2,}/, ' ')
|
.replace(/\s{2,}/, ' ')
|
||||||
.replace(/\s+$/, '');
|
.replace(/\s+$/, '');
|
||||||
|
|
@ -273,7 +317,7 @@ export default class DependenceService {
|
||||||
depInfo &&
|
depInfo &&
|
||||||
((isNodeDependence && depInfo.split(' ')?.[0] === depName) ||
|
((isNodeDependence && depInfo.split(' ')?.[0] === depName) ||
|
||||||
(isLinuxDependence &&
|
(isLinuxDependence &&
|
||||||
depInfo.toLocaleLowerCase().includes('installed')) ||
|
linuxCommand.check(depInfo.toLocaleLowerCase())) ||
|
||||||
isPythonDependence) &&
|
isPythonDependence) &&
|
||||||
(!depVersion || depInfo.includes(depVersion))
|
(!depVersion || depInfo.includes(depVersion))
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ export default class NotificationService {
|
||||||
['chronocat', this.chronocat],
|
['chronocat', this.chronocat],
|
||||||
['ntfy', this.ntfy],
|
['ntfy', this.ntfy],
|
||||||
['wxPusherBot', this.wxPusherBot],
|
['wxPusherBot', this.wxPusherBot],
|
||||||
['openiLink', this.openiLink],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
private title = '';
|
private title = '';
|
||||||
|
|
@ -859,35 +858,4 @@ export default class NotificationService {
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async openiLink() {
|
|
||||||
const { openiLinkAppToken, openiLinkHubUrl, openiLinkContextToken } =
|
|
||||||
this.params;
|
|
||||||
const baseUrl = openiLinkHubUrl?.replace(/\/$/, '') || 'https://hub.openilink.com';
|
|
||||||
const url = `${baseUrl}/bot/v1/message/send`;
|
|
||||||
const body: Record<string, string> = {
|
|
||||||
type: 'text',
|
|
||||||
content: `${this.title}\n\n${this.content}`,
|
|
||||||
};
|
|
||||||
if (openiLinkContextToken) {
|
|
||||||
body.context_token = openiLinkContextToken;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const res = await httpClient.post(url, {
|
|
||||||
...this.gotOption,
|
|
||||||
json: body,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${openiLinkAppToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (res.ok) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
throw new Error(JSON.stringify(res));
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
throw new Error(error.response ? error.response.body : error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import ScheduleService, { TaskCallbacks } from './schedule';
|
||||||
import SockService from './sock';
|
import SockService from './sock';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { updateLinuxMirrorFile } from '../config/util';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class SystemService {
|
export default class SystemService {
|
||||||
|
|
@ -214,33 +215,11 @@ export default class SystemService {
|
||||||
onEnd?: () => void,
|
onEnd?: () => void,
|
||||||
) {
|
) {
|
||||||
const oDoc = await this.getSystemConfig();
|
const oDoc = await this.getSystemConfig();
|
||||||
await this.updateAuthDb({
|
|
||||||
...oDoc,
|
|
||||||
info: { ...oDoc.info, ...info },
|
|
||||||
});
|
|
||||||
let defaultDomain = 'https://dl-cdn.alpinelinux.org';
|
|
||||||
let targetDomain = 'https://dl-cdn.alpinelinux.org';
|
|
||||||
if (os.platform() !== 'linux') {
|
if (os.platform() !== 'linux') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const content = await fs.promises.readFile('/etc/apk/repositories', {
|
const command = await updateLinuxMirrorFile(info.linuxMirror || '');
|
||||||
encoding: 'utf-8',
|
let hasError = false;
|
||||||
});
|
|
||||||
const domainMatch = content.match(/(http.*)\/alpine\/.*/);
|
|
||||||
if (domainMatch) {
|
|
||||||
defaultDomain = domainMatch[1];
|
|
||||||
}
|
|
||||||
if (info.linuxMirror) {
|
|
||||||
targetDomain = info.linuxMirror;
|
|
||||||
}
|
|
||||||
const command = `sed -i 's/${defaultDomain.replace(
|
|
||||||
/\//g,
|
|
||||||
'\\/',
|
|
||||||
)}/${targetDomain.replace(
|
|
||||||
/\//g,
|
|
||||||
'\\/',
|
|
||||||
)}/g' /etc/apk/repositories && apk update -f`;
|
|
||||||
|
|
||||||
this.scheduleService.runTask(
|
this.scheduleService.runTask(
|
||||||
command,
|
command,
|
||||||
{
|
{
|
||||||
|
|
@ -254,8 +233,15 @@ export default class SystemService {
|
||||||
message: 'update linux mirror end',
|
message: 'update linux mirror end',
|
||||||
});
|
});
|
||||||
onEnd?.();
|
onEnd?.();
|
||||||
|
if (!hasError) {
|
||||||
|
await this.updateAuthDb({
|
||||||
|
...oDoc,
|
||||||
|
info: { ...oDoc.info, ...info },
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: async (message: string) => {
|
onError: async (message: string) => {
|
||||||
|
hasError = true;
|
||||||
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
||||||
},
|
},
|
||||||
onLog: async (message: string) => {
|
onLog: async (message: string) => {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
FROM python:3.10-alpine3.18 AS builder
|
FROM node:22-slim AS nodebuilder
|
||||||
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
||||||
RUN set -x \
|
|
||||||
&& apk update \
|
|
||||||
&& apk add nodejs npm git \
|
|
||||||
&& npm i -g pnpm@8.3.1 pm2 ts-node \
|
|
||||||
&& cd /tmp/build \
|
|
||||||
&& pnpm install --prod
|
|
||||||
|
|
||||||
FROM python:3.10-alpine
|
FROM python:3.10-slim-bookworm AS builder
|
||||||
|
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
||||||
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
RUN set -x && \
|
||||||
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install --no-install-recommends -y libatomic1 && \
|
||||||
|
npm i -g pnpm@8.3.1 && \
|
||||||
|
cd /tmp/build && \
|
||||||
|
pnpm install --prod
|
||||||
|
|
||||||
|
FROM python:3.10-slim-bookworm
|
||||||
|
|
||||||
ARG QL_MAINTAINER="whyour"
|
ARG QL_MAINTAINER="whyour"
|
||||||
LABEL maintainer="${QL_MAINTAINER}"
|
LABEL maintainer="${QL_MAINTAINER}"
|
||||||
|
|
@ -21,69 +26,86 @@ ENV QL_DIR=/ql \
|
||||||
SHELL=/bin/bash \
|
SHELL=/bin/bash \
|
||||||
PS1="\u@\h:\w \$ "
|
PS1="\u@\h:\w \$ "
|
||||||
|
|
||||||
VOLUME /ql/data
|
ARG QL_UID=5432
|
||||||
|
ARG QL_GID=5432
|
||||||
|
RUN groupadd -g ${QL_GID} qinglong && \
|
||||||
|
useradd -m -u ${QL_UID} -g ${QL_GID} -s /bin/bash qinglong && \
|
||||||
|
mkdir -p /home/qinglong/bin /home/qinglong/.ssh && \
|
||||||
|
chmod 700 /home/qinglong/.ssh && \
|
||||||
|
chown -R ${QL_UID}:${QL_GID} /home/qinglong
|
||||||
|
|
||||||
EXPOSE 5700
|
ENV QL_USER=qinglong
|
||||||
|
ENV QL_HOME=/home/$QL_USER
|
||||||
|
|
||||||
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
COPY --from=builder /usr/local/bin/. /usr/local/bin/
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x && \
|
||||||
&& apk update -f \
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
&& apk upgrade \
|
apt-get update && \
|
||||||
&& apk --no-cache add -f bash \
|
apt-get upgrade -y && \
|
||||||
coreutils \
|
apt-get install --no-install-recommends -y git \
|
||||||
git \
|
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
tzdata \
|
tzdata \
|
||||||
perl \
|
perl \
|
||||||
openssl \
|
openssl \
|
||||||
nodejs \
|
openssh-client \
|
||||||
jq \
|
jq \
|
||||||
openssh \
|
|
||||||
procps \
|
procps \
|
||||||
netcat-openbsd \
|
netcat-openbsd \
|
||||||
unzip \
|
unzip \
|
||||||
npm \
|
libatomic1 && \
|
||||||
&& rm -rf /var/cache/apk/* \
|
apt-get clean && \
|
||||||
&& apk update \
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
echo "Asia/Shanghai" >/etc/timezone && \
|
||||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
git config --global user.email "qinglong@users.noreply.github.com" && \
|
||||||
&& git config --global user.email "qinglong@users.noreply.github.com" \
|
git config --global user.name "qinglong" && \
|
||||||
&& git config --global user.name "qinglong" \
|
git config --global http.postBuffer 524288000 && \
|
||||||
&& git config --global http.postBuffer 524288000 \
|
npm install -g pnpm@8.3.1 pm2 ts-node && \
|
||||||
&& rm -rf /root/.cache \
|
rm -rf /root/.cache && \
|
||||||
&& ulimit -c 0
|
rm -rf /root/.npm && \
|
||||||
|
rm -rf /etc/apt/apt.conf.d/docker-clean && \
|
||||||
|
ulimit -c 0
|
||||||
|
|
||||||
|
RUN mkdir -p ${QL_DIR} && \
|
||||||
|
chown -R ${QL_UID}:${QL_GID} ${QL_DIR}
|
||||||
|
|
||||||
|
USER qinglong
|
||||||
|
|
||||||
ARG SOURCE_COMMIT
|
ARG SOURCE_COMMIT
|
||||||
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
|
||||||
&& cd ${QL_DIR} \
|
cd ${QL_DIR} && \
|
||||||
&& cp -f .env.example .env \
|
cp -f .env.example .env && \
|
||||||
&& chmod 777 ${QL_DIR}/shell/*.sh \
|
chmod 777 ${QL_DIR}/shell/*.sh && \
|
||||||
&& chmod 777 ${QL_DIR}/docker/*.sh \
|
chmod 777 ${QL_DIR}/docker/*.sh && \
|
||||||
&& git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \
|
git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /tmp/static && \
|
||||||
&& mkdir -p ${QL_DIR}/static \
|
mkdir -p ${QL_DIR}/static && \
|
||||||
&& cp -rf /static/* ${QL_DIR}/static \
|
cp -rf /tmp/static/* ${QL_DIR}/static && \
|
||||||
&& rm -rf /static
|
rm -rf /tmp/static
|
||||||
|
|
||||||
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
||||||
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
||||||
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3 \
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
||||||
HOME=/root
|
|
||||||
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin:${HOME}/bin \
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
|
||||||
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
||||||
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
||||||
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
||||||
|
|
||||||
RUN pip3 install --prefix ${PYTHON_HOME} requests
|
RUN pip3 install --prefix ${PYTHON_HOME} requests
|
||||||
|
|
||||||
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
COPY --chown=qinglong:qinglong --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
WORKDIR ${QL_DIR}
|
WORKDIR ${QL_DIR}
|
||||||
|
|
||||||
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
||||||
CMD curl -sf --noproxy '*' http://127.0.0.1:${QlPort:-5700}/api/health || exit 1
|
CMD curl -sf --noproxy '*' http://127.0.0.1:5700/api/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
VOLUME /ql/data
|
||||||
|
|
||||||
|
EXPOSE 5700
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
FROM python:3.11-alpine3.18 AS builder
|
FROM node:22-slim AS nodebuilder
|
||||||
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
|
||||||
RUN set -x \
|
|
||||||
&& apk update \
|
|
||||||
&& apk add nodejs npm git \
|
|
||||||
&& npm i -g pnpm@8.3.1 pm2 ts-node \
|
|
||||||
&& cd /tmp/build \
|
|
||||||
&& pnpm install --prod
|
|
||||||
|
|
||||||
FROM python:3.11-alpine
|
FROM python:3.11-slim-bookworm AS builder
|
||||||
|
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
||||||
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
RUN set -x && \
|
||||||
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install --no-install-recommends -y libatomic1 && \
|
||||||
|
npm i -g pnpm@8.3.1 && \
|
||||||
|
cd /tmp/build && \
|
||||||
|
pnpm install --prod
|
||||||
|
|
||||||
|
FROM python:3.11-slim-bookworm
|
||||||
|
|
||||||
ARG QL_MAINTAINER="whyour"
|
ARG QL_MAINTAINER="whyour"
|
||||||
LABEL maintainer="${QL_MAINTAINER}"
|
LABEL maintainer="${QL_MAINTAINER}"
|
||||||
|
|
@ -21,69 +26,86 @@ ENV QL_DIR=/ql \
|
||||||
SHELL=/bin/bash \
|
SHELL=/bin/bash \
|
||||||
PS1="\u@\h:\w \$ "
|
PS1="\u@\h:\w \$ "
|
||||||
|
|
||||||
VOLUME /ql/data
|
ARG QL_UID=5432
|
||||||
|
ARG QL_GID=5432
|
||||||
|
RUN groupadd -g ${QL_GID} qinglong && \
|
||||||
|
useradd -m -u ${QL_UID} -g ${QL_GID} -s /bin/bash qinglong && \
|
||||||
|
mkdir -p /home/qinglong/bin /home/qinglong/.ssh && \
|
||||||
|
chmod 700 /home/qinglong/.ssh && \
|
||||||
|
chown -R ${QL_UID}:${QL_GID} /home/qinglong
|
||||||
|
|
||||||
EXPOSE 5700
|
ENV QL_USER=qinglong
|
||||||
|
ENV QL_HOME=/home/$QL_USER
|
||||||
|
|
||||||
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
|
||||||
COPY --from=builder /usr/local/bin/. /usr/local/bin/
|
COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x && \
|
||||||
&& apk update -f \
|
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
||||||
&& apk upgrade \
|
ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
|
||||||
&& apk --no-cache add -f bash \
|
apt-get update && \
|
||||||
coreutils \
|
apt-get upgrade -y && \
|
||||||
git \
|
apt-get install --no-install-recommends -y git \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
tzdata \
|
tzdata \
|
||||||
perl \
|
perl \
|
||||||
openssl \
|
openssl \
|
||||||
nodejs \
|
openssh-client \
|
||||||
jq \
|
jq \
|
||||||
openssh \
|
|
||||||
procps \
|
procps \
|
||||||
netcat-openbsd \
|
netcat-openbsd \
|
||||||
unzip \
|
unzip \
|
||||||
npm \
|
libatomic1 && \
|
||||||
&& rm -rf /var/cache/apk/* \
|
apt-get clean && \
|
||||||
&& apk update \
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
echo "Asia/Shanghai" >/etc/timezone && \
|
||||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
git config --global user.email "qinglong@users.noreply.github.com" && \
|
||||||
&& git config --global user.email "qinglong@users.noreply.github.com" \
|
git config --global user.name "qinglong" && \
|
||||||
&& git config --global user.name "qinglong" \
|
git config --global http.postBuffer 524288000 && \
|
||||||
&& git config --global http.postBuffer 524288000 \
|
npm install -g pnpm@8.3.1 pm2 ts-node && \
|
||||||
&& rm -rf /root/.cache \
|
rm -rf /root/.cache && \
|
||||||
&& ulimit -c 0
|
rm -rf /root/.npm && \
|
||||||
|
rm -rf /etc/apt/apt.conf.d/docker-clean && \
|
||||||
|
ulimit -c 0
|
||||||
|
|
||||||
|
RUN mkdir -p ${QL_DIR} && \
|
||||||
|
chown -R ${QL_UID}:${QL_GID} ${QL_DIR}
|
||||||
|
|
||||||
|
USER qinglong
|
||||||
ARG SOURCE_COMMIT
|
ARG SOURCE_COMMIT
|
||||||
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
|
||||||
&& cd ${QL_DIR} \
|
cd ${QL_DIR} && \
|
||||||
&& cp -f .env.example .env \
|
cp -f .env.example .env && \
|
||||||
&& chmod 777 ${QL_DIR}/shell/*.sh \
|
chmod 777 ${QL_DIR}/shell/*.sh && \
|
||||||
&& chmod 777 ${QL_DIR}/docker/*.sh \
|
chmod 777 ${QL_DIR}/docker/*.sh && \
|
||||||
&& git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \
|
git clone --depth=1 -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /tmp/static && \
|
||||||
&& mkdir -p ${QL_DIR}/static \
|
mkdir -p ${QL_DIR}/static && \
|
||||||
&& cp -rf /static/* ${QL_DIR}/static \
|
cp -rf /tmp/static/* ${QL_DIR}/static && \
|
||||||
&& rm -rf /static
|
rm -rf /tmp/static
|
||||||
|
|
||||||
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
||||||
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
||||||
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3 \
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
||||||
HOME=/root
|
|
||||||
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin:${HOME}/bin \
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
|
||||||
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
||||||
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
||||||
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
||||||
|
|
||||||
RUN pip3 install --prefix ${PYTHON_HOME} requests
|
RUN pip3 install --prefix ${PYTHON_HOME} requests
|
||||||
|
|
||||||
COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
COPY --chown=qinglong:qinglong --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
WORKDIR ${QL_DIR}
|
WORKDIR ${QL_DIR}
|
||||||
|
|
||||||
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
||||||
CMD curl -sf --noproxy '*' http://127.0.0.1:${QlPort:-5700}/api/health || exit 1
|
CMD curl -sf --noproxy '*' http://127.0.0.1:5700/api/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
VOLUME /ql/data
|
||||||
|
|
||||||
|
EXPOSE 5700
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH="$HOME/bin:$PATH"
|
||||||
|
|
||||||
dir_shell=/ql/shell
|
dir_shell=/ql/shell
|
||||||
. $dir_shell/share.sh
|
. $dir_shell/share.sh
|
||||||
|
|
||||||
|
|
@ -50,6 +52,6 @@ fi
|
||||||
|
|
||||||
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
||||||
|
|
||||||
crond -f >/dev/null
|
tail -f /dev/null
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
22
package.json
22
package.json
|
|
@ -1,6 +1,17 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"name": "@whyour/qinglong",
|
||||||
"packageManager": "pnpm@8.3.1",
|
"packageManager": "pnpm@8.3.1",
|
||||||
|
"version": "2.20.2-0",
|
||||||
|
"description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/whyour/qinglong.git"
|
||||||
|
},
|
||||||
|
"author": "whyour",
|
||||||
|
"license": "Apache License 2.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/whyour/qinglong/issues"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "concurrently -n w: npm:start:*",
|
"start": "concurrently -n w: npm:start:*",
|
||||||
"start:back": "nodemon ./back/app.ts",
|
"start:back": "nodemon ./back/app.ts",
|
||||||
|
|
@ -25,6 +36,11 @@
|
||||||
"prettier --parser=typescript --write"
|
"prettier --parser=typescript --write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"ql": "shell/update.sh",
|
||||||
|
"task": "shell/task.sh",
|
||||||
|
"qinglong": "shell/start.sh"
|
||||||
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
"peerDependencyRules": {
|
||||||
"ignoreMissing": [
|
"ignoreMissing": [
|
||||||
|
|
@ -77,9 +93,9 @@
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"multer": "2.1.1",
|
"multer": "1.4.5-lts.1",
|
||||||
"node-schedule": "^2.1.0",
|
"node-schedule": "^2.1.0",
|
||||||
"nodemailer": "^8.0.1",
|
"nodemailer": "^6.9.16",
|
||||||
"p-queue-cjs": "7.3.4",
|
"p-queue-cjs": "7.3.4",
|
||||||
"@bufbuild/protobuf": "^2.10.0",
|
"@bufbuild/protobuf": "^2.10.0",
|
||||||
"ps-tree": "^1.2.0",
|
"ps-tree": "^1.2.0",
|
||||||
|
|
|
||||||
827
pnpm-lock.yaml
827
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -259,13 +259,4 @@ export WEBHOOK_METHOD=""
|
||||||
## 支持 text/plain、application/json、multipart/form-data、application/x-www-form-urlencoded
|
## 支持 text/plain、application/json、multipart/form-data、application/x-www-form-urlencoded
|
||||||
export WEBHOOK_CONTENT_TYPE=""
|
export WEBHOOK_CONTENT_TYPE=""
|
||||||
|
|
||||||
## 23. OpeniLink
|
|
||||||
## 官方文档: https://openilink.com/docs/hub/apps
|
|
||||||
## 在 OpeniLink Hub 后台安装 App 后获取 app_token
|
|
||||||
export OPENILINK_APP_TOKEN=""
|
|
||||||
## OpeniLink Hub 地址,默认为 https://hub.openilink.com,自建 Hub 时填写自己的地址
|
|
||||||
export OPENILINK_HUB_URL=""
|
|
||||||
## OpeniLink 的 context_token,用于标识消息会话上下文,可从消息事件中获取
|
|
||||||
export OPENILINK_CONTEXT_TOKEN=""
|
|
||||||
|
|
||||||
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
||||||
|
|
|
||||||
|
|
@ -151,11 +151,6 @@ const push_config = {
|
||||||
WXPUSHER_APP_TOKEN: '', // wxpusher 的 appToken
|
WXPUSHER_APP_TOKEN: '', // wxpusher 的 appToken
|
||||||
WXPUSHER_TOPIC_IDS: '', // wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
WXPUSHER_TOPIC_IDS: '', // wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
||||||
WXPUSHER_UIDS: '', // wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
WXPUSHER_UIDS: '', // wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
||||||
|
|
||||||
// 官方文档: https://openilink.com/docs/hub/apps
|
|
||||||
OPENILINK_APP_TOKEN: '', // OpeniLink 的 app_token,在 OpeniLink Hub 后台安装 App 后获取
|
|
||||||
OPENILINK_HUB_URL: '', // OpeniLink Hub 地址,默认为 https://hub.openilink.com,自建 Hub 时填写自己的地址
|
|
||||||
OPENILINK_CONTEXT_TOKEN: '', // OpeniLink 的 context_token,用于标识消息会话上下文,可从消息事件中获取
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in push_config) {
|
for (const key in push_config) {
|
||||||
|
|
@ -1413,54 +1408,6 @@ function wxPusherNotify(text, desp) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openiLinkNotify(text, desp) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const { OPENILINK_APP_TOKEN, OPENILINK_HUB_URL, OPENILINK_CONTEXT_TOKEN } =
|
|
||||||
push_config;
|
|
||||||
if (OPENILINK_APP_TOKEN) {
|
|
||||||
const baseUrl = OPENILINK_HUB_URL
|
|
||||||
? OPENILINK_HUB_URL.replace(/\/$/, '')
|
|
||||||
: 'https://hub.openilink.com';
|
|
||||||
const body = {
|
|
||||||
type: 'text',
|
|
||||||
content: `${text}\n\n${desp}`,
|
|
||||||
};
|
|
||||||
if (OPENILINK_CONTEXT_TOKEN) {
|
|
||||||
body.context_token = OPENILINK_CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
url: `${baseUrl}/bot/v1/message/send`,
|
|
||||||
body: JSON.stringify(body),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${OPENILINK_APP_TOKEN}`,
|
|
||||||
},
|
|
||||||
timeout,
|
|
||||||
};
|
|
||||||
|
|
||||||
$.post(options, (err, resp, data) => {
|
|
||||||
try {
|
|
||||||
if (err) {
|
|
||||||
console.log('OpeniLink 发送通知消息失败!\n', err);
|
|
||||||
} else {
|
|
||||||
if (data.ok) {
|
|
||||||
console.log('OpeniLink 发送通知消息成功!');
|
|
||||||
} else {
|
|
||||||
console.log(`OpeniLink 发送通知消息异常:${data.error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
$.logErr(e, resp);
|
|
||||||
} finally {
|
|
||||||
resolve(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseString(input, valueFormatFn) {
|
function parseString(input, valueFormatFn) {
|
||||||
const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
|
const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
|
||||||
const matches = {};
|
const matches = {};
|
||||||
|
|
@ -1591,7 +1538,6 @@ async function sendNotify(text, desp, params = {}) {
|
||||||
qmsgNotify(text, desp), // 自定义通知
|
qmsgNotify(text, desp), // 自定义通知
|
||||||
ntfyNotify(text, desp), // Ntfy
|
ntfyNotify(text, desp), // Ntfy
|
||||||
wxPusherNotify(text, desp), // wxpusher
|
wxPusherNotify(text, desp), // wxpusher
|
||||||
openiLinkNotify(text, desp), // OpeniLink
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,6 @@ push_config = {
|
||||||
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
|
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
|
||||||
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
||||||
'WXPUSHER_UIDS': '', # wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
'WXPUSHER_UIDS': '', # wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
||||||
|
|
||||||
'OPENILINK_APP_TOKEN': '', # OpeniLink 的 app_token,在 OpeniLink Hub 后台安装 App 后获取 官方文档: https://openilink.com/docs/hub/apps
|
|
||||||
'OPENILINK_HUB_URL': '', # OpeniLink Hub 地址,默认为 https://hub.openilink.com,自建 Hub 时填写自己的地址
|
|
||||||
'OPENILINK_CONTEXT_TOKEN': '', # OpeniLink 的 context_token,用于标识消息会话上下文,可从消息事件中获取
|
|
||||||
}
|
}
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
@ -902,43 +898,6 @@ def wxpusher_bot(title: str, content: str) -> None:
|
||||||
print(f"wxpusher 推送失败!错误信息:{response.get('msg')}")
|
print(f"wxpusher 推送失败!错误信息:{response.get('msg')}")
|
||||||
|
|
||||||
|
|
||||||
def openilink(title: str, content: str) -> None:
|
|
||||||
"""
|
|
||||||
通过 OpeniLink 推送消息。
|
|
||||||
支持的环境变量:
|
|
||||||
- OPENILINK_APP_TOKEN: 在 OpeniLink Hub 后台安装 App 后获取的 app_token
|
|
||||||
- OPENILINK_HUB_URL: OpeniLink Hub 地址,默认为 https://hub.openilink.com
|
|
||||||
- OPENILINK_CONTEXT_TOKEN: 消息会话上下文 token,可从消息事件中获取
|
|
||||||
"""
|
|
||||||
if not push_config.get("OPENILINK_APP_TOKEN"):
|
|
||||||
return
|
|
||||||
|
|
||||||
print("OpeniLink 服务启动")
|
|
||||||
|
|
||||||
base_url = (
|
|
||||||
push_config.get("OPENILINK_HUB_URL", "").rstrip("/")
|
|
||||||
or "https://hub.openilink.com"
|
|
||||||
)
|
|
||||||
url = f"{base_url}/bot/v1/message/send"
|
|
||||||
headers = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Authorization": f'Bearer {push_config.get("OPENILINK_APP_TOKEN")}',
|
|
||||||
}
|
|
||||||
data = {
|
|
||||||
"type": "text",
|
|
||||||
"content": f"{title}\n\n{content}",
|
|
||||||
}
|
|
||||||
if push_config.get("OPENILINK_CONTEXT_TOKEN"):
|
|
||||||
data["context_token"] = push_config.get("OPENILINK_CONTEXT_TOKEN")
|
|
||||||
|
|
||||||
response = requests.post(url=url, json=data, headers=headers).json()
|
|
||||||
|
|
||||||
if response.get("ok"):
|
|
||||||
print("OpeniLink 推送成功!")
|
|
||||||
else:
|
|
||||||
print(f'OpeniLink 推送失败!错误信息:{response.get("error")}')
|
|
||||||
|
|
||||||
|
|
||||||
def parse_headers(headers):
|
def parse_headers(headers):
|
||||||
if not headers:
|
if not headers:
|
||||||
return {}
|
return {}
|
||||||
|
|
@ -1104,8 +1063,6 @@ def add_notify_function():
|
||||||
push_config.get("WXPUSHER_TOPIC_IDS") or push_config.get("WXPUSHER_UIDS")
|
push_config.get("WXPUSHER_TOPIC_IDS") or push_config.get("WXPUSHER_UIDS")
|
||||||
):
|
):
|
||||||
notify_function.append(wxpusher_bot)
|
notify_function.append(wxpusher_bot)
|
||||||
if push_config.get("OPENILINK_APP_TOKEN"):
|
|
||||||
notify_function.append(openilink)
|
|
||||||
if not notify_function:
|
if not notify_function:
|
||||||
print(f"无推送渠道,请检查通知变量是否正确")
|
print(f"无推送渠道,请检查通知变量是否正确")
|
||||||
return notify_function
|
return notify_function
|
||||||
|
|
|
||||||
10
shell/bot.sh
10
shell/bot.sh
|
|
@ -9,7 +9,15 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n1、安装bot依赖...\n"
|
echo -e "\n1、安装bot依赖...\n"
|
||||||
apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
|
os_name=$(source /etc/os-release && echo "$ID")
|
||||||
|
if [[ $os_name == 'alpine' ]]; then
|
||||||
|
apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
|
||||||
|
elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
|
||||||
|
apt-get install -y gcc python3-dev musl-dev
|
||||||
|
else
|
||||||
|
echo -e "暂不支持此系统 $os_name"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo -e "\nbot依赖安装成功...\n"
|
echo -e "\nbot依赖安装成功...\n"
|
||||||
|
|
||||||
echo -e "2、下载bot所需文件...\n"
|
echo -e "2、下载bot所需文件...\n"
|
||||||
|
|
|
||||||
16
shell/pub.sh
16
shell/pub.sh
|
|
@ -1,26 +1,26 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
echo -e "开始发布"
|
echo -e "开始发布"
|
||||||
|
|
||||||
echo -e "切换master分支"
|
echo -e "切换 debian 分支"
|
||||||
git branch -D master
|
git branch -D debian
|
||||||
git checkout -b master
|
git checkout -b debian
|
||||||
git push --set-upstream origin master -f
|
git push --set-upstream origin debian -f
|
||||||
|
|
||||||
echo -e "更新cdn文件"
|
echo -e "更新cdn文件"
|
||||||
ts-node-transpile-only sample/tool.ts
|
ts-node-transpile-only sample/tool.ts
|
||||||
|
|
||||||
string=$(cat version.yaml | grep "version" | egrep "[^ ]*" -o | egrep "\d\.*")
|
string=$(cat version.yaml | grep "version" | egrep "[^ ]*" -o | egrep "\d\.*")
|
||||||
version="v$string"
|
version="v$string"
|
||||||
echo -e "当前版本$version"
|
echo -e "当前版本$version-debian"
|
||||||
|
|
||||||
echo -e "删除已经存在的本地tag"
|
echo -e "删除已经存在的本地tag"
|
||||||
git tag -d "$version" &>/dev/null
|
git tag -d "$version-debian" &>/dev/null
|
||||||
|
|
||||||
echo -e "删除已经存在的远程tag"
|
echo -e "删除已经存在的远程tag"
|
||||||
git push origin :refs/tags/$version &>/dev/null
|
git push origin :refs/tags/$version-debian &>/dev/null
|
||||||
|
|
||||||
echo -e "创建新tag"
|
echo -e "创建新tag"
|
||||||
git tag -a "$version" -m "release $version"
|
git tag -a "$version-debian" -m "release $version-debian"
|
||||||
|
|
||||||
echo -e "提交tag"
|
echo -e "提交tag"
|
||||||
git push --tags
|
git push --tags
|
||||||
|
|
|
||||||
125
shell/start.sh
Normal file
125
shell/start.sh
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# 前置依赖 nodejs、npm、python3
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [[ ! $QL_DIR ]]; then
|
||||||
|
npm_dir=$(npm root -g)
|
||||||
|
pnpm_dir=$(pnpm root -g)
|
||||||
|
if [[ -d "$npm_dir/@whyour/qinglong" ]]; then
|
||||||
|
QL_DIR="$npm_dir/@whyour/qinglong"
|
||||||
|
elif [[ -d "$pnpm_dir/@whyour/qinglong" ]]; then
|
||||||
|
QL_DIR="$pnpm_dir/@whyour/qinglong"
|
||||||
|
else
|
||||||
|
echo -e "未找到 qinglong 模块,请先执行 npm i -g @whyour/qinglong 安装"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $QL_DIR ]]; then
|
||||||
|
echo -e "请先手动设置 export QL_DIR=$QL_DIR,环境变量,并手动添加到系统环境变量,然后再次执行命令 qinglong 启动服务"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! $QL_DATA_DIR ]]; then
|
||||||
|
echo -e "请先手动设置数据存储目录 export QL_DATA_DIR 环境变量,目录必须以斜杠开头的绝对路径,并且以 /data 结尾,例如 /ql/data 并手动添加到系统环境变量"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $QL_DATA_DIR != */data ]]; then
|
||||||
|
echo -e "QL_DATA_DIR 必须以 /data 结尾,例如 /ql/data,如果有历史数据,请新建 data 目录,把历史数据放到 data 目录中"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
command="$1"
|
||||||
|
|
||||||
|
if [[ $command != "reload" ]]; then
|
||||||
|
# 安装依赖
|
||||||
|
os_name=$(source /etc/os-release && echo "$ID")
|
||||||
|
|
||||||
|
if [[ $os_name == 'alpine' ]]; then
|
||||||
|
apk update
|
||||||
|
apk add -f bash \
|
||||||
|
coreutils \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
tzdata \
|
||||||
|
perl \
|
||||||
|
openssl \
|
||||||
|
jq \
|
||||||
|
nginx \
|
||||||
|
openssh \
|
||||||
|
procps \
|
||||||
|
netcat-openbsd
|
||||||
|
elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
|
||||||
|
else
|
||||||
|
echo -e "暂不支持此系统部署 $os_name"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm install -g pnpm@8.3.1 pm2 ts-node
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
|
||||||
|
export PNPM_HOME=${QL_DIR}/data/dep_cache/node
|
||||||
|
export PYTHON_HOME=${QL_DIR}/data/dep_cache/python3
|
||||||
|
export PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
||||||
|
|
||||||
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin
|
||||||
|
export NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules
|
||||||
|
export PIP_CACHE_DIR=${PYTHON_HOME}/pip
|
||||||
|
export PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
|
||||||
|
|
||||||
|
if [[ $command != "reload" ]]; then
|
||||||
|
pip3 install --prefix ${PYTHON_HOME} requests
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${QL_DIR}
|
||||||
|
cp -f .env.example .env
|
||||||
|
chmod 777 ${QL_DIR}/shell/*.sh
|
||||||
|
|
||||||
|
. ${QL_DIR}/shell/share.sh
|
||||||
|
. ${QL_DIR}/shell/env.sh
|
||||||
|
|
||||||
|
log_with_style() {
|
||||||
|
local level="$1"
|
||||||
|
local message="$2"
|
||||||
|
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||||
|
import_config "$@"
|
||||||
|
make_dir /etc/nginx/conf.d
|
||||||
|
make_dir /run/nginx
|
||||||
|
fix_config
|
||||||
|
|
||||||
|
pm2 l &>/dev/null
|
||||||
|
|
||||||
|
log_with_style "INFO" "🔄 2. 启动 nginx..."
|
||||||
|
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
log_with_style "INFO" "⚙️ 3. 启动 pm2 服务..."
|
||||||
|
reload_pm2
|
||||||
|
|
||||||
|
if [[ $command != "reload" ]]; then
|
||||||
|
if [[ $AutoStartBot == true ]]; then
|
||||||
|
log_with_style "INFO" "🤖 4. 启动 bot..."
|
||||||
|
nohup ql bot >$dir_log/bot.log 2>&1 &
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $EnableExtraShell == true ]]; then
|
||||||
|
log_with_style "INFO" "🛠️ 5. 执行自定义脚本..."
|
||||||
|
nohup ql extra >$dir_log/extra.log 2>&1 &
|
||||||
|
fi
|
||||||
|
|
||||||
|
pm2 startup
|
||||||
|
pm2 save
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_with_style "SUCCESS" "🎉 启动成功!"
|
||||||
|
|
@ -64,7 +64,7 @@ const Diff = () => {
|
||||||
const getFiles = () => {
|
const getFiles = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}configs/sample`)
|
.get(`${config.apiPrefix}configs/samples`)
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
setFiles(data);
|
setFiles(data);
|
||||||
|
|
|
||||||
|
|
@ -215,12 +215,12 @@ const Dependence = () => {
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={intl.get('Linux 软件包镜像源')}
|
label={intl.get('Linux 软件包镜像源')}
|
||||||
name="linux"
|
name="linux"
|
||||||
tooltip={intl.get('alpine linux 镜像源')}
|
tooltip={intl.get('debian linux 镜像源')}
|
||||||
>
|
>
|
||||||
<Input.Group compact>
|
<Input.Group compact>
|
||||||
<Input
|
<Input
|
||||||
style={{ width: 250 }}
|
style={{ width: 250 }}
|
||||||
placeholder={'https://mirrors.aliyun.com'}
|
placeholder={'http://mirrors.aliyun.com'}
|
||||||
value={systemConfig?.linuxMirror}
|
value={systemConfig?.linuxMirror}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSystemConfig({
|
setSystemConfig({
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ export default {
|
||||||
{ value: 'pushPlus', label: 'PushPlus' },
|
{ value: 'pushPlus', label: 'PushPlus' },
|
||||||
{ value: 'wePlusBot', label: intl.get('微加机器人') },
|
{ value: 'wePlusBot', label: intl.get('微加机器人') },
|
||||||
{ value: 'wxPusherBot', label: 'wxPusher' },
|
{ value: 'wxPusherBot', label: 'wxPusher' },
|
||||||
{ value: 'openiLink', label: 'OpeniLink' },
|
|
||||||
{ value: 'chat', label: intl.get('群晖chat') },
|
{ value: 'chat', label: intl.get('群晖chat') },
|
||||||
{ value: 'email', label: intl.get('邮箱') },
|
{ value: 'email', label: intl.get('邮箱') },
|
||||||
{ value: 'lark', label: intl.get('飞书机器人') },
|
{ value: 'lark', label: intl.get('飞书机器人') },
|
||||||
|
|
@ -388,27 +387,6 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
openiLink: [
|
|
||||||
{
|
|
||||||
label: 'openiLinkAppToken',
|
|
||||||
tip: intl.get(
|
|
||||||
'OpeniLink的app_token,在OpeniLink Hub后台安装App后获取,参考 https://openilink.com/docs/hub/apps',
|
|
||||||
),
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'openiLinkHubUrl',
|
|
||||||
tip: intl.get(
|
|
||||||
'OpeniLink Hub地址,默认为 https://hub.openilink.com,自建Hub时填写自己的地址',
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'openiLinkContextToken',
|
|
||||||
tip: intl.get(
|
|
||||||
'OpeniLink的context_token,用于标识消息会话上下文,可从消息事件中获取',
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
lark: [
|
lark: [
|
||||||
{
|
{
|
||||||
label: 'larkKey',
|
label: 'larkKey',
|
||||||
|
|
|
||||||
15
version.yaml
15
version.yaml
|
|
@ -1,6 +1,11 @@
|
||||||
version: 2.20.2
|
version: 2.20.1
|
||||||
changeLogLink: https://t.me/jiao_long/434
|
changeLogLink: https://t.me/jiao_long/433
|
||||||
publishTime: 2026-03-01 1800
|
publishTime: 2025-12-26 22:00
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 修复 path 安全漏洞(重要)
|
1. 修复获取依赖管理列表
|
||||||
|
2. notify.js 修复 TG_PROXY_AUTH 参数拼接
|
||||||
|
3. QLAPI.notify larkSecret 参数
|
||||||
|
4. 修复 cron parser 定时规则校验
|
||||||
|
5. 修复设置 baseUrl 后无法访问
|
||||||
|
6. 修复环境变量排序
|
||||||
|
7. 修复定时任务无法停止
|
||||||
Loading…
Reference in New Issue
Block a user