()
| 344 | ]; |
| 345 | |
| 346 | const Steps = () => [ |
| 347 | { |
| 348 | init: 'install.preparing', |
| 349 | operations: [ |
| 350 | async () => { |
| 351 | if (process.env.IGNORE_BT) return; |
| 352 | const res = exec('bt default'); |
| 353 | if (!res.code) { |
| 354 | log.warn('error.bt'); |
| 355 | process.exit(1); |
| 356 | } |
| 357 | }, |
| 358 | async () => { |
| 359 | if (process.env.IGNORE_CENTOS) return; |
| 360 | const res = exec('yum -h'); |
| 361 | if (res.code) return; |
| 362 | if (!process.argv.includes('--unsupported-centos')) { |
| 363 | log.warn('error.centos'); |
| 364 | process.exit(1); |
| 365 | } else { |
| 366 | log.warn('warn.centos'); |
| 367 | warnings.push(['warn.centos']); |
| 368 | } |
| 369 | }, |
| 370 | async () => { |
| 371 | if (!avx && !installAsJudge) { |
| 372 | log.warn('note.avx'); |
| 373 | log.info('install.wait', 60); |
| 374 | await sleep(60000); |
| 375 | } |
| 376 | }, |
| 377 | async () => { |
| 378 | const shm = exec('df --output=avail -k /dev/shm').output?.split('\n')[1]; |
| 379 | if (!shm || !+shm) { |
| 380 | log.warn('shm.readFail'); |
| 381 | warnings.push(['shm.readFail']); |
| 382 | return; |
| 383 | } |
| 384 | const size = (+shm) / 1024; |
| 385 | if (size < 250) { |
| 386 | log.warn('shm.sizeTooSmall', size); |
| 387 | warnings.push(['shm.sizeTooSmall', size]); |
| 388 | } |
| 389 | }, |
| 390 | async () => { |
| 391 | // Enable memory cgroup for Raspberry Pi |
| 392 | if (process.arch !== 'arm64') return; |
| 393 | const isRpi = ['rpi', 'raspberrypi'].some((i) => readFileSync('/proc/cpuinfo', 'utf-8').toLowerCase().includes(i)); |
| 394 | if (!isRpi) return; |
| 395 | const memoryLine = readFileSync('/proc/cgroups', 'utf-8').split('\n').find((i) => i.includes('memory'))?.trim(); |
| 396 | const memoryCgroupEnabled = memoryLine && !memoryLine.endsWith('0'); |
| 397 | if (memoryCgroupEnabled) return; |
| 398 | let targetFile = '/boot/cmdline.txt'; |
| 399 | let content = readFileSync(targetFile, 'utf-8'); |
| 400 | if (content.includes('has moved to /boot/firmware/cmdline.txt')) targetFile = '/boot/firmware/cmdline.txt'; |
| 401 | content = readFileSync(targetFile, 'utf-8'); |
| 402 | if (content.includes('cgroup_enable=memory')) return; |
| 403 | writeFileSync(targetFile, content.replace(' console=', ' cgroup_enable=memory cgroup_memory=1 console=')); |
no test coverage detected