penguins-eggs 10.0.2 → 10.0.7
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.
- package/.oclif.manifest.json +26 -30
- package/README.md +106 -1164
- package/addons/eggs/theme/livecd/grub.main.cfg +3 -3
- package/addons/eggs/theme/livecd/isolinux.main.cfg +3 -3
- package/assets/calamares/install-system.sh +9 -5
- package/conf/derivatives.yaml +2 -1
- package/dist/classes/bleach.d.ts +6 -6
- package/dist/classes/bleach.js +6 -6
- package/dist/classes/cfs.d.ts +6 -6
- package/dist/classes/cfs.js +6 -6
- package/dist/classes/compressors.d.ts +8 -7
- package/dist/classes/compressors.js +19 -9
- package/dist/classes/daddy.d.ts +6 -6
- package/dist/classes/daddy.js +13 -13
- package/dist/classes/distro.d.ts +12 -2
- package/dist/classes/distro.js +41 -46
- package/dist/classes/families/archlinux.d.ts +6 -6
- package/dist/classes/families/archlinux.js +7 -11
- package/dist/classes/families/debian.d.ts +6 -6
- package/dist/classes/families/debian.js +6 -6
- package/dist/classes/families/mockup.js +2 -4
- package/dist/classes/families/suse.d.ts +2 -2
- package/dist/classes/families/suse.js +2 -2
- package/dist/classes/incubation/branding.js +24 -25
- package/dist/classes/incubation/distros/focal.js +1 -1
- package/dist/classes/incubation/distros/rolling.d.ts +4 -4
- package/dist/classes/incubation/distros/rolling.js +4 -4
- package/dist/classes/incubation/fisherman-helper/packages.js +9 -6
- package/dist/classes/incubation/incubator.js +6 -7
- package/dist/classes/incubation/installer.js +1 -2
- package/dist/classes/initrd.d.ts +6 -6
- package/dist/classes/initrd.js +6 -6
- package/dist/classes/keyboards.d.ts +6 -6
- package/dist/classes/keyboards.js +6 -6
- package/dist/classes/locales.d.ts +12 -12
- package/dist/classes/locales.js +14 -14
- package/dist/classes/n8.d.ts +6 -6
- package/dist/classes/n8.js +6 -6
- package/dist/classes/network.d.ts +6 -6
- package/dist/classes/network.js +9 -11
- package/dist/classes/ovary.d.ts +43 -43
- package/dist/classes/ovary.js +215 -217
- package/dist/classes/pacman.d.ts +6 -6
- package/dist/classes/pacman.js +8 -10
- package/dist/classes/pve-live.d.ts +6 -6
- package/dist/classes/pve-live.js +6 -6
- package/dist/classes/pxe.d.ts +34 -25
- package/dist/classes/pxe.js +205 -190
- package/dist/classes/settings.d.ts +6 -6
- package/dist/classes/settings.js +9 -9
- package/dist/classes/sources_list.d.ts +16 -16
- package/dist/classes/sources_list.js +20 -20
- package/dist/classes/systemctl.js +2 -2
- package/dist/classes/tailor.d.ts +22 -22
- package/dist/classes/tailor.js +88 -88
- package/dist/classes/tools.d.ts +6 -6
- package/dist/classes/tools.js +6 -6
- package/dist/classes/users.d.ts +9 -9
- package/dist/classes/users.js +33 -35
- package/dist/classes/xdg.d.ts +6 -6
- package/dist/classes/xdg.js +13 -9
- package/dist/classes/yolk.d.ts +8 -8
- package/dist/classes/yolk.js +9 -15
- package/dist/commands/adapt.d.ts +2 -2
- package/dist/commands/adapt.js +2 -4
- package/dist/commands/analyze.d.ts +2 -2
- package/dist/commands/analyze.js +1 -1
- package/dist/commands/calamares.d.ts +8 -8
- package/dist/commands/calamares.js +8 -13
- package/dist/commands/config.d.ts +6 -7
- package/dist/commands/config.js +11 -23
- package/dist/commands/cuckoo.d.ts +2 -2
- package/dist/commands/cuckoo.js +11 -10
- package/dist/commands/dad.d.ts +4 -4
- package/dist/commands/dad.js +2 -6
- package/dist/commands/export/deb.d.ts +4 -4
- package/dist/commands/export/deb.js +2 -6
- package/dist/commands/export/iso.d.ts +4 -4
- package/dist/commands/export/iso.js +2 -5
- package/dist/commands/install.d.ts +15 -15
- package/dist/commands/install.js +7 -25
- package/dist/commands/kill.d.ts +4 -4
- package/dist/commands/kill.js +3 -5
- package/dist/commands/mom.d.ts +1 -1
- package/dist/commands/mom.js +2 -4
- package/dist/commands/produce.d.ts +19 -18
- package/dist/commands/produce.js +16 -18
- package/dist/commands/status.d.ts +2 -2
- package/dist/commands/status.js +2 -4
- package/dist/commands/syncfrom.d.ts +7 -7
- package/dist/commands/syncfrom.js +6 -9
- package/dist/commands/syncto.d.ts +4 -4
- package/dist/commands/syncto.js +8 -12
- package/dist/commands/tools/clean.d.ts +3 -3
- package/dist/commands/tools/clean.js +3 -5
- package/dist/commands/tools/ppa.d.ts +5 -5
- package/dist/commands/tools/ppa.js +14 -17
- package/dist/commands/tools/skel.d.ts +3 -3
- package/dist/commands/tools/skel.js +2 -5
- package/dist/commands/tools/stat.d.ts +3 -3
- package/dist/commands/tools/stat.js +3 -7
- package/dist/commands/tools/yolk.d.ts +2 -2
- package/dist/commands/tools/yolk.js +2 -4
- package/dist/commands/update.d.ts +2 -2
- package/dist/commands/update.js +4 -6
- package/dist/commands/wardrobe/get.d.ts +3 -3
- package/dist/commands/wardrobe/get.js +4 -7
- package/dist/commands/wardrobe/list.d.ts +4 -4
- package/dist/commands/wardrobe/list.js +11 -15
- package/dist/commands/wardrobe/show.d.ts +5 -5
- package/dist/commands/wardrobe/show.js +11 -15
- package/dist/commands/wardrobe/wear.d.ts +6 -6
- package/dist/commands/wardrobe/wear.js +3 -7
- package/dist/interfaces/i-packages.d.ts +4 -17
- package/dist/interfaces/i-packages.js +0 -14
- package/dist/interfaces/i-pxe.d.ts +35 -11
- package/dist/interfaces/i-pxe.js +0 -7
- package/dist/interfaces/i-settings.d.ts +15 -21
- package/dist/krill/modules/change-password.d.ts +4 -4
- package/dist/krill/modules/change-password.js +4 -4
- package/dist/krill/modules/del-live-user.d.ts +3 -3
- package/dist/krill/modules/del-live-user.js +3 -3
- package/dist/krill/modules/fstab.d.ts +3 -3
- package/dist/krill/modules/fstab.js +5 -5
- package/dist/krill/modules/grubcfg.d.ts +6 -6
- package/dist/krill/modules/grubcfg.js +6 -6
- package/dist/krill/modules/hostname.js +4 -4
- package/dist/krill/modules/initramfs.d.ts +2 -2
- package/dist/krill/modules/initramfs.js +2 -2
- package/dist/krill/modules/locale-cfg.js +8 -7
- package/dist/krill/modules/locale.d.ts +2 -2
- package/dist/krill/modules/locale.js +6 -6
- package/dist/krill/modules/m-keyboard.js +14 -14
- package/dist/krill/modules/mkfs.d.ts +2 -2
- package/dist/krill/modules/mkfs.js +2 -2
- package/dist/krill/modules/mount-fs.d.ts +2 -2
- package/dist/krill/modules/mount-fs.js +2 -2
- package/dist/krill/modules/mount-vfs.d.ts +4 -4
- package/dist/krill/modules/mount-vfs.js +4 -4
- package/dist/krill/modules/packages.js +39 -37
- package/dist/krill/modules/partition.js +38 -38
- package/dist/krill/modules/remove-installer-link.d.ts +2 -2
- package/dist/krill/modules/remove-installer-link.js +2 -2
- package/dist/krill/modules/umount.d.ts +3 -3
- package/dist/krill/modules/umount.js +4 -4
- package/dist/krill/modules/unpackfs.d.ts +2 -2
- package/dist/krill/modules/unpackfs.js +2 -2
- package/dist/krill/prepare.d.ts +2 -1
- package/dist/krill/prepare.js +4 -2
- package/dist/krill/sequence.d.ts +2 -1
- package/dist/krill/sequence.js +64 -43
- package/dist/lib/cli-autologin.js +4 -4
- package/dist/lib/get_address.js +2 -3
- package/dist/lib/get_dns.js +2 -3
- package/dist/lib/get_domain.js +2 -3
- package/dist/lib/get_gateway.js +2 -3
- package/dist/lib/get_hostname.js +2 -3
- package/dist/lib/get_netmask.js +2 -3
- package/dist/lib/get_password.js +3 -4
- package/dist/lib/get_userfullname.js +2 -3
- package/dist/lib/get_username.js +2 -2
- package/dist/lib/kill_me_softly.js +3 -18
- package/dist/lib/select_address_type.js +2 -2
- package/dist/lib/select_filesystem_type.js +9 -3
- package/dist/lib/select_installation_device.js +2 -2
- package/dist/lib/select_installation_mode.js +2 -3
- package/dist/lib/select_interface.js +2 -2
- package/dist/lib/select_keyboard_layout.d.ts +2 -2
- package/dist/lib/select_keyboard_layout.js +4 -4
- package/dist/lib/select_keyboard_model.d.ts +2 -2
- package/dist/lib/select_keyboard_model.js +4 -4
- package/dist/lib/select_keyboard_option.d.ts +2 -2
- package/dist/lib/select_keyboard_option.js +4 -4
- package/dist/lib/select_keyboard_variant.d.ts +2 -2
- package/dist/lib/select_keyboard_variant.js +4 -4
- package/dist/lib/select_languages.js +2 -2
- package/dist/lib/select_regions.js +2 -3
- package/dist/lib/select_user_swap_choice.js +2 -3
- package/dist/lib/select_zones.js +8 -10
- package/dist/lib/utils.js +1 -1
- package/manpages/doc/man/eggs.1.gz +0 -0
- package/manpages/doc/man/eggs.html +21 -27
- package/package.json +27 -24
- package/scripts/_eggs +354 -314
- package/scripts/eggs.bash +8 -8
package/dist/classes/pxe.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ./src/classes/pxe.ts
|
|
3
|
-
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
-
* author: Piero Proietti
|
|
5
|
-
* email: piero.proietti@gmail.com
|
|
6
|
-
* license: MIT
|
|
7
|
-
*/
|
|
2
|
+
* ./src/classes/pxe.ts
|
|
3
|
+
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
+
* author: Piero Proietti
|
|
5
|
+
* email: piero.proietti@gmail.com
|
|
6
|
+
* license: MIT
|
|
7
|
+
*/
|
|
8
|
+
import { dhcpd } from 'node-proxy-dhcpd';
|
|
8
9
|
// @ts-ignore
|
|
9
|
-
import
|
|
10
|
+
import tftp from 'tftp';
|
|
10
11
|
import fs from 'node:fs';
|
|
11
12
|
import http from 'node:http';
|
|
12
13
|
import path from 'node:path';
|
|
13
14
|
import nodeStatic from 'node-static';
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import tftp from 'tftp';
|
|
16
15
|
import { exec } from '../lib/utils.js';
|
|
17
16
|
import Distro from './distro.js';
|
|
18
17
|
import Settings from './settings.js';
|
|
@@ -20,138 +19,33 @@ import Utils from './utils.js';
|
|
|
20
19
|
// _dirname
|
|
21
20
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
22
21
|
/**
|
|
23
|
-
* Pxe:
|
|
24
|
-
*/
|
|
22
|
+
* Pxe:
|
|
23
|
+
*/
|
|
25
24
|
export default class Pxe {
|
|
26
25
|
bootLabel = '';
|
|
27
26
|
echo = {};
|
|
28
27
|
eggRoot = '';
|
|
29
28
|
initrdImg = '';
|
|
30
|
-
isos = []; // cuckoo's
|
|
29
|
+
isos = []; // cuckoo's eggs
|
|
31
30
|
nest = '';
|
|
32
31
|
pxeRoot = '';
|
|
33
32
|
settings = {};
|
|
34
33
|
verbose = false;
|
|
35
34
|
vmlinuz = '';
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.log('creating cuckoo configuration pxe: BIOS');
|
|
41
|
-
await this.tryCatch(`cp ${__dirname}/../../addons/eggs/theme/livecd/isolinux.theme.cfg ${this.pxeRoot}/isolinux.theme.cfg`);
|
|
42
|
-
await this.tryCatch(`cp ${__dirname}/../../addons/eggs/theme/livecd/splash.png ${this.pxeRoot}/splash.png`);
|
|
43
|
-
/**
|
|
44
|
-
* ipxe.efi
|
|
45
|
-
*/
|
|
46
|
-
await this.tryCatch(`ln -s ${__dirname}/../../ipxe/ipxe.efi ${this.pxeRoot}/ipxe.efi`);
|
|
47
|
-
// pxe
|
|
48
|
-
const distro = new Distro();
|
|
49
|
-
await this.tryCatch(`ln -s ${distro.pxelinuxPath}pxelinux.0 ${this.pxeRoot}/pxelinux.0`);
|
|
50
|
-
await this.tryCatch(`ln -s ${distro.pxelinuxPath}lpxelinux.0 ${this.pxeRoot}/lpxelinux.0`);
|
|
51
|
-
// syslinux
|
|
52
|
-
await this.tryCatch(`ln -s ${distro.syslinuxPath}ldlinux.c32 ${this.pxeRoot}/ldlinux.c32`);
|
|
53
|
-
await this.tryCatch(`ln -s ${distro.syslinuxPath}vesamenu.c32 ${this.pxeRoot}/vesamenu.c32`);
|
|
54
|
-
await this.tryCatch(`ln -s ${distro.syslinuxPath}libcom32.c32 ${this.pxeRoot}/libcom32.c32`);
|
|
55
|
-
await this.tryCatch(`ln -s ${distro.syslinuxPath}libutil.c32 ${this.pxeRoot}/libutil.c32`);
|
|
56
|
-
await this.tryCatch(`ln -s ${distro.memdiskPath}memdisk ${this.pxeRoot}/memdisk`);
|
|
57
|
-
await this.tryCatch(`mkdir ${this.pxeRoot}/pxelinux.cfg`);
|
|
58
|
-
let content = '';
|
|
59
|
-
content += '# eggs: pxelinux.cfg/default\n';
|
|
60
|
-
content += '# search path for the c32 support libraries (libcom32, libutil etc.)\n';
|
|
61
|
-
content += 'path\n';
|
|
62
|
-
content += 'include isolinux.theme.cfg\n';
|
|
63
|
-
content += 'UI vesamenu.c32\n';
|
|
64
|
-
content += '\n';
|
|
65
|
-
content += `menu title cuckoo: when you need a flying PXE server! ${Utils.address()}\n`;
|
|
66
|
-
content += 'PROMPT 0\n';
|
|
67
|
-
content += 'TIMEOUT 200\n';
|
|
68
|
-
content += '\n';
|
|
69
|
-
content += 'label egg\n';
|
|
70
|
-
content += `menu label ${this.bootLabel.replace('.iso', '')}\n`;
|
|
71
|
-
if (this.settings.distro.familyId === 'debian') {
|
|
72
|
-
/**
|
|
73
|
-
* DEBIAN
|
|
74
|
-
*/
|
|
75
|
-
const clid = this.settings.distro.codenameLikeId;
|
|
76
|
-
if (clid === 'bionic' || clid === 'stretch' || clid === 'jessie') {
|
|
77
|
-
content += 'kernel vmlinuz\n';
|
|
78
|
-
content += `append initrd=initrd boot=live config noswap noprompt fetch=http://${Utils.address()}/live/filesystem.squashfs\n`;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
content += `kernel http://${Utils.address()}/vmlinuz\n`;
|
|
82
|
-
content += `append initrd=http://${Utils.address()}/initrd boot=live config noswap noprompt fetch=http://${Utils.address()}/live/filesystem.squashfs\n`;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else if (distro.familyId === 'archlinux') {
|
|
86
|
-
/**
|
|
87
|
-
* ARCH LINUX
|
|
88
|
-
*/
|
|
89
|
-
let tool = 'archiso';
|
|
90
|
-
if (distro.distroId === 'ManjaroLinux') {
|
|
91
|
-
tool = 'miso';
|
|
92
|
-
}
|
|
93
|
-
content += `kernel http://${Utils.address()}/vmlinuz\n`;
|
|
94
|
-
content += `append initrd=http://${Utils.address()}/initrd boot=live config noswap noprompt ${tool}_http_srv=http://${Utils.address()}/\n`;
|
|
95
|
-
content += 'sysappend 3\n';
|
|
96
|
-
content += '\n';
|
|
97
|
-
}
|
|
98
|
-
if (this.isos.length > 0) {
|
|
99
|
-
content += 'menu separator\n';
|
|
100
|
-
for (const iso of this.isos) {
|
|
101
|
-
content += '\n';
|
|
102
|
-
content += `label ${iso}\n`;
|
|
103
|
-
content += `menu label ${iso}\n`;
|
|
104
|
-
content += `kernel http://${Utils.address()}/memdisk\n`;
|
|
105
|
-
content += `initrd http://${Utils.address()}/${iso}\n`;
|
|
106
|
-
content += 'append iso raw sysappend 3\n';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const file = `${this.pxeRoot}/pxelinux.cfg/default`;
|
|
110
|
-
fs.writeFileSync(file, content);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* build
|
|
114
|
-
*/
|
|
115
|
-
async build() {
|
|
116
|
-
if (fs.existsSync(this.pxeRoot)) {
|
|
117
|
-
await this.tryCatch(`rm ${this.pxeRoot} -rf`);
|
|
118
|
-
}
|
|
119
|
-
await this.tryCatch(`mkdir ${this.pxeRoot} -p`);
|
|
120
|
-
await this.tryCatch(`mkdir ${this.pxeRoot} -p`);
|
|
121
|
-
await this.tryCatch(`ln -s ${this.eggRoot}live ${this.pxeRoot}/live`);
|
|
122
|
-
await this.tryCatch(`ln -s ${this.nest}.disk ${this.pxeRoot}/.disk`);
|
|
123
|
-
if (this.settings.distro.distroId === 'ManjaroLinux') {
|
|
124
|
-
await this.tryCatch(`ln -s ${this.eggRoot}manjaro ${this.pxeRoot}/manjaro`);
|
|
125
|
-
}
|
|
126
|
-
else if (this.settings.distro.distroId === 'Arch' || this.settings.distro.distroId === 'RebornOS') {
|
|
127
|
-
await this.tryCatch(`ln -s ${this.eggRoot}arch ${this.pxeRoot}/arch`);
|
|
128
|
-
}
|
|
129
|
-
if (fs.existsSync(this.eggRoot)) {
|
|
130
|
-
await this.tryCatch(`cp ${this.eggRoot}live/${this.vmlinuz} ${this.pxeRoot}/vmlinuz`, true);
|
|
131
|
-
await this.tryCatch(`chmod 777 ${this.pxeRoot}/vmlinuz`);
|
|
132
|
-
await this.tryCatch(`cp ${this.eggRoot}live/${this.initrdImg} ${this.pxeRoot}/initrd`, true);
|
|
133
|
-
await this.tryCatch(`chmod 777 ${this.pxeRoot}/initrd`);
|
|
134
|
-
}
|
|
135
|
-
// link iso images in pxe
|
|
136
|
-
for (const iso of this.isos) {
|
|
137
|
-
await this.tryCatch(`ln -s ${this.nest}/${iso} ${this.pxeRoot}/${iso}`);
|
|
138
|
-
}
|
|
139
|
-
await this.bios();
|
|
140
|
-
await this.ipxe();
|
|
141
|
-
await this.http();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
* @param dhcpOptions
|
|
36
|
+
* constructor
|
|
37
|
+
* @param nest
|
|
38
|
+
* @param pxeRoot
|
|
146
39
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
40
|
+
constructor(nest = "", pxeRoot = "") {
|
|
41
|
+
this.nest = nest;
|
|
42
|
+
this.pxeRoot = pxeRoot;
|
|
149
43
|
}
|
|
150
44
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
45
|
+
* fertilization()
|
|
46
|
+
*
|
|
47
|
+
* cuckoo's nest
|
|
48
|
+
*/
|
|
155
49
|
async fertilization() {
|
|
156
50
|
this.settings = new Settings();
|
|
157
51
|
await this.settings.load();
|
|
@@ -172,24 +66,23 @@ export default class Pxe {
|
|
|
172
66
|
}
|
|
173
67
|
}
|
|
174
68
|
else {
|
|
175
|
-
// this.eggRoot = path.dirname(this.settings.config.snapshot_mnt) + '/iso/'
|
|
176
69
|
this.eggRoot = this.settings.config.snapshot_mnt + 'iso/';
|
|
177
70
|
}
|
|
178
71
|
if (!Utils.isLive() && !fs.existsSync(this.settings.config.snapshot_mnt)) {
|
|
179
72
|
console.log('no image available, build an image with: sudo eggs produce');
|
|
180
73
|
process.exit();
|
|
181
74
|
}
|
|
182
|
-
|
|
183
|
-
|
|
75
|
+
const settings = new Settings();
|
|
76
|
+
settings.load();
|
|
184
77
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
78
|
+
* se pxeRoot non esiste viene creato
|
|
79
|
+
*/
|
|
187
80
|
if (!fs.existsSync(this.pxeRoot)) {
|
|
188
81
|
await exec(`mkdir ${this.pxeRoot} -p`);
|
|
189
82
|
}
|
|
190
83
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
84
|
+
* Ricerca delle ISOs
|
|
85
|
+
*/
|
|
193
86
|
const isos = [];
|
|
194
87
|
/*
|
|
195
88
|
if (!Utils.isLive()) {
|
|
@@ -198,15 +91,15 @@ export default class Pxe {
|
|
|
198
91
|
if (path.extname(iso) === '.iso') {
|
|
199
92
|
this.isos.push(iso)
|
|
200
93
|
}
|
|
201
|
-
|
|
94
|
+
|
|
202
95
|
this.isos = this.isos.sort()
|
|
203
96
|
}
|
|
204
97
|
}
|
|
205
98
|
*/
|
|
206
99
|
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
100
|
+
* installed: /home/eggs/.mnt/iso/live
|
|
101
|
+
* live: this.iso/live
|
|
102
|
+
*/
|
|
210
103
|
const pathFiles = this.eggRoot + 'live';
|
|
211
104
|
const files = fs.readdirSync(pathFiles);
|
|
212
105
|
for (const file of files) {
|
|
@@ -228,8 +121,8 @@ export default class Pxe {
|
|
|
228
121
|
}
|
|
229
122
|
}
|
|
230
123
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
124
|
+
* bootLabel
|
|
125
|
+
*/
|
|
233
126
|
this.bootLabel = 'not found';
|
|
234
127
|
if (fs.existsSync(this.eggRoot + '/.disk/mkisofs')) {
|
|
235
128
|
const a = fs.readFileSync(this.eggRoot + '/.disk/mkisofs', 'utf8');
|
|
@@ -241,16 +134,170 @@ export default class Pxe {
|
|
|
241
134
|
console.log(`vmlinuz: ${this.vmlinuz}`);
|
|
242
135
|
console.log(`initrd: ${this.initrdImg}`);
|
|
243
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* build
|
|
139
|
+
*/
|
|
140
|
+
async build() {
|
|
141
|
+
if (fs.existsSync(this.pxeRoot)) {
|
|
142
|
+
await this.tryCatch(`rm ${this.pxeRoot} -rf`);
|
|
143
|
+
}
|
|
144
|
+
await this.tryCatch(`mkdir ${this.pxeRoot} -p`);
|
|
145
|
+
await this.tryCatch(`mkdir ${this.pxeRoot} -p`);
|
|
146
|
+
await this.tryCatch(`ln -s ${this.eggRoot}live ${this.pxeRoot}/live`);
|
|
147
|
+
await this.tryCatch(`ln -s ${this.nest}.disk ${this.pxeRoot}/.disk`);
|
|
148
|
+
if (this.settings.distro.distroId === 'ManjaroLinux') {
|
|
149
|
+
await this.tryCatch(`ln -s ${this.eggRoot}manjaro ${this.pxeRoot}/manjaro`);
|
|
150
|
+
}
|
|
151
|
+
else if (this.settings.distro.distroId === 'Arch' || this.settings.distro.distroId === 'RebornOS') {
|
|
152
|
+
await this.tryCatch(`ln -s ${this.eggRoot}arch ${this.pxeRoot}/arch`);
|
|
153
|
+
}
|
|
154
|
+
if (fs.existsSync(this.eggRoot)) {
|
|
155
|
+
await this.tryCatch(`cp ${this.eggRoot}live/${this.vmlinuz} ${this.pxeRoot}/vmlinuz`, true);
|
|
156
|
+
await this.tryCatch(`chmod 777 ${this.pxeRoot}/vmlinuz`);
|
|
157
|
+
await this.tryCatch(`cp ${this.eggRoot}live/${this.initrdImg} ${this.pxeRoot}/initrd`, true);
|
|
158
|
+
await this.tryCatch(`chmod 777 ${this.pxeRoot}/initrd`);
|
|
159
|
+
}
|
|
160
|
+
// link iso images in pxe
|
|
161
|
+
for (const iso of this.isos) {
|
|
162
|
+
await this.tryCatch(`ln -s ${this.nest}/${iso} ${this.pxeRoot}/${iso}`);
|
|
163
|
+
}
|
|
164
|
+
await this.bios();
|
|
165
|
+
await this.ipxe();
|
|
166
|
+
await this.http();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
* @param dhcpOptions
|
|
171
|
+
*/
|
|
172
|
+
dhcpStart(dhcpOptions) {
|
|
173
|
+
new dhcpd(dhcpOptions);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* start http server for images
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
async httpStart() {
|
|
180
|
+
const port = 80;
|
|
181
|
+
const httpRoot = this.pxeRoot + '/';
|
|
182
|
+
console.log('http root: ' + httpRoot);
|
|
183
|
+
console.log('http listening: 0.0.0.0:' + port);
|
|
184
|
+
//const file = new nodeStatic.Server(httpRoot, { followSymlinks: true })
|
|
185
|
+
const file = new nodeStatic.Server(httpRoot);
|
|
186
|
+
http
|
|
187
|
+
.createServer((req, res) => {
|
|
188
|
+
file.serve(req, res);
|
|
189
|
+
})
|
|
190
|
+
.listen(port);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* start tftp
|
|
194
|
+
*/
|
|
195
|
+
async tftpStart(tftpOptions) {
|
|
196
|
+
const tftpServer = tftp.createServer(tftpOptions);
|
|
197
|
+
console.log('tftp listening: ' + tftpOptions.host + ':' + tftpOptions.port);
|
|
198
|
+
tftpServer.on('error', (error) => {
|
|
199
|
+
// Errors from the main socket
|
|
200
|
+
// The current transfers are not aborted
|
|
201
|
+
console.error(error);
|
|
202
|
+
});
|
|
203
|
+
tftpServer.on('request', (req, res) => {
|
|
204
|
+
req.on('error', (error) => {
|
|
205
|
+
// Error from the request
|
|
206
|
+
// The connection is already closed
|
|
207
|
+
console.error('[' + req.stats.remoteAddress + ':' + req.stats.remotePort + '] (' + req.file + ') ' + error.message);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
tftpServer.listen();
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Il resto PRIVATO
|
|
214
|
+
*/
|
|
215
|
+
/**
|
|
216
|
+
* configure PXE bios
|
|
217
|
+
*/
|
|
218
|
+
async bios() {
|
|
219
|
+
console.log('creating cuckoo configuration: BIOS');
|
|
220
|
+
await this.tryCatch(`cp ${__dirname}/../../addons/eggs/theme/livecd/isolinux.theme.cfg ${this.pxeRoot}/isolinux.theme.cfg`);
|
|
221
|
+
await this.tryCatch(`cp ${__dirname}/../../addons/eggs/theme/livecd/splash.png ${this.pxeRoot}/splash.png`);
|
|
222
|
+
/**
|
|
223
|
+
* ipxe.efi
|
|
224
|
+
*/
|
|
225
|
+
await this.tryCatch(`ln -s ${__dirname}/../../ipxe/ipxe.efi ${this.pxeRoot}/ipxe.efi`);
|
|
226
|
+
// pxe
|
|
227
|
+
const distro = new Distro();
|
|
228
|
+
await this.tryCatch(`ln -s ${distro.pxelinuxPath}pxelinux.0 ${this.pxeRoot}/pxelinux.0`);
|
|
229
|
+
await this.tryCatch(`ln -s ${distro.pxelinuxPath}lpxelinux.0 ${this.pxeRoot}/lpxelinux.0`);
|
|
230
|
+
// syslinux
|
|
231
|
+
await this.tryCatch(`ln -s ${distro.syslinuxPath}ldlinux.c32 ${this.pxeRoot}/ldlinux.c32`);
|
|
232
|
+
await this.tryCatch(`ln -s ${distro.syslinuxPath}vesamenu.c32 ${this.pxeRoot}/vesamenu.c32`);
|
|
233
|
+
await this.tryCatch(`ln -s ${distro.syslinuxPath}libcom32.c32 ${this.pxeRoot}/libcom32.c32`);
|
|
234
|
+
await this.tryCatch(`ln -s ${distro.syslinuxPath}libutil.c32 ${this.pxeRoot}/libutil.c32`);
|
|
235
|
+
await this.tryCatch(`ln -s ${distro.memdiskPath}memdisk ${this.pxeRoot}/memdisk`);
|
|
236
|
+
await this.tryCatch(`mkdir ${this.pxeRoot}/pxelinux.cfg`);
|
|
237
|
+
let content = '';
|
|
238
|
+
content += '# eggs: pxelinux.cfg/default\n';
|
|
239
|
+
content += '# search path for the c32 support libraries (libcom32, libutil etc.)\n';
|
|
240
|
+
content += 'path\n';
|
|
241
|
+
content += 'include isolinux.theme.cfg\n';
|
|
242
|
+
content += 'UI vesamenu.c32\n';
|
|
243
|
+
content += '\n';
|
|
244
|
+
content += `menu title cuckoo: when you need a flying PXE server! ${Utils.address()}\n`;
|
|
245
|
+
content += 'PROMPT 0\n';
|
|
246
|
+
content += 'TIMEOUT 200\n';
|
|
247
|
+
content += '\n';
|
|
248
|
+
content += 'label egg\n';
|
|
249
|
+
content += `menu label ${this.bootLabel.replace('.iso', '')}\n`;
|
|
250
|
+
if (this.settings.distro.familyId === 'debian') {
|
|
251
|
+
/**
|
|
252
|
+
* DEBIAN
|
|
253
|
+
*/
|
|
254
|
+
const clid = this.settings.distro.codenameLikeId;
|
|
255
|
+
if (clid === 'bionic' || clid === 'stretch' || clid === 'jessie') {
|
|
256
|
+
content += 'kernel vmlinuz\n';
|
|
257
|
+
content += `append initrd=initrd boot=live config noswap noprompt fetch=http://${Utils.address()}/live/filesystem.squashfs\n`;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
content += `kernel http://${Utils.address()}/vmlinuz\n`;
|
|
261
|
+
content += `append initrd=http://${Utils.address()}/initrd boot=live config noswap noprompt fetch=http://${Utils.address()}/live/filesystem.squashfs\n`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else if (distro.familyId === 'archlinux') {
|
|
265
|
+
/**
|
|
266
|
+
* ARCH LINUX
|
|
267
|
+
*/
|
|
268
|
+
let tool = 'archiso';
|
|
269
|
+
if (distro.distroId === 'ManjaroLinux') {
|
|
270
|
+
tool = 'miso';
|
|
271
|
+
}
|
|
272
|
+
content += `kernel http://${Utils.address()}/vmlinuz\n`;
|
|
273
|
+
content += `append initrd=http://${Utils.address()}/initrd boot=live config noswap noprompt ${tool}_http_srv=http://${Utils.address()}/\n`;
|
|
274
|
+
content += 'sysappend 3\n';
|
|
275
|
+
content += '\n';
|
|
276
|
+
}
|
|
277
|
+
if (this.isos.length > 0) {
|
|
278
|
+
content += 'menu separator\n';
|
|
279
|
+
for (const iso of this.isos) {
|
|
280
|
+
content += '\n';
|
|
281
|
+
content += `label ${iso}\n`;
|
|
282
|
+
content += `menu label ${iso}\n`;
|
|
283
|
+
content += `kernel http://${Utils.address()}/memdisk\n`;
|
|
284
|
+
content += `initrd http://${Utils.address()}/${iso}\n`;
|
|
285
|
+
content += 'append iso raw sysappend 3\n';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const file = `${this.pxeRoot}/pxelinux.cfg/default`;
|
|
289
|
+
fs.writeFileSync(file, content);
|
|
290
|
+
}
|
|
244
291
|
/**
|
|
245
292
|
* configure PXE http server
|
|
246
293
|
*/
|
|
247
294
|
async http() {
|
|
248
|
-
console.log('creating cuckoo configuration:
|
|
295
|
+
console.log('creating cuckoo configuration: html');
|
|
249
296
|
const file = `${this.pxeRoot}/index.html`;
|
|
250
297
|
let content = '';
|
|
251
|
-
content +=
|
|
298
|
+
content += "<html><title>Penguin's eggs PXE server</title>";
|
|
252
299
|
content += '<div style="background-image:url(\'/splash.png\');background-repeat:no-repeat;width: 640;height:480;padding:5px;border:1px solid black;">';
|
|
253
|
-
content += '<h1>
|
|
300
|
+
content += '<h1>Cuckoo PXE server</h1>';
|
|
254
301
|
content += `<body>address: <a href=http://${Utils.address()}>${Utils.address()}</a><br/>`;
|
|
255
302
|
if (Utils.isLive()) {
|
|
256
303
|
content += 'started from live iso image<br/>';
|
|
@@ -262,29 +309,16 @@ export default class Pxe {
|
|
|
262
309
|
}
|
|
263
310
|
content += '</li>';
|
|
264
311
|
}
|
|
265
|
-
content +=
|
|
266
|
-
content +=
|
|
267
|
-
content +=
|
|
312
|
+
content += "source: <a href='https://github.com/pieroproietti/penguins-eggs'>https://github.com/pieroproietti/penguins-eggs</a><br/>";
|
|
313
|
+
content += "manual: <a href='https://penguins-eggs.net/book/italiano9.2.html'>italiano</a>, <a href='https://penguins--eggs-net.translate.goog/book/italiano9.2?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en'>translated</a><br/>";
|
|
314
|
+
content += "discuss: <a href='https://t.me/penguins_eggs'>Telegram group<br/></body</html>";
|
|
268
315
|
fs.writeFileSync(file, content);
|
|
269
316
|
}
|
|
270
317
|
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
*/
|
|
274
|
-
async httpStart() {
|
|
275
|
-
const port = 80;
|
|
276
|
-
const httpRoot = this.pxeRoot + '/';
|
|
277
|
-
console.log('http listening: 0.0.0.0:' + port);
|
|
278
|
-
const file = new (nodeStatic.Server)(httpRoot);
|
|
279
|
-
http.createServer((req, res) => {
|
|
280
|
-
file.serve(req, res);
|
|
281
|
-
}).listen(port);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
*/
|
|
318
|
+
*
|
|
319
|
+
*/
|
|
286
320
|
async ipxe() {
|
|
287
|
-
console.log('creating cuckoo configuration
|
|
321
|
+
console.log('creating cuckoo configuration: UEFI');
|
|
288
322
|
let content = '#!ipxe\n';
|
|
289
323
|
content += 'dhcp\n';
|
|
290
324
|
content += 'set net0/ip=dhcp\n';
|
|
@@ -314,19 +348,19 @@ export default class Pxe {
|
|
|
314
348
|
content += `kernel http://${Utils.address()}/vmlinuz\n`;
|
|
315
349
|
content += `initrd http://${Utils.address()}/initrd\n`;
|
|
316
350
|
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
351
|
+
* CORRECT:
|
|
352
|
+
* content += `imgargs vmlinuz fetch=http://${Utils.address()}/live/filesystem.squashfs boot=live dhcp initrd=initrd ro\n`
|
|
353
|
+
*/
|
|
320
354
|
if (this.settings.distro.familyId === 'debian') {
|
|
321
355
|
/**
|
|
322
|
-
|
|
323
|
-
|
|
356
|
+
* DEBIAN
|
|
357
|
+
*/
|
|
324
358
|
content += `imgargs vmlinuz fetch=http://${Utils.address()}/live/filesystem.squashfs boot=live dhcp initrd=initrd ro\n`;
|
|
325
359
|
}
|
|
326
360
|
else if (this.settings.distro.familyId === 'archlinux') {
|
|
327
361
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
362
|
+
* ARCH LINUX
|
|
363
|
+
*/
|
|
330
364
|
let tool = 'archiso';
|
|
331
365
|
if (this.settings.distro.codenameId === 'Qonos' || this.settings.distro.codenameId === 'Ruah' || this.settings.distro.codenameId === 'Sikaris' || this.settings.distro.codenameId === 'UltimaThule') {
|
|
332
366
|
tool = 'miso';
|
|
@@ -345,8 +379,8 @@ export default class Pxe {
|
|
|
345
379
|
}
|
|
346
380
|
}
|
|
347
381
|
/**
|
|
348
|
-
|
|
349
|
-
|
|
382
|
+
* netboot.xyz
|
|
383
|
+
*/
|
|
350
384
|
content += ':netboot\n';
|
|
351
385
|
content += 'ifopen net0\n';
|
|
352
386
|
content += 'set conn_type https\n';
|
|
@@ -357,25 +391,6 @@ export default class Pxe {
|
|
|
357
391
|
const file = `${this.pxeRoot}/autoexec.ipxe`;
|
|
358
392
|
fs.writeFileSync(file, content);
|
|
359
393
|
}
|
|
360
|
-
/**
|
|
361
|
-
* start tftp
|
|
362
|
-
*/
|
|
363
|
-
async tftpStart(tftpOptions) {
|
|
364
|
-
const tftpServer = tftp.createServer(tftpOptions);
|
|
365
|
-
tftpServer.on('error', (error) => {
|
|
366
|
-
// Errors from the main socket
|
|
367
|
-
// The current transfers are not aborted
|
|
368
|
-
console.error(error);
|
|
369
|
-
});
|
|
370
|
-
tftpServer.on('request', (req, res) => {
|
|
371
|
-
req.on('error', (error) => {
|
|
372
|
-
// Error from the request
|
|
373
|
-
// The connection is already closed
|
|
374
|
-
console.error('[' + req.stats.remoteAddress + ':' + req.stats.remotePort + '] (' + req.file + ') ' + error.message);
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
tftpServer.listen();
|
|
378
|
-
}
|
|
379
394
|
/**
|
|
380
395
|
*
|
|
381
396
|
* @param cmd
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ./src/classes/settings.ts
|
|
3
|
-
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
-
* author: Piero Proietti
|
|
5
|
-
* email: piero.proietti@gmail.com
|
|
6
|
-
* license: MIT
|
|
7
|
-
*/
|
|
2
|
+
* ./src/classes/settings.ts
|
|
3
|
+
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
+
* author: Piero Proietti
|
|
5
|
+
* email: piero.proietti@gmail.com
|
|
6
|
+
* license: MIT
|
|
7
|
+
*/
|
|
8
8
|
import { IApp, IDistro, IRemix, IWorkDir } from '../interfaces/index.js';
|
|
9
9
|
import { IEggsConfig } from '../interfaces/index.js';
|
|
10
10
|
import Incubator from './incubation/incubator.js';
|
package/dist/classes/settings.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ./src/classes/settings.ts
|
|
3
|
-
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
-
* author: Piero Proietti
|
|
5
|
-
* email: piero.proietti@gmail.com
|
|
6
|
-
* license: MIT
|
|
7
|
-
*/
|
|
2
|
+
* ./src/classes/settings.ts
|
|
3
|
+
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
+
* author: Piero Proietti
|
|
5
|
+
* email: piero.proietti@gmail.com
|
|
6
|
+
* license: MIT
|
|
7
|
+
*/
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import yaml from 'js-yaml';
|
|
10
10
|
// packages
|
|
@@ -49,7 +49,7 @@ export default class Settings {
|
|
|
49
49
|
this.app.version = pjson.version;
|
|
50
50
|
this.isLive = Utils.isLive();
|
|
51
51
|
this.i686 = Utils.isi686();
|
|
52
|
-
this.distro = new Distro(
|
|
52
|
+
this.distro = new Distro();
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Calculate and show free space on the disk
|
|
@@ -72,7 +72,7 @@ export default class Settings {
|
|
|
72
72
|
}
|
|
73
73
|
spaceAvailable = Number(shx
|
|
74
74
|
.exec(`df "${this.config.snapshot_mnt}" | /usr/bin/awk 'NR==2 {print $4}'`, {
|
|
75
|
-
silent: true
|
|
75
|
+
silent: true
|
|
76
76
|
})
|
|
77
77
|
.stdout.trim());
|
|
78
78
|
console.log(`Space available: ${Math.round((spaceAvailable / gb) * 10) / 10} GB`);
|
|
@@ -167,7 +167,7 @@ export default class Settings {
|
|
|
167
167
|
async loadRemix(basename = '', theme = '') {
|
|
168
168
|
this.remix.versionNumber = Utils.getPackageVersion();
|
|
169
169
|
this.remix.kernel = Utils.kernelVersion();
|
|
170
|
-
this.remix.branding = theme === '' ? 'eggs' : this.remix.branding = theme.slice(Math.max(0, theme.lastIndexOf('/') + 1));
|
|
170
|
+
this.remix.branding = theme === '' ? 'eggs' : (this.remix.branding = theme.slice(Math.max(0, theme.lastIndexOf('/') + 1)));
|
|
171
171
|
this.remix.name = this.config.snapshot_basename;
|
|
172
172
|
let name = this.config.snapshot_prefix + this.config.snapshot_basename;
|
|
173
173
|
name = name.replaceAll('-', ' ').replaceAll('_', ' ').replace('egg of ', '');
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ./src/classes/sources_list.ts
|
|
3
|
-
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
-
* author: Piero Proietti
|
|
5
|
-
* email: piero.proietti@gmail.com
|
|
6
|
-
* license: MIT
|
|
7
|
-
*/
|
|
2
|
+
* ./src/classes/sources_list.ts
|
|
3
|
+
* penguins-eggs v.10.0.0 / ecmascript 2020
|
|
4
|
+
* author: Piero Proietti
|
|
5
|
+
* email: piero.proietti@gmail.com
|
|
6
|
+
* license: MIT
|
|
7
|
+
*/
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
export default class SourcesList {
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
*
|
|
14
|
+
* @param repos
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
17
|
components(components: string[]): Promise<boolean>;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
*
|
|
20
|
+
* @param repos
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
23
|
distribution(distributions: string[]): Promise<boolean>;
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
27
|
private get;
|
|
28
28
|
}
|