penguins-eggs 25.11.12 → 25.11.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/.oclif.manifest.json +149 -140
  2. package/README.md +726 -1
  3. package/README.pdf +1343 -2331
  4. package/addons/eggs/adapt/applications/eggs-adapt.desktop +0 -0
  5. package/addons/eggs/pve/applications/eggs-pve.desktop +0 -0
  6. package/addons/eggs/rsupport/applications/eggs-rsupport.desktop +0 -0
  7. package/addons/eggs/theme/applications/install-system.desktop +0 -0
  8. package/assets/calamares/install-system.sh +0 -0
  9. package/assets/penguins-eggs.desktop +0 -0
  10. package/assets/penguins-krill.desktop +0 -0
  11. package/assets/penguins-links-add.desktop +0 -0
  12. package/assets/penguins-live-installer.desktop +0 -0
  13. package/bin/dev.js +0 -0
  14. package/conf/distros/alpine/calamares/calamares-modules/machineid-openrc/machineid-openrc.sh +0 -0
  15. package/conf/distros/buster/calamares/calamares-modules/cleanup/cleanup.sh +0 -0
  16. package/conf/distros/buster/calamares/calamares-modules/dpkg-unsafe-io/dpkg-unsafe-io.sh +0 -0
  17. package/conf/distros/buster/calamares/calamares-modules/sources-yolk/sources-yolk.sh +0 -0
  18. package/conf/distros/fedora/calamares/calamares-modules/bootloaderspecification/bootloaderspecification.sh +0 -0
  19. package/conf/distros/focal/calamares/calamares-modules/.keepit +0 -0
  20. package/conf/distros/focal/calamares/calamares-modules/cleanup/cleanup.sh +20 -0
  21. package/conf/distros/focal/calamares/calamares-modules/cleanup/module.yml +9 -0
  22. package/conf/distros/focal/calamares/calamares-modules/sources-yolk/module.yml +8 -0
  23. package/conf/distros/focal/calamares/calamares-modules/sources-yolk/sources-yolk.sh +50 -0
  24. package/conf/distros/focal/calamares/calamares-modules/sources-yolk-undo/module.yml +8 -0
  25. package/conf/distros/focal/calamares/libexec/.keepit +0 -0
  26. package/conf/distros/focal/calamares/libexec/README.md +5 -0
  27. package/conf/distros/focal/calamares/libexec/calamares-aptsources.sh +15 -0
  28. package/conf/distros/focal/calamares/libexec/calamares-l10n-helper.sh +38 -0
  29. package/conf/distros/focal/calamares/libexec/calamares-logs-helper.sh +34 -0
  30. package/conf/distros/focal/calamares/libexec/calamares-nomodeset.sh +19 -0
  31. package/conf/distros/focal/calamares/modules/after_bootloader_context.yml +26 -0
  32. package/conf/distros/focal/calamares/modules/before_bootloader_context.yml +12 -0
  33. package/conf/distros/focal/calamares/modules/bootloader.yml +86 -0
  34. package/conf/distros/focal/calamares/modules/bootloader.yml.old +35 -0
  35. package/conf/distros/focal/calamares/modules/displaymanager.yml +12 -0
  36. package/conf/distros/focal/calamares/modules/finished.yml +6 -0
  37. package/conf/distros/focal/calamares/modules/fstab.yml +63 -0
  38. package/conf/distros/focal/calamares/modules/grubcfg.yml +51 -0
  39. package/conf/distros/focal/calamares/modules/keyboard.yml +29 -0
  40. package/conf/distros/focal/calamares/modules/locale.yml +7 -0
  41. package/conf/distros/focal/calamares/modules/machineid.yml +10 -0
  42. package/conf/distros/focal/calamares/modules/mount.yml +20 -0
  43. package/conf/distros/focal/calamares/modules/netinstall.yml +5 -0
  44. package/conf/distros/focal/calamares/modules/packages.mustache +5 -0
  45. package/conf/distros/focal/calamares/modules/partition.yml +21 -0
  46. package/conf/distros/focal/calamares/modules/removeuser.mustache +3 -0
  47. package/conf/distros/focal/calamares/modules/shellprocess@aptsources.yml +11 -0
  48. package/conf/distros/focal/calamares/modules/shellprocess@boot_deploy.yml +9 -0
  49. package/conf/distros/focal/calamares/modules/shellprocess@boot_reconfigure.yml +15 -0
  50. package/conf/distros/focal/calamares/modules/shellprocess@install_translations.yml +8 -0
  51. package/conf/distros/focal/calamares/modules/shellprocess@logs.yml +8 -0
  52. package/conf/distros/focal/calamares/modules/shellprocess@mkinitramfs.yml +6 -0
  53. package/conf/distros/focal/calamares/modules/shellprocess@nomodeset.yml +12 -0
  54. package/conf/distros/focal/calamares/modules/umount.yml +4 -0
  55. package/conf/distros/focal/calamares/modules/unpackfs.mustache +6 -0
  56. package/conf/distros/focal/calamares/modules/users.yml +27 -0
  57. package/conf/distros/focal/calamares/modules/welcome.yml +24 -0
  58. package/conf/distros/focal/calamares/settings.yml +97 -0
  59. package/conf/distros/noble/calamares/calamares-modules/cleanup/cleanup.sh +0 -0
  60. package/conf/distros/noble/calamares/calamares-modules/sources-yolk/sources-yolk.sh +0 -0
  61. package/conf/distros/noble/calamares/libexec/calamares-aptsources.sh +0 -0
  62. package/conf/distros/noble/calamares/libexec/calamares-l10n-helper.sh +0 -0
  63. package/conf/distros/noble/calamares/libexec/calamares-logs-helper.sh +0 -0
  64. package/conf/distros/noble/calamares/libexec/calamares-nomodeset.sh +0 -0
  65. package/conf/distros/opensuse/calamares/calamares-modules/bootloaderspecification/bootloaderspecification.sh +0 -0
  66. package/conf/distros/opensuse/calamares/settings.yml +0 -0
  67. package/conf/distros/opensuse/calamares/zstd2lzo.sh +0 -0
  68. package/conf/distros/trixie/calamares/calamares-modules/cleanup/cleanup.sh +0 -0
  69. package/conf/distros/trixie/calamares/calamares-modules/dpkg-unsafe-io/dpkg-unsafe-io.sh +0 -0
  70. package/conf/distros/trixie/calamares/calamares-modules/sources-yolk/sources-yolk.sh +0 -0
  71. package/conf/init/unattended.sh +0 -0
  72. package/dist/appimage/first-run-check.d.ts +8 -0
  73. package/dist/appimage/first-run-check.js +13 -0
  74. package/dist/appimage/prerequisites.d.ts +34 -0
  75. package/dist/appimage/prerequisites.js +350 -0
  76. package/dist/bin/dev.cmd +3 -0
  77. package/dist/bin/dev.js +6 -0
  78. package/dist/bin/run.cmd +3 -0
  79. package/dist/bin/run.js +5 -0
  80. package/dist/classes/cli-autologin.js +4 -4
  81. package/dist/classes/diversions.d.ts +5 -0
  82. package/dist/classes/diversions.js +23 -7
  83. package/dist/classes/pacman.js +10 -11
  84. package/dist/classes/utils.d.ts +4 -0
  85. package/dist/classes/utils.js +19 -3
  86. package/dist/commands/calamares.js +1 -1
  87. package/dist/commands/config.js +2 -2
  88. package/dist/commands/{analyze.d.ts → export/appimage.d.ts} +10 -9
  89. package/dist/commands/export/appimage.js +76 -0
  90. package/dist/commands/export/iso.js +1 -1
  91. package/dist/commands/export/pkg.d.ts +1 -1
  92. package/dist/commands/export/pkg.js +2 -2
  93. package/dist/commands/{install.d.ts → krill.d.ts} +3 -4
  94. package/dist/commands/{install.js → krill.js} +5 -6
  95. package/dist/commands/produce.js +1 -1
  96. package/dist/commands/setup.d.ts +21 -0
  97. package/dist/commands/setup.js +90 -0
  98. package/dist/commands/tools/repo.d.ts +0 -5
  99. package/dist/commands/tools/repo.js +205 -127
  100. package/dist/commands/update.d.ts +1 -1
  101. package/dist/commands/update.js +68 -59
  102. package/dist/krill/components/information.js +2 -2
  103. package/dist/krill/components/title.js +13 -13
  104. package/dist/lib/utils.d.ts +16 -0
  105. package/dist/lib/utils.js +24 -32
  106. package/dracut/create-symlink +0 -0
  107. package/dracut/export +0 -0
  108. package/dracut/export-dracut-analysis +0 -0
  109. package/dracut/export-dracut-log +0 -0
  110. package/dracut/mkisofs +0 -0
  111. package/dracut/modules.d/00debug-shell/debug-hook.sh +0 -0
  112. package/dracut/modules.d/00debug-shell/module-setup.sh +0 -0
  113. package/dracut/modules.d/90block/block-cmdline.sh +0 -0
  114. package/dracut/modules.d/90block/module-setup.sh +0 -0
  115. package/dracut/modules.d/95iso-scan/iso-scan-fallback.sh +0 -0
  116. package/dracut/modules.d/95iso-scan/iso-scan.sh +0 -0
  117. package/dracut/modules.d/95iso-scan/module-setup.sh +0 -0
  118. package/dracut/modules.d/95luks-loop/luks-loop.sh +0 -0
  119. package/dracut/modules.d/95luks-loop/module-setup.sh +0 -0
  120. package/dracut/renew-initramfs +0 -0
  121. package/dracut/sbin2bin +0 -0
  122. package/dracut/update-dracut-conf-d +0 -0
  123. package/dracut/update-dracut-modules +0 -0
  124. package/eui/eui-autostart-cinnamon.desktop +0 -0
  125. package/eui/eui-autostart-xfce.desktop +0 -0
  126. package/eui/eui-create-image.sh +0 -0
  127. package/eui/eui-start.sh +0 -0
  128. package/manpages/doc/man/eggs.1.gz +0 -0
  129. package/manpages/doc/man/eggs.html +582 -9
  130. package/package.json +125 -130
  131. package/perrisbrewery/scripts/postinst +0 -0
  132. package/perrisbrewery/scripts/postrm +0 -0
  133. package/perrisbrewery/scripts/preinst +0 -0
  134. package/perrisbrewery/scripts/prerm +0 -0
  135. package/perrisbrewery/template/dependencies.yaml +0 -5
  136. package/perrisbrewery/template/man.template.md +7 -0
  137. package/scripts/99clean +0 -0
  138. package/scripts/_eggs +28 -47
  139. package/scripts/adapt.sh +0 -0
  140. package/scripts/appimage-build.sh +152 -0
  141. package/scripts/appimage-install.sh +43 -0
  142. package/scripts/bros/waydroid-helper.sh +0 -0
  143. package/scripts/eggs.bash +3 -4
  144. package/scripts/lsb_release +0 -0
  145. package/scripts/mom.sh +0 -0
  146. package/scripts/pve-live.service +0 -0
  147. package/scripts/pve-live.sh +0 -0
  148. package/scripts/resy +0 -0
  149. package/dist/commands/analyze.js +0 -95
  150. package/dist/commands/pods.d.ts +0 -22
  151. package/dist/commands/pods.js +0 -92
  152. package/scripts/boot-encrypted-root.sh +0 -220
  153. package/scripts/mount-encrypted-home.sh +0 -324
package/scripts/eggs.bash CHANGED
@@ -12,21 +12,20 @@ _eggs_autocomplete()
12
12
 
13
13
  local commands="
14
14
  adapt --help --verbose
15
- analyze --help --verbose
16
15
  calamares --help --install --nointeractive --policies --release --remove --theme --verbose
17
16
  config --clean --help --nointeractive --verbose
18
17
  cuckoo --help --verbose
19
18
  dad --clean --default --file --nointeractive --help --verbose
19
+ export:appimage --clean --help --verbose
20
20
  export:iso --checksum --clean --help --verbose
21
21
  export:pkg --all --clean --help --verbose
22
22
  export:tarballs --clean --help --verbose
23
- install --btrfs --chroot --crypted --domain --halt --help --ip --nointeractive --none --pve --random --replace --small --suspend --testing --unattended --verbose
24
- krill --btrfs --chroot --crypted --domain --halt --help --ip --nointeractive --none --pve --random --replace --small --suspend --testing --unattended --verbose
25
23
  kill --help --isos --nointeractive --verbose
24
+ krill --btrfs --chroot --crypted --domain --halt --help --ip --nointeractive --none --pve --random --replace --small --suspend --testing --unattended --verbose
26
25
  love --help --verbose --hidden --nointeractive --clone --homecrypt --fullcrypt
27
26
  mom --help
28
- pods --help
29
27
  produce --addons --basename --clone --homecrypt --fullcrypt --excludes --help --hidden --kernel --links --max --noicon --nointeractive --pendrive --prefix --release --script --standard --theme --includeRootHome --verbose --yolk
28
+ setup --check --force
30
29
  status --help --verbose
31
30
  tools:clean --help --nointeractive --verbose
32
31
  tools:repo --add --help --nointeractive --remove --verbose
File without changes
package/scripts/mom.sh CHANGED
File without changes
File without changes
File without changes
package/scripts/resy CHANGED
File without changes
@@ -1,95 +0,0 @@
1
- /**
2
- * ./src/commands/analyze.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import { Command, Flags } from '@oclif/core';
9
- import fs, { constants } from 'node:fs';
10
- import { access } from 'node:fs/promises';
11
- import si from 'systeminformation';
12
- import Users from '../classes/users.js';
13
- import Utils from '../classes/utils.js';
14
- export default class Analyze extends Command {
15
- static description = 'analyze for syncto';
16
- static examples = ['sudo eggs analyze'];
17
- static flags = {
18
- help: Flags.help({ char: 'h' }),
19
- verbose: Flags.boolean({ char: 'v', description: 'verbose' })
20
- };
21
- config_file = '/etc/penguins-eggs.d/eggs.yaml';
22
- snapshot_dir = '';
23
- work_dir = {};
24
- /**
25
- * fill
26
- */
27
- async fill() {
28
- try {
29
- const usersArray = [];
30
- await access('/etc/passwd', constants.R_OK | constants.W_OK);
31
- const passwd = fs.readFileSync('/etc/passwd', 'utf8').split('\n');
32
- for (const element of passwd) {
33
- const line = element.split(':');
34
- const users = new Users(line[0], line[1], line[2], line[3], line[4], line[5], line[6]);
35
- await users.getValues();
36
- if (users.password !== undefined) {
37
- usersArray.push(users);
38
- }
39
- }
40
- return usersArray;
41
- }
42
- catch {
43
- console.error("can't read /etc/passwd");
44
- process.exit(1);
45
- }
46
- }
47
- async run() {
48
- Utils.titles(this.id + ' ' + this.argv);
49
- const { flags } = await this.parse(Analyze);
50
- let verbose = false;
51
- if (flags.verbose) {
52
- verbose = true;
53
- }
54
- Utils.warning('eggs will analyze your system, and get users data');
55
- const echo = Utils.setEcho(verbose);
56
- let totalSize = 0;
57
- if (Utils.isRoot(this.id)) {
58
- const audio = await si.audio();
59
- const bios = await si.bios();
60
- const blockDevices = await si.blockDevices();
61
- const chassis = await si.chassis();
62
- const cpu = await si.cpu();
63
- const diskLayout = await si.diskLayout();
64
- const mem = await si.mem();
65
- const usb = await si.usb();
66
- console.log(`chassis: ${chassis.manufacturer} model: ${chassis.manufacturer}`);
67
- console.log(`bios vendor: ${bios.vendor} version: ${bios.version} revision: ${bios.revision}`);
68
- console.log(`processor: ${cpu.brand} core: ${cpu.cores} `);
69
- if (diskLayout[0].device !== undefined) {
70
- console.log(`disk0: ${diskLayout[0].device}`);
71
- }
72
- if (diskLayout[1] !== undefined) {
73
- console.log(`disk1: ${diskLayout[1].device}`);
74
- }
75
- if (diskLayout[2] !== undefined) {
76
- console.log(`disk1: ${diskLayout[2].device}`);
77
- }
78
- // console.log(`name: ${blockDevices[0].name} fs: ${blockDevices[0].fsType}`)
79
- // console.log(`name: ${blockDevices[1].name} fs: ${blockDevices[1].fsType}`)
80
- // console.log(`name: ${blockDevices[2].name} fs: ${blockDevices[2].fsType}`)
81
- // console.log(`name: ${blockDevices[3].name} fs: ${blockDevices[3].fsType}`)
82
- // console.log(`usb: ${usb[0].name}`)
83
- const users = await this.fill();
84
- for (let i = 0; i < users.length; i++)
85
- if (users[i].saveIt) {
86
- console.log(`user: ${users[i].login} \thome: ${users[i].home.padEnd(16)} \tsize: ${Utils.formatBytes(users[i].size)} \tBytes: ${users[i].size} `);
87
- totalSize += users[i].size;
88
- }
89
- console.log(`Total\t\t\t\t\tSize: ${Utils.formatBytes(totalSize)} \tBytes: ${totalSize}`);
90
- }
91
- else {
92
- Utils.useRoot(this.id);
93
- }
94
- }
95
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * ./src/commands/cuckoo.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import { Command } from '@oclif/core';
9
- export default class Pods extends Command {
10
- static args: {
11
- distro: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
12
- };
13
- static description: string;
14
- static examples: string[];
15
- static flags: {
16
- help: import("@oclif/core/interfaces").BooleanFlag<void>;
17
- };
18
- /**
19
- *
20
- */
21
- run(): Promise<void>;
22
- }
@@ -1,92 +0,0 @@
1
- /**
2
- * ./src/commands/cuckoo.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import { Args, Command, Flags } from '@oclif/core';
9
- import fs from 'fs';
10
- import Utils from '../classes/utils.js';
11
- import { exec } from '../lib/utils.js';
12
- import path from 'node:path';
13
- import { execSync } from 'node:child_process';
14
- // _dirname
15
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
16
- export default class Pods extends Command {
17
- static args = {
18
- distro: Args.string({ description: 'distro to build', name: 'distro', required: false })
19
- };
20
- static description = 'eggs pods: build ISOs from containers';
21
- static examples = [
22
- 'eggs pods archlinux',
23
- 'eggs pods debian',
24
- 'eggs pods ubuntu',
25
- ];
26
- static flags = {
27
- help: Flags.help({ char: 'h' })
28
- };
29
- /**
30
- *
31
- */
32
- async run() {
33
- Utils.titles(this.id + ' ' + this.argv);
34
- const { args, flags } = await this.parse(Pods);
35
- if (!isPodmanInstalledSync()) {
36
- console.log('You need to install podmand to use this command');
37
- process.exit(0);
38
- }
39
- if (process.getuid && process.getuid() === 0) {
40
- Utils.warning('You must use eggs pods without sudo');
41
- process.exit(0);
42
- }
43
- // mode
44
- let pathPods = path.resolve(__dirname, `../../pods`);
45
- const userHome = `/home/${await Utils.getPrimaryUser()}/`;
46
- if (Utils.isSources()) {
47
- console.log("Using eggs pods from sources.\nThe pods directory of the source will be used ");
48
- }
49
- else {
50
- console.log("Using eggs pods from package.");
51
- if (!fs.existsSync(`${userHome}/pods`)) {
52
- console.log(`The pods directory will be created in the user home ${userHome}, do you want to continue?`);
53
- if (await Utils.customConfirm()) {
54
- console.log(`Creating a pods folder under ${userHome}`);
55
- await exec(`cp -r ${Utils.rootPenguin()}/pods ${userHome}`);
56
- }
57
- }
58
- pathPods = path.resolve(`${userHome}/pods`);
59
- }
60
- console.log(`Using ${pathPods}`);
61
- let distro = 'debian';
62
- if (this.argv['0'] !== undefined) {
63
- distro = this.argv['0'];
64
- }
65
- let cmd = `${pathPods}/${distro}.sh`;
66
- if (fs.existsSync(cmd)) {
67
- console.log(`We are building a egg from a ${distro} container`);
68
- if (!await Utils.customConfirm()) {
69
- process.exit(0);
70
- }
71
- await exec(cmd);
72
- }
73
- else {
74
- console.log(`No script: ${cmd} fpr ${distro} container`);
75
- }
76
- }
77
- }
78
- /**
79
- *
80
- * @returns
81
- */
82
- function isPodmanInstalledSync() {
83
- let podmanInstalled = false;
84
- try {
85
- execSync('podman --version', { stdio: 'ignore' });
86
- podmanInstalled = true;
87
- }
88
- catch (error) {
89
- console.error('Podman does not appear to be installed or is not in the PATH.\n');
90
- }
91
- return podmanInstalled;
92
- }
@@ -1,220 +0,0 @@
1
- #!/bin/sh
2
- # /scripts/live-premount/boot-encrypted-root.sh
3
- #
4
- # This script is designed to Boot Encrypted Linux Live (BELL).
5
- #
6
- # Its main purpose is to find an encrypted root image file (root.img) 
7
- # on a live USB/DVD, ask the user for a passphrase to unlock it, 
8
- # and then copy the main system filesystem (filesystem.squashfs) 
9
- # from inside the encrypted image into RAM.
10
-
11
- # the process continue with standard live-boot 
12
-
13
- # enable echo
14
- # set -e
15
-
16
- echo "BELL: Boot Encrypted Linux Live"
17
-
18
- #################################################
19
- # 1. Setup and Find Media
20
-
21
- # 1.1 load modules
22
- echo "BELL: loading modules..."
23
- modprobe loop 2>/dev/null || true
24
- modprobe dm_mod 2>/dev/null || true
25
- modprobe dm_crypt 2>/dev/null || true
26
- modprobe overlay 2>/dev/null || true
27
- modprobe ext4 2>/dev/null || true
28
- modprobe squashfs 2>/dev/null || true
29
- sleep 2
30
-
31
-
32
- # 1.2 find BELL media drive
33
- echo "BELL: find BELL media drive..."
34
- mkdir -p /mnt/live-media /mnt/ext4
35
- BELL_MEDIA_MNT="/mnt/live-media"
36
- LIVE_DEV=""
37
-
38
- # find to max 20 devices
39
- MAX_WAIT_DEV=20; COUNT_DEV=0
40
- while [ -z "$LIVE_DEV" ] && [ $COUNT_DEV -lt $MAX_WAIT_DEV ]; do
41
- ls /dev > /dev/null
42
- for dev in /dev/sr* /dev/sd* /dev/vd* /dev/nvme*n*; do
43
- if [ ! -b "$dev" ]; then continue; fi
44
- if mount -o ro "$dev" "$BELL_MEDIA_MNT" 2>/dev/null; then
45
- if [ -f "${BELL_MEDIA_MNT}/live/root.img" ]; then
46
- echo "BELL: Found BELL media on $dev"
47
- LIVE_DEV=$dev
48
- break 2
49
- else
50
- umount "$BELL_MEDIA_MNT" 2>/dev/null || true
51
- fi
52
- fi
53
- done
54
- sleep 1
55
- COUNT_DEV=$((COUNT_DEV+1))
56
- done
57
-
58
- if [ -z "$LIVE_DEV" ]; then
59
- echo "BELL: Error: no live BELL drive found!"
60
- ls /dev
61
- exit 1
62
- fi
63
-
64
- ROOT_IMG_RO="${BELL_MEDIA_MNT}/live/root.img"
65
- RAM_MEDIA_MNT="/run/live/medium" # final destination in RAM
66
-
67
-
68
- #################################################
69
- # 2. Prepare Encrypted Image
70
-
71
- # 2.1 loop device
72
- echo "BELL: loop device association for $ROOT_IMG_RO..."
73
- LOOP_DEV_OUTPUT=$(/sbin/losetup -f --show "$ROOT_IMG_RO" 2>/dev/null); LOSETUP_EXIT_STATUS=$?
74
- if [ $LOSETUP_EXIT_STATUS -ne 0 ] || [ -z "$LOOP_DEV_OUTPUT" ] || ! [ -b "$LOOP_DEV_OUTPUT" ]; then
75
- echo "BELL: Error: loop association failed!"
76
- exit 1
77
- fi
78
- LOOP_DEV="$LOOP_DEV_OUTPUT"
79
- echo "BELL: loop device $ROOT_IMG_RO associated to: $LOOP_DEV"
80
-
81
-
82
-
83
- #################################################
84
- # 3. Unlock LUKS (User Interaction)
85
-
86
- # disable 'set -e' to let 3 tempts 
87
- #set +e
88
- MAX_ATTEMPTS=3
89
- ATTEMPT=1
90
- UNLOCKED=0
91
-
92
- while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
93
-
94
- # check if plymouth is active
95
- if plymouth --ping 2>/dev/null; then
96
-
97
- # request the password in plymouth and pass it to cryptsetup via stdin (--key-file -)
98
- if plymouth ask-for-password --prompt="Enter passphrase ($ATTEMPT/$MAX_ATTEMPTS)" | cryptsetup open --readonly --key-file - "$LOOP_DEV" live-root; then
99
- UNLOCKED=1
100
- break
101
- else
102
- if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
103
- plymouth display-message --text="Incorrect passphrase. Try again..."
104
- sleep 2 # wait 2 seconds to read message
105
- fi
106
- fi
107
- else
108
- # Fallback: Plymouth not active
109
- echo "Please enter passphrase for $LOOP_DEV ($ATTEMPT/$MAX_ATTEMPTS):"
110
-
111
- if cryptsetup open --readonly "$LOOP_DEV" live-root; then
112
- UNLOCKED=1
113
- break
114
- else
115
- if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
116
- echo "Incorrect passphrase. Please try again."
117
- fi
118
- fi
119
- fi
120
-
121
- ATTEMPT=$((ATTEMPT + 1))
122
- sleep 1
123
- done
124
-
125
- # Enable echo
126
- # set -e
127
-
128
- # check if all attempts have failed
129
- if [ $UNLOCKED -eq 0 ]; then
130
- if plymouth --ping 2>/dev/null; then
131
- plymouth display-message --text="LUKS Unlock Failed: Max attempts reached"
132
- sleep 5
133
- fi
134
- /sbin/losetup -d "$LOOP_DEV" || true
135
- exit 1
136
- fi
137
-
138
- echo "BELL: LUKS unlocked ($LOOP_DEV -> live-root) [readonly]. Waiting for mapper..."
139
-
140
-
141
- #################################################
142
- # 4. copy System to RAM
143
-
144
- # 4.1 waiting mapper
145
- MAX_WAIT_MAP=10; COUNT_MAP=0
146
- while [ ! -b /dev/mapper/live-root ] && [ $COUNT_MAP -lt $MAX_WAIT_MAP ]; do
147
- sleep 1
148
- COUNT_MAP=$((COUNT_MAP+1))
149
- done
150
-
151
- if [ ! -b /dev/mapper/live-root ]; then
152
- echo "BELL: Error: mapper did not appear."
153
- cryptsetup close live-root || true
154
- /sbin/losetup -d "$LOOP_DEV" || true
155
- exit 1
156
- fi
157
-
158
- # 4.2 mount ext4 filesystem
159
- echo "BELL: mounting ext4 filesystem..."
160
- mount -t ext4 -o ro /dev/mapper/live-root /mnt/ext4
161
-
162
- SQFS_SRC="/mnt/ext4/filesystem.squashfs"
163
- if [ ! -f "$SQFS_SRC" ]; then
164
- echo "BELL: error: $SQFS_SRC not found!"
165
- exit 1
166
- fi
167
-
168
-
169
- # 4.3. Prepare RAM destination /run
170
- echo "BELL: preparing RAM disk ${RAM_MEDIA_MNT}..."
171
- SQFS_SIZE_BYTES=$(stat -c%s "$SQFS_SRC")
172
- NEEDED_SIZE_MB=$(( $SQFS_SIZE_BYTES / 1024 / 1024 + 500 )) # add 500MB buffer
173
- echo "BELL: Estimated space required in /run: ${NEEDED_SIZE_MB} MB"
174
- echo "BELL: increase size /run (tmpfs)..."
175
- if ! mount -o remount,size=${NEEDED_SIZE_MB}M /run; then
176
- echo "BELL: WARN: Remount /run failed, space may be insufficient."
177
- df -h /run
178
- fi
179
- mkdir -p "${RAM_MEDIA_MNT}/live"
180
-
181
- # 4.4 copy ONLY filesystem.squashfs to RAM
182
- SQFS_DEST="${RAM_MEDIA_MNT}/live/filesystem.squashfs"
183
- echo "BELL: copying $SQFS_SRC -> $SQFS_DEST..."
184
- if command -v rsync >/dev/null; then
185
- rsync -a --info=progress2 "$SQFS_SRC" "$SQFS_DEST"
186
- else
187
- cp "$SQFS_SRC" "$SQFS_DEST"
188
- fi
189
- SQFS_SIZE=$(du -h "$SQFS_DEST" | cut -f1)
190
- echo "BELL: filesystem.squashfs ($SQFS_SIZE) copied to RAM."
191
-
192
- # 4.5 copy .disk
193
- if [ -d "${BELL_MEDIA_MNT}/.disk" ]; then
194
- cp -a "${BELL_MEDIA_MNT}/.disk" "${RAM_MEDIA_MNT}/"
195
- echo "BELL: .disk copied."
196
- else
197
- echo "BELL: Warning: .disk not found."
198
- fi
199
-
200
- # 4.6 Copy vmlinuz and initrd (we need to install the system)
201
- cp -a "${BELL_MEDIA_MNT}/live/vmlinuz"* "${RAM_MEDIA_MNT}/live/" 2>/dev/null || true
202
- cp -a "${BELL_MEDIA_MNT}/live/initrd"* "${RAM_MEDIA_MNT}/live/" 2>/dev/null || true
203
- echo "BELL: Attempted kernel/initrd copy (any errors ignored)."
204
-
205
-
206
- #################################################
207
- # 6. Cleanup and Hand-off
208
- echo "BELL: cleaning used mounts and devices..."
209
- umount /mnt/ext4 || echo "BELL: WARN: umount /mnt/ext4 failed ($?)"
210
- cryptsetup close live-root || echo "BELL: WARN: cryptsetup close live-root failed ($?)"
211
- /sbin/losetup -d "$LOOP_DEV" || echo "BELL: WARN: losetup -d $LOOP_DEV failed ($?)"
212
- umount "$BELL_MEDIA_MNT" || echo "BELL: WARN: umount ${BELL_MEDIA_MNT} failed ($?)"
213
- echo "BELL: cleaning complete."
214
-
215
-
216
- # 6.1 switching to live boot
217
- echo "BELL: live ISO image built in RAM on ${RAM_MEDIA_MNT}"
218
- # ls -l "$RAM_MEDIA_MNT"
219
- # ls -l "${RAM_MEDIA_MNT}/live"
220
- exit 0