🆕 内置客户端安装脚本
This commit is contained in:
parent
0c6ea82be5
commit
a05056df32
@ -6,7 +6,7 @@ async function getHostList({ res }) {
|
||||
data?.sort((a, b) => Number(b.index || 0) - Number(a.index || 0))
|
||||
for (const item of data) {
|
||||
let { username, port, authType, _id: id, credential } = item
|
||||
console.log('解密凭证title: ', credential)
|
||||
// console.log('解密凭证title: ', credential)
|
||||
if (credential) credential = await AESDecryptSync(credential)
|
||||
const isConfig = Boolean(username && port && (item[authType]))
|
||||
Object.assign(item, { id, isConfig, password: '', privateKey: '', credential })
|
||||
|
@ -1,5 +1,6 @@
|
||||
const { writeKey, writeNotifyList, writeGroupList } = require('./utils/storage')
|
||||
const { KeyDB, NotifyDB, GroupDB, EmailNotifyDB } = require('./utils/db-class')
|
||||
const { readScriptList, writeScriptList } = require('./utils')
|
||||
|
||||
function initKeyDB() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -145,9 +146,38 @@ function initEmailNotifyDB() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function initScriptsDB() {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve) => {
|
||||
let scriptList = await readScriptList()
|
||||
let clientInstallScript = 'wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-instal.sh | bash'
|
||||
let clientUninstallScript = 'wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-uninstall.sh | bash'
|
||||
let clientVersion = process.env.CLIENT_VERSION
|
||||
consola.info('客户端版本:', clientVersion)
|
||||
let installId = `clientInstall${ clientVersion }`
|
||||
let uninstallId = `clientUninstall${ clientVersion }`
|
||||
|
||||
let isClientInstall = scriptList?.find(script => script._id = installId)
|
||||
let isClientUninstall = scriptList?.find(script => script._id = uninstallId)
|
||||
let writeFlag = false
|
||||
if (!isClientInstall) {
|
||||
scriptList.push({ _id: installId, name: `easynode-client-${ clientVersion }安装脚本`, remark: '系统内置|重启生成', content: clientInstallScript, index: 99 })
|
||||
writeFlag = true
|
||||
}
|
||||
if (!isClientUninstall) {
|
||||
scriptList.push({ _id: uninstallId, name: `easynode-client-${ clientVersion }卸载脚本`, remark: '系统内置|重启生成', content: clientUninstallScript, index: 98 })
|
||||
writeFlag = true
|
||||
}
|
||||
if (writeFlag) await writeScriptList(scriptList)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = async () => {
|
||||
await initKeyDB()
|
||||
await initNotifyDB()
|
||||
await initGroupDB()
|
||||
await initEmailNotifyDB()
|
||||
await initScriptsDB()
|
||||
}
|
@ -253,7 +253,7 @@ const writeScriptList = async (list = []) => {
|
||||
const scriptsDB = new ScriptsDB().getInstance()
|
||||
scriptsDB.remove({}, { multi: true }, (err) => {
|
||||
if (err) {
|
||||
consola.error('清空group list出错:', err)
|
||||
consola.error('清空scripts list出错:', err)
|
||||
reject(err)
|
||||
} else {
|
||||
scriptsDB.insert(list, (err, newDocs) => {
|
||||
|
@ -4,11 +4,16 @@
|
||||
<el-button type="primary" @click="addGroup">添加分组</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column prop="index" label="序号" />
|
||||
<el-table-column prop="index" label="序号" width="100px" />
|
||||
<el-table-column prop="name" label="分组名称" />
|
||||
<el-table-column label="关联实例数量">
|
||||
<template #default="{ row }">
|
||||
<el-popover v-if="row.hosts.list.length !== 0" placement="left" :width="350" trigger="hover">
|
||||
<el-popover
|
||||
v-if="row.hosts.list.length !== 0"
|
||||
placement="left"
|
||||
:width="350"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #reference>
|
||||
<u class="host_count">{{ row.hosts.count }}</u>
|
||||
</template>
|
||||
@ -30,15 +35,38 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-dialog v-model="groupFormVisible" width="600px" top="150px" :title="isModify ? '修改分组' : '添加分组'"
|
||||
:close-on-click-modal="false" @close="clearFormInfo">
|
||||
<el-form ref="updateFormRef" :model="groupForm" :rules="rules" :hide-required-asterisk="true" label-suffix=":"
|
||||
label-width="100px" :show-message="false">
|
||||
<el-dialog
|
||||
v-model="groupFormVisible"
|
||||
width="600px"
|
||||
top="150px"
|
||||
:title="isModify ? '修改分组' : '添加分组'"
|
||||
:close-on-click-modal="false"
|
||||
@close="clearFormInfo"
|
||||
>
|
||||
<el-form
|
||||
ref="updateFormRef"
|
||||
:model="groupForm"
|
||||
:rules="rules"
|
||||
:hide-required-asterisk="true"
|
||||
label-suffix=":"
|
||||
label-width="100px"
|
||||
:show-message="false"
|
||||
>
|
||||
<el-form-item label="分组名称" prop="name">
|
||||
<el-input v-model.trim="groupForm.name" clearable placeholder="" autocomplete="off" />
|
||||
<el-input
|
||||
v-model.trim="groupForm.name"
|
||||
clearable
|
||||
placeholder=""
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分组序号" prop="index">
|
||||
<el-input v-model.number="groupForm.index" clearable placeholder="用于分组排序" autocomplete="off" />
|
||||
<el-input
|
||||
v-model.number="groupForm.index"
|
||||
clearable
|
||||
placeholder="用于分组排序"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -122,7 +150,7 @@ const clearFormInfo = () => {
|
||||
}
|
||||
|
||||
const deleteGroup = ({ id, name }) => {
|
||||
$messageBox.confirm(`确认删除分组:${name} (分组下实例将移动至默认分组)`, 'Warning', {
|
||||
$messageBox.confirm(`确认删除分组:${ name } (分组下实例将移动至默认分组)`, 'Warning', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
@ -4,10 +4,10 @@
|
||||
<el-button type="primary" @click="addScript">添加脚本</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="scriptList">
|
||||
<el-table-column prop="index" label="序号" />
|
||||
<el-table-column prop="index" label="序号" width="100px" />
|
||||
<el-table-column prop="name" label="名称" />
|
||||
<el-table-column prop="remark" label="备注" />
|
||||
<el-table-column prop="content" label="脚本内容" />
|
||||
<el-table-column prop="content" label="脚本内容" show-overflow-tooltip />
|
||||
<el-table-column label="操作">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" @click="handleChange(row)">修改</el-button>
|
||||
@ -32,7 +32,7 @@
|
||||
label-width="100px"
|
||||
:show-message="false"
|
||||
>
|
||||
<el-form-item label="脚本名称" prop="name">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input
|
||||
v-model.trim="formData.name"
|
||||
clearable
|
||||
@ -40,7 +40,7 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本备注" prop="remark">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model.trim="formData.remark"
|
||||
clearable
|
||||
@ -48,7 +48,7 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本序号" prop="index">
|
||||
<el-form-item label="序号" prop="index">
|
||||
<el-input
|
||||
v-model.trim.number="formData.index"
|
||||
clearable
|
||||
@ -56,7 +56,7 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item prop="content" label="脚本内容" show-overflow-tooltip>
|
||||
<el-form-item prop="content" label="内容">
|
||||
<el-input
|
||||
v-model.trim="formData.content"
|
||||
type="textarea"
|
||||
|
Loading…
x
Reference in New Issue
Block a user