mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
install: enable memory cgroup on rpi
This commit is contained in:
3 files changed
+23
-2
No files matched your search
+2
-1
@@ -22,7 +22,8 @@ echo "// File created by Hydro install script\n" >/tmp/install.js
|
||||
cat >/tmp/install.b64 << EOF123
|
||||
%PLACEHOLDER%
|
||||
EOF123
|
||||
cat /tmp/install.b64 | base64 -d >>/tmp/install.js
|
||||
cat /tmp/install.b64 | base64 -d >>/tmp/install.js.gz
|
||||
rm /tmp/install.b64
|
||||
gunzip /tmp/install.js.gz
|
||||
node /tmp/install.js "$@"
|
||||
set +e
|
||||
@@ -52,6 +52,7 @@ const locales = {
|
||||
'migrate.hustojFound': `检测到 HustOJ。安装程序可以将 HustOJ 中的全部数据导入到 Hydro。(原有数据不会丢失,您可随时切换回 HustOJ)
|
||||
该功能支持原版 HustOJ 和部分修改版,输入 y 确认该操作。
|
||||
迁移过程有任何问题,欢迎加QQ群 1085853538 咨询管理员。`,
|
||||
'install.restartRequired': '安装完成,请使用 sudo reboot 重启系统。在此之前系统的部分功能可能无法正常使用。',
|
||||
},
|
||||
en: {
|
||||
'install.start': 'Starting Hydro installation tool',
|
||||
@@ -85,6 +86,7 @@ To cancel the installation, please use Ctrl-C to exit. The installation program
|
||||
The original data will not be lost, and you can switch back to HustOJ at any time.
|
||||
This feature supports the original version of HustOJ and some modified versions. Enter y to confirm this operation.
|
||||
If you have any questions about the migration process, please add QQ group 1085853538 to consult the administrator.`,
|
||||
'install.restartRequired': 'Please reboot the system. Some functions may not work properly before the restart.',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -98,6 +100,8 @@ const substituters = substitutersArg ? substitutersArg.split('=')[1].split(',')
|
||||
const migrationArg = process.argv.find((i) => i.startsWith('--migration='));
|
||||
let migration = migrationArg ? migrationArg.split('=')[1] : '';
|
||||
|
||||
let needRestart = false;
|
||||
|
||||
let locale = (process.env.LANG?.includes('zh') || process.env.LOCALE?.includes('zh')) ? 'zh' : 'en';
|
||||
if (process.env.TERM === 'linux') locale = 'en';
|
||||
const processLog = (orig) => (str, ...args) => (orig(locales[locale][str] || str, ...args), 0);
|
||||
@@ -319,6 +323,21 @@ const Steps = () => [
|
||||
await sleep(60000);
|
||||
}
|
||||
},
|
||||
async () => {
|
||||
if (process.arch !== 'arm64') return;
|
||||
const isRpi = ['rpi', 'raspberrypi'].some((i) => readFileSync('/proc/cpuinfo', 'utf-8').toLowerCase().includes(i));
|
||||
if (!isRpi) return;
|
||||
const memoryLine = readFileSync('/proc/cgroups', 'utf-8').split('\n').find((i) => i.includes('memory'))?.trim();
|
||||
const memoryCgroupEnabled = memoryLine && !memoryLine.endsWith('0');
|
||||
if (memoryCgroupEnabled) return;
|
||||
let targetFile = '/boot/cmdline.txt';
|
||||
let content = readFileSync(targetFile, 'utf-8');
|
||||
if (content.includes('has moved to /boot/firmware/cmdline.txt')) targetFile = '/boot/firmware/cmdline.txt';
|
||||
content = readFileSync(targetFile, 'utf-8');
|
||||
if (content.includes('cgroup_enable=memory')) return;
|
||||
writeFileSync(targetFile, content.replace(' console=', ' cgroup_enable=memory cgroup_memory=1 console='));
|
||||
needRestart = true;
|
||||
},
|
||||
() => {
|
||||
if (substituters.length) {
|
||||
writeFileSync('/etc/nix/nix.conf', `substituters = ${substituters.join(' ')}
|
||||
@@ -603,6 +622,7 @@ ${nixConfBase}`);
|
||||
...printInfo,
|
||||
() => log.info('install.alldone'),
|
||||
() => installAsJudge && log.info('install.editJudgeConfigAndStart'),
|
||||
() => needRestart && log.info('install.restartRequired'),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
"main": "package.json",
|
||||
"scripts": {
|
||||
"build": "node build/prepare.js && tsc -b --verbose",
|
||||
"build:installer": "esbuild ./install/install.js --minify --format=cjs | base64",
|
||||
"build:installer": "esbuild ./install/install.js --minify --format=cjs | gzip -9 | base64",
|
||||
"build:watch": "node build/prepare.js && tsc -b --watch",
|
||||
"build:ui": "node packages/ui-default/build --iconfont && node packages/ui-default/build",
|
||||
"build:ui:iconfont": "node packages/ui-default/build --iconfont",
|
||||
|
||||
Reference in new issue
Block a user