MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / Steps

Function Steps

install/install.ts:346–705  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

344];
345
346const 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='));

Callers 1

mainFunction · 0.85

Calls 14

nixInstallFunction · 0.85
rollbackResolveFieldFunction · 0.85
isPortFreeFunction · 0.85
findMethod · 0.80
logMethod · 0.80
execFunction · 0.70
sleepFunction · 0.70
getConfigFunction · 0.70
warnMethod · 0.45
pushMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected