From 5fdfada5955180a6587d9e47d90c8847dcac58d7 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 23 Sep 2024 23:15:52 +0800 Subject: [PATCH] install: use mongodb 7 by default --- install/install.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/install/install.ts b/install/install.ts index 60e3c18b2..f8df6392a 100644 --- a/install/install.ts +++ b/install/install.ts @@ -24,6 +24,9 @@ const sleep = (t: number) => new Promise((r) => { setTimeout(r, t); }); const locales = { zh: { 'install.start': '开始运行 Hydro 安装工具', + 'note.avx': `检测到您的 CPU 不支持 avx 指令集,这可能会影响系统运行速度。 +如果您正在使用 PVE/VirtualBox 等虚拟机平台,请尝试关机后将虚拟机的 CPU 类型设置为 Host,重启后再次运行该脚本。 +您也可以选择忽略此问题,安装脚本将在一分钟后自动继续安装。`, 'warn.avx': '检测到您的 CPU 不支持 avx 指令集,将使用 mongodb@v4.4', 'error.rootRequired': '请先使用 sudo su 切换到 root 用户后再运行该工具。', 'error.unsupportedArch': '不支持的架构 %s ,请尝试手动安装。', @@ -51,6 +54,11 @@ const locales = { }, en: { 'install.start': 'Starting Hydro installation tool', + 'note.avx': `Your CPU does not support avx, this may affect system performance. +If you are using a virtual machine platform such as PVE/VirtualBox, +try shutting down and setting the CPU type of the virtual machine to Host, +then restart and run the script again. +You can also choose to ignore this issue, the installation script will continue in one minute.`, 'warn.avx': 'Your CPU does not support avx, will use mongodb@v4.4', 'error.rootRequired': 'Please run this tool as root user.', 'error.unsupportedArch': 'Unsupported architecture %s, please try to install manually.', @@ -308,6 +316,12 @@ const Steps = () => [ } } }, + async () => { + if (!avx && !installAsJudge) { + log.warn('note.avx'); + await sleep(60000); + } + }, () => { if (substituters.length) { writeFileSync('/etc/nix/nix.conf', `substituters = ${substituters.join(' ')} @@ -373,7 +387,7 @@ ${nixConfBase}`); "openssl-1.1.1z" ]; }`), - `nix-env -iA hydro.mongodb${avx ? 6 : 4}${CN ? '-cn' : ''} nixpkgs.mongosh nixpkgs.mongodb-tools`, + `nix-env -iA hydro.mongodb${avx ? 7 : 4}${CN ? '-cn' : ''} nixpkgs.mongosh nixpkgs.mongodb-tools`, ], }, { @@ -442,7 +456,9 @@ ${nixConfBase}`); readPreference: 'nearest', writeConcern: new WriteConcern('majority'), }); - await client.db('hydro').addUser('hydro', password, { + await client.db('hydro').command({ + createUser: 'hydro', + pwd: password, roles: [{ role: 'readWrite', db: 'hydro' }], }); await client.close(); @@ -466,7 +482,6 @@ ${nixConfBase}`); // The only thing mongod writes to stderr is 'libcurl no version information available' `pm2 start mongod --name mongodb -e /dev/null -- --auth --bind_ip 0.0.0.0 --wiredTigerCacheSizeGB=${wtsize}`, () => sleep(1000), - 'pm2 start hydrooj', async () => { if (noCaddy) return; if (!await isPortFree(80)) log.warn('port.80'); @@ -478,7 +493,9 @@ ${nixConfBase}`); exec('pm2 start caddy -- run', { cwd: `${process.env.HOME}/.hydro` }); exec('hydrooj cli system set server.xff x-forwarded-for'); exec('hydrooj cli system set server.xhost x-forwarded-host'); + exec('hydrooj cli system set server.xproxy true'); }, + 'pm2 start hydrooj', ], 'pm2 startup', 'pm2 save',