penguins-eggs 9.2.2 → 9.2.4

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 (87) hide show
  1. package/README.md +145 -130
  2. package/addons/eggs/theme/livecd/isolinux.theme.cfg +36 -41
  3. package/conf/eggs.yaml +41 -73
  4. package/conf/exclude.list +1 -0
  5. package/conf/krill.yaml +38 -0
  6. package/lib/classes/daddy.d.ts +2 -2
  7. package/lib/classes/distro.d.ts +2 -0
  8. package/lib/classes/distro.js +6 -0
  9. package/lib/classes/incubation/fisherman.js +1 -1
  10. package/lib/classes/pacman.js +3 -2
  11. package/lib/classes/pxe.d.ts +42 -0
  12. package/lib/classes/pxe.js +242 -0
  13. package/lib/classes/settings.d.ts +3 -3
  14. package/lib/classes/settings.js +2 -1
  15. package/lib/classes/tools.d.ts +2 -2
  16. package/lib/classes/utils.d.ts +1 -1
  17. package/lib/classes/utils.js +1 -1
  18. package/lib/commands/cuckoo.d.ts +24 -0
  19. package/lib/commands/cuckoo.js +69 -0
  20. package/lib/commands/install.d.ts +2 -2
  21. package/lib/commands/install.js +8 -14
  22. package/lib/commands/produce.js +3 -3
  23. package/lib/commands/{info.d.ts → status.d.ts} +1 -1
  24. package/lib/commands/{info.js → status.js} +5 -5
  25. package/lib/components/summary.d.ts +6 -1
  26. package/lib/components/summary.js +25 -8
  27. package/lib/components/users.js +3 -4
  28. package/lib/interfaces/i-config-tools.d.ts +1 -1
  29. package/lib/interfaces/i-distro.d.ts +2 -0
  30. package/lib/interfaces/{i-config.d.ts → i-eggs-config.d.ts} +2 -4
  31. package/lib/interfaces/{i-config.js → i-eggs-config.js} +0 -0
  32. package/lib/interfaces/i-krill-config.d.ts +26 -0
  33. package/lib/interfaces/i-krill-config.js +2 -0
  34. package/lib/interfaces/i-packages.d.ts +6 -9
  35. package/lib/interfaces/i-packages.js +3 -0
  36. package/lib/interfaces/index.d.ts +1 -1
  37. package/lib/krill/krill-prepare.d.ts +5 -3
  38. package/lib/krill/krill-prepare.js +159 -35
  39. package/lib/krill/krill-sequence.d.ts +5 -3
  40. package/lib/krill/krill-sequence.js +26 -12
  41. package/lib/krill/modules/fstab.d.ts +5 -0
  42. package/lib/krill/modules/fstab.js +5 -0
  43. package/lib/krill/modules/grubcfg.d.ts +5 -0
  44. package/lib/krill/modules/grubcfg.js +5 -0
  45. package/lib/krill/modules/hostname.d.ts +5 -0
  46. package/lib/krill/modules/hostname.js +5 -0
  47. package/lib/krill/modules/hosts.d.ts +5 -0
  48. package/lib/krill/modules/hosts.js +5 -0
  49. package/lib/krill/modules/initramfs-cfg.d.ts +5 -0
  50. package/lib/krill/modules/initramfs-cfg.js +5 -0
  51. package/lib/krill/modules/initramfs.d.ts +5 -0
  52. package/lib/krill/modules/initramfs.js +5 -0
  53. package/lib/krill/modules/locale-cfg.d.ts +5 -0
  54. package/lib/krill/modules/locale-cfg.js +5 -0
  55. package/lib/krill/modules/locale.d.ts +5 -0
  56. package/lib/krill/modules/locale.js +5 -0
  57. package/lib/krill/modules/machine-id.d.ts +5 -0
  58. package/lib/krill/modules/machine-id.js +5 -0
  59. package/lib/krill/modules/mkfs.d.ts +5 -0
  60. package/lib/krill/modules/mkfs.js +5 -0
  61. package/lib/krill/modules/mount-fs.d.ts +5 -0
  62. package/lib/krill/modules/mount-fs.js +5 -0
  63. package/lib/krill/modules/mount-vfs.d.ts +5 -0
  64. package/lib/krill/modules/mount-vfs.js +5 -0
  65. package/lib/krill/modules/network-cfg.d.ts +5 -0
  66. package/lib/krill/modules/network-cfg.js +5 -0
  67. package/lib/krill/modules/packages.d.ts +14 -0
  68. package/lib/krill/modules/packages.js +65 -0
  69. package/lib/krill/modules/{partitions.d.ts → partition.d.ts} +5 -0
  70. package/lib/krill/modules/{partitions.js → partition.js} +5 -0
  71. package/lib/krill/modules/remove-installer-link.d.ts +5 -0
  72. package/lib/krill/modules/remove-installer-link.js +5 -0
  73. package/lib/krill/modules/set-keyboard.d.ts +5 -0
  74. package/lib/krill/modules/set-keyboard.js +37 -18
  75. package/lib/krill/modules/set-timezone.d.ts +5 -0
  76. package/lib/krill/modules/set-timezone.js +5 -0
  77. package/lib/krill/modules/umount.d.ts +5 -0
  78. package/lib/krill/modules/umount.js +5 -0
  79. package/lib/krill/modules/unpackfs.d.ts +5 -0
  80. package/lib/krill/modules/unpackfs.js +5 -0
  81. package/manpages/doc/man/eggs.1.gz +0 -0
  82. package/manpages/doc/man/eggs.html +72 -83
  83. package/package.json +6 -2
  84. package/scripts/_eggs +23 -24
  85. package/scripts/eggs.bash +4 -4
  86. package/scripts/mom-cli.sh +11 -11
  87. package/manpages/doc/man/eggs.roll.gz +0 -0
package/conf/eggs.yaml CHANGED
@@ -1,100 +1,68 @@
1
1
  # Penguin's eggs
2
2
  # eggs.yaml
3
3
  ---
4
- # version
5
- version: '16.*.*'
6
-
7
- # You can change the location of 'snapshot_dir' (location of final iso file)
8
- # in case you don't have enough space on the system.
9
- # default: /home/eggs
10
- snapshot_dir: '/home/eggs/'
11
-
12
- # The name of the snapshot file will be hostname-{arch}_{yyyy-mm-dd_hhmm}.iso.
13
- # If you'd like to replace "hostname" with something different,
14
- # change it here. (example: snapshot_basename="my-buster-live")
15
- #
16
- # prefix iso file
17
- # You can choose a prefix like 'UfficioZero_'
18
- # default ''
4
+ version: ''
5
+
6
+ # eggs nest, default: /home/eggs
7
+ snapshot_dir: /home/eggs/
8
+
9
+ # Default '', dad -d put it at egg-of-distro-version-
19
10
  snapshot_prefix: ''
20
11
 
21
- # Note: hostname use the name of the host
22
- #
23
- # default hostname
24
- snapshot_basename: 'hostname'
12
+ # You can edit this rsync excludes file
13
+ snapshot_excludes: /usr/local/share/penguins-eggs/exclude.list
25
14
 
26
- # You can change the rsync excludes file here - if you know what you're doing -
27
- # be sure to use the full path to the file.
28
- #
29
- # default /var/local/share/excludes/penguins-eggs-snapshot-exclude.list
30
- snapshot_excludes: '/var/local/share/penguins-eggs/exclude.list'
15
+ # snapshot_basename, default: ''
16
+ snapshot_basename: ''
31
17
 
32
- # user to be used in the liveCd
33
- # default live
34
- user_opt: 'live'
18
+ # user liveCD, default: live
19
+ user_opt: live
35
20
 
36
- # password of user to be used in the liveCd
37
- # default evolution
38
- user_opt_passwd: 'evolution'
21
+ # user liveCD password, default: evolution
22
+ user_opt_passwd: evolution
39
23
 
40
- # root password to be used in liveCd
41
- # default evolution
42
- root_passwd: 'evolution'
24
+ # root liveCD password, default: evolution
25
+ root_passwd: evolution
43
26
 
44
- # theme to be used as default
45
- # default: eggs
46
- theme: ''
27
+ # theme to be used, default: eggs
28
+ theme: eggs
47
29
 
48
- # Force installation package calamares if is not already installed.
49
- # default no if calamares is not installed
50
- force_installer: false
30
+ # Ask for installation calamares
31
+ force_installer: true
51
32
 
52
- # Set to true to create boot files for uefi.
53
- # default true if grub_efi_amd64 package is installed
54
- make_efi: false
33
+ # make_efi, default: true
34
+ make_efi: true
55
35
 
56
- # Change to false if you don't want the md5sum file created with the iso.
57
- # default yes
36
+ # Create md5sum file, default true
58
37
  make_md5sum: true
59
38
 
60
- # Change to fale if you want a plain iso image instead of isohybrid.
61
- # Default true
39
+ # make_isohybrid, default true
62
40
  make_isohybrid: true
63
41
 
64
- # Compression algorithm
65
- # Allowed values are, in order of speed-size tradeoff: lz4, lzo, gzip, xz
66
- # default -Xcompression-level 20
67
- compression: '-Xcompression-level 20'
42
+ # Compression algorithm, default xz
43
+ compression: xz
68
44
 
69
45
  # Allow password login to ssh for users (not root).
70
- # If ssh_pass=true, then PasswordAuthentication will be set to true
71
- # If ssh_pass=false, then PasswordAuthentication will be set to false
72
- # In either of the above cases, if PermitRootLogin was set to true,
73
- # it will be changed to "prohibit-password" (meaning with auth keys only)
74
- # default true
75
46
  ssh_pass: true
76
47
 
77
-
78
-
79
- # timezone
48
+ # timezone
80
49
  timezone: Europe/Rome
81
50
 
82
- # locales to be builded
51
+ # locales_default, default env.LANG or en_US.UTF-8
52
+ locales_default:
53
+
54
+ # locales, default: locales_default + en_US.UTF-8
83
55
  locales:
84
- - it_IT.UTF-8
56
+ - en_US.UTF-8
57
+
58
+ # it's still used?
59
+ pmount_fixed: false
85
60
 
86
- # default locales
87
- locales_default: it_IT.UTF-8
61
+ # machine_id: default /etc/machine-id
62
+ machine_id: ''
88
63
 
89
- # keyboard
90
- keyboard:
91
- XkbModel: "pc105"
92
- XkbLayout: "it"
93
- XkbVariant: ""
94
- XkbOptions: ""
64
+ # vmlinuz, default: /path/to/vmlinuz
65
+ vmlinuz: ''
95
66
 
96
- ##
97
- # The following fields are actually not used in eggs
98
- pmount_fixed: false
99
- netconfig_opt: ''
100
- ifnames_opt: ''
67
+ # initrd_img, default: /path/to/initrd_img
68
+ initrd_img: ''
package/conf/exclude.list CHANGED
@@ -32,6 +32,7 @@
32
32
  - /etc/crypttab
33
33
  - /etc/fstab
34
34
  - /etc/fstab.d/*
35
+ - /etc/dnsmasq.d/cuckoo.conf
35
36
  - /etc/initramfs-tools/conf.d/resume # see remove-cryptroot and nocrypt.sh
36
37
  - /etc/initramfs-tools/conf.d/cryptroot # see remove-cryptroot and nocrypt.sh
37
38
  - /etc/machine-id
@@ -0,0 +1,38 @@
1
+ # Penguin's eggs
2
+ # krill.yaml
3
+ ---
4
+ # welcome (put your language, example: it_IT.UTF-8)
5
+ language: 'en_US.UTF-8'
6
+
7
+ # location (put your location, example region: "Europe", zone: "Rome")
8
+ region: 'America'
9
+ zone: 'New_York'
10
+
11
+ # keyboard (put your values example: keyboardModel: "pc105", keyboardLayout: "it")
12
+ keyboardModel: 'pc105'
13
+ keyboardLayout: 'us'
14
+ keyboardVariant: ''
15
+ keyboardOption: ''
16
+
17
+ # partition (leave it unchanged)
18
+ installationDevice: ''
19
+ installationMode: 'standard'
20
+ filesystemType: 'ext4'
21
+ userSwapChoice: 'small'
22
+
23
+ # users (Here you can put your default user, password, etc)
24
+ name: 'artisan'
25
+ fullname: 'artisan'
26
+ password: 'evolution'
27
+ rootPassword: 'evolution'
28
+ autologin: true
29
+ hostname: ''
30
+
31
+ # network (leave it unchanged)
32
+ iface: ""
33
+ addressType: 'dhcp'
34
+ address: ''
35
+ netmask: ''
36
+ gateway: ''
37
+ domain: ''
38
+ dns: ''
@@ -1,5 +1,5 @@
1
1
  import Settings from '../classes/settings';
2
- import { IConfig } from '../interfaces';
2
+ import { IEggsConfig } from '../interfaces';
3
3
  export default class Daddy {
4
4
  settings: Settings;
5
5
  helpMe(loadDefault?: boolean, verbose?: boolean): Promise<void>;
@@ -7,5 +7,5 @@ export default class Daddy {
7
7
  *
8
8
  * @param c
9
9
  */
10
- editConfig(c: IConfig): Promise<string>;
10
+ editConfig(c: IEggsConfig): Promise<string>;
11
11
  }
@@ -19,6 +19,8 @@ declare class Distro implements IDistro {
19
19
  usrLibPath: string;
20
20
  isolinuxPath: string;
21
21
  syslinuxPath: string;
22
+ pxelinuxPath: string;
23
+ liveMediumPath: string;
22
24
  mountpointSquashFs: string;
23
25
  homeUrl: string;
24
26
  supportUrl: string;
@@ -52,6 +52,8 @@ class Distro {
52
52
  this.usrLibPath = '/usr/lib';
53
53
  this.isolinuxPath = '';
54
54
  this.syslinuxPath = '';
55
+ this.pxelinuxPath = '';
56
+ this.liveMediumPath = `/run/live/medium/`;
55
57
  this.mountpointSquashFs = '';
56
58
  this.homeUrl = '';
57
59
  this.supportUrl = '';
@@ -117,12 +119,14 @@ class Distro {
117
119
  // Debian 8 jessie
118
120
  this.distroLike = 'Debian';
119
121
  this.codenameLikeId = 'jessie';
122
+ this.liveMediumPath = '/lib/live/mount/medium/';
120
123
  break;
121
124
  }
122
125
  case 'stretch': {
123
126
  // Debian 9 stretch
124
127
  this.distroLike = 'Debian';
125
128
  this.codenameLikeId = 'stretch';
129
+ this.liveMediumPath = '/lib/live/mount/medium/';
126
130
  break;
127
131
  }
128
132
  case 'buster': {
@@ -168,6 +172,7 @@ class Distro {
168
172
  // Ubuntu 18.04 bionic LTS eol aprile 2023
169
173
  this.distroLike = 'Ubuntu';
170
174
  this.codenameLikeId = 'bionic';
175
+ this.liveMediumPath = '/lib/live/mount/medium/';
171
176
  break;
172
177
  }
173
178
  case 'focal': {
@@ -385,6 +390,7 @@ class Distro {
385
390
  case 'debian': {
386
391
  this.isolinuxPath = '/usr/lib/ISOLINUX/';
387
392
  this.syslinuxPath = '/usr/lib/syslinux/modules/bios/';
393
+ this.pxelinuxPath = '/usr/lib/PXELINUX/';
388
394
  this.usrLibPath = '/usr/lib/x86_64-linux-gnu/';
389
395
  if (process.arch === 'ia32') {
390
396
  this.usrLibPath = '/usr/lib/i386-linux-gnu/';
@@ -90,7 +90,7 @@ class Fisherman {
90
90
  * @param replaces [['search','replace']]
91
91
  */
92
92
  async buildModule(name, vendor = '') {
93
- console.log('creating... ' + name);
93
+ // console.log('creating calamares module ' + name)
94
94
  let moduleSource = node_path_1.default.resolve(__dirname, this.installer.templateModules + name + '.yml');
95
95
  /**
96
96
  * We need vendor here to have possibility to load custom modules for calamares
@@ -329,7 +329,7 @@ class Pacman {
329
329
  config.snapshot_dir = '/home/eggs';
330
330
  config.snapshot_prefix = '';
331
331
  config.snapshot_excludes = '/usr/local/share/penguins-eggs/exclude.list';
332
- config.snapshot_basename = 'hostname';
332
+ config.snapshot_basename = ''; // before default was hostname
333
333
  config.user_opt = 'live';
334
334
  config.user_opt_passwd = 'evolution';
335
335
  config.root_passwd = 'evolution';
@@ -340,7 +340,7 @@ class Pacman {
340
340
  config.make_isohybrid = true;
341
341
  config.compression = 'xz';
342
342
  config.ssh_pass = true;
343
- config.timezone = 'Europe/Rome';
343
+ config.timezone = 'America/New_York';
344
344
  const env = process.env;
345
345
  config.locales_default = env.LANG !== undefined ? env.LANG : 'en_US.UTF-8';
346
346
  config.locales = config.locales_default === 'en_US.UTF-8' ? ['en_US.UTF-8'] : [config.locales_default, 'en_US.UTF-8'];
@@ -382,6 +382,7 @@ class Pacman {
382
382
  shelljs_1.default.ln('-s', node_path_1.default.resolve(__dirname, '../../addons'), addons);
383
383
  shelljs_1.default.cp(node_path_1.default.resolve(__dirname, '../../conf/README.md'), '/etc/penguins-eggs.d/');
384
384
  shelljs_1.default.cp(node_path_1.default.resolve(__dirname, '../../conf/tools.yaml'), config_tools);
385
+ shelljs_1.default.cp(node_path_1.default.resolve(__dirname, '../../conf/krill.yaml'), '/etc/penguins-eggs.d/krill.yaml');
385
386
  // creazione del file delle esclusioni
386
387
  shelljs_1.default.mkdir('-p', '/usr/local/share/penguins-eggs/');
387
388
  shelljs_1.default.cp(node_path_1.default.resolve(__dirname, '../../conf/exclude.list'), '/usr/local/share/penguins-eggs');
@@ -0,0 +1,42 @@
1
+ /**
2
+ * penguins-eggs: pxe.ts
3
+ * author: Piero Proietti
4
+ * mail: piero.proietti@gmail.com
5
+ */
6
+ import Settings from '../classes/settings';
7
+ /**
8
+ * Pxe:
9
+ */
10
+ export default class Pxe {
11
+ verbose: boolean;
12
+ echo: {};
13
+ settings: Settings;
14
+ mainLabel: string;
15
+ pxeRoot: string;
16
+ isoRoot: string;
17
+ isos: string[];
18
+ vmlinuz: string;
19
+ initrd: string;
20
+ /**
21
+ * fertilization()
22
+ */
23
+ fertilization(): Promise<void>;
24
+ /**
25
+ * structure
26
+ */
27
+ structure(): Promise<void>;
28
+ /**
29
+ *
30
+ */
31
+ dnsMasq(full?: boolean): Promise<void>;
32
+ /**
33
+ *
34
+ * @param cmd
35
+ */
36
+ tryCatch(cmd?: string): Promise<void>;
37
+ /**
38
+ * start http server for images
39
+ *
40
+ */
41
+ httpStart(): Promise<void>;
42
+ }
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ /**
3
+ * penguins-eggs: pxe.ts
4
+ * author: Piero Proietti
5
+ * mail: piero.proietti@gmail.com
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const tslib_1 = require("tslib");
9
+ const os_1 = tslib_1.__importDefault(require("os"));
10
+ const fs_1 = tslib_1.__importDefault(require("fs"));
11
+ const netmask_1 = require("netmask");
12
+ const utils_1 = tslib_1.__importDefault(require("../classes/utils"));
13
+ const settings_1 = tslib_1.__importDefault(require("../classes/settings"));
14
+ const http_1 = tslib_1.__importDefault(require("http"));
15
+ const node_static_1 = tslib_1.__importDefault(require("node-static"));
16
+ const utils_2 = require("../lib/utils");
17
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
18
+ const distro_1 = tslib_1.__importDefault(require("./distro"));
19
+ /**
20
+ * Pxe:
21
+ */
22
+ class Pxe {
23
+ constructor() {
24
+ this.verbose = false;
25
+ this.echo = {};
26
+ this.settings = {};
27
+ this.mainLabel = '';
28
+ this.pxeRoot = '';
29
+ this.isoRoot = '';
30
+ this.isos = [];
31
+ this.vmlinuz = '';
32
+ this.initrd = '';
33
+ }
34
+ /**
35
+ * fertilization()
36
+ */
37
+ async fertilization() {
38
+ this.settings = new settings_1.default();
39
+ await this.settings.load();
40
+ if (utils_1.default.isLive()) {
41
+ this.isoRoot = this.settings.distro.liveMediumPath;
42
+ }
43
+ else {
44
+ this.isoRoot = node_path_1.default.dirname(this.settings.work_dir.path) + '/ovarium/iso/';
45
+ }
46
+ if (!utils_1.default.isLive() && !fs_1.default.existsSync(this.settings.work_dir.path)) {
47
+ console.log('no image available, build an image with: sudo eggs produce');
48
+ process.exit();
49
+ }
50
+ /**
51
+ * se pxeRoot non esiste viene creato
52
+ */
53
+ this.pxeRoot = node_path_1.default.dirname(this.settings.work_dir.path) + '/pxe/';
54
+ if (!fs_1.default.existsSync(this.pxeRoot)) {
55
+ await (0, utils_2.exec)(`mkdir ${this.pxeRoot} -p`);
56
+ }
57
+ /**
58
+ * Ricerca delle immagini ISO
59
+ */
60
+ let isos = [];
61
+ if (!utils_1.default.isLive()) {
62
+ let isos = fs_1.default.readdirSync(node_path_1.default.dirname(this.settings.work_dir.path));
63
+ for (const iso of isos) {
64
+ if (node_path_1.default.extname(iso) === ".iso") {
65
+ this.isos.push(iso);
66
+ }
67
+ }
68
+ }
69
+ /**
70
+ * installed: /home/eggs/ovarium/iso/live
71
+ * live: this.iso/live
72
+ */
73
+ let pathFiles = this.isoRoot + '/live';
74
+ let files = fs_1.default.readdirSync(pathFiles);
75
+ for (const file of files) {
76
+ if (node_path_1.default.basename(file).substring(0, 7) === 'vmlinuz') {
77
+ this.vmlinuz = node_path_1.default.basename(file);
78
+ }
79
+ if (node_path_1.default.basename(file).substring(0, 6) === 'initrd') {
80
+ this.initrd = node_path_1.default.basename(file);
81
+ }
82
+ }
83
+ /**
84
+ * bootLabel
85
+ */
86
+ this.mainLabel = this.settings.config.snapshot_prefix + utils_1.default.getVolid(os_1.default.hostname());
87
+ }
88
+ /**
89
+ * structure
90
+ */
91
+ async structure() {
92
+ if (fs_1.default.existsSync(this.pxeRoot)) {
93
+ await this.tryCatch(`rm ${this.pxeRoot} -rf`);
94
+ }
95
+ let cmd = `mkdir -p ${this.pxeRoot}`;
96
+ await this.tryCatch(cmd);
97
+ const distro = new distro_1.default();
98
+ await this.tryCatch(`mkdir ${this.pxeRoot} -p`);
99
+ // boot efi isolinux live .disk
100
+ await this.tryCatch(`ln -s ${this.isoRoot}boot ${this.pxeRoot}/boot`);
101
+ await this.tryCatch(`ln -s ${this.isoRoot}efi ${this.pxeRoot}/efi`);
102
+ await this.tryCatch(`ln -s ${this.isoRoot}isolinux ${this.pxeRoot}/isolinux`);
103
+ await this.tryCatch(`ln -s ${this.isoRoot}live ${this.pxeRoot}/live`);
104
+ await this.tryCatch(`ln -s ${this.isoRoot}.disk ${this.pxeRoot}/.disk`);
105
+ // isolinux.theme.cfg, splash.png MUST to be on root
106
+ await this.tryCatch(`ln -s ${this.isoRoot}isolinux/isolinux.theme.cfg ${this.pxeRoot}/isolinux.theme.cfg`);
107
+ await this.tryCatch(`ln -s ${this.isoRoot}isolinux/splash.png ${this.pxeRoot}/splash.png`);
108
+ // pxe
109
+ await this.tryCatch(`ln ${distro.pxelinuxPath}pxelinux.0 ${this.pxeRoot}/pxelinux.0`);
110
+ await this.tryCatch(`ln ${distro.pxelinuxPath}lpxelinux.0 ${this.pxeRoot}/lpxelinux.0`);
111
+ // syslinux
112
+ await this.tryCatch(`ln ${distro.syslinuxPath}ldlinux.c32 ${this.pxeRoot}/ldlinux.c32`);
113
+ await this.tryCatch(`ln ${distro.syslinuxPath}vesamenu.c32 ${this.pxeRoot}/vesamenu.c32`);
114
+ await this.tryCatch(`ln ${distro.syslinuxPath}libcom32.c32 ${this.pxeRoot}/libcom32.c32`);
115
+ await this.tryCatch(`ln ${distro.syslinuxPath}libutil.c32 ${this.pxeRoot}/libutil.c32`);
116
+ await this.tryCatch(`ln /usr/lib/syslinux/memdisk ${this.pxeRoot}/memdisk`);
117
+ await this.tryCatch(`mkdir ${this.pxeRoot}/pxelinux.cfg`);
118
+ // link iso images in pxe
119
+ for (const iso of this.isos) {
120
+ await this.tryCatch(`ln /home/eggs/${iso} ${this.pxeRoot}/${iso}`);
121
+ }
122
+ let content = ``;
123
+ content += `# eggs: pxelinux.cfg/default\n`;
124
+ content += `# search path for the c32 support libraries (libcom32, libutil etc.)\n`;
125
+ content += `path\n`;
126
+ content += `include isolinux.theme.cfg\n`;
127
+ content += `UI vesamenu.c32\n`;
128
+ content += `\n`;
129
+ content += `menu title Penguin's eggs - Perri's brewery edition - ${utils_1.default.address()}\n`;
130
+ content += `PROMPT 0\n`;
131
+ content += `TIMEOUT 0\n`;
132
+ content += `\n`;
133
+ content += `LABEL http\n`;
134
+ content += `MENU LABEL ${this.mainLabel}\n`;
135
+ content += `MENU DEFAULT\n`;
136
+ content += `KERNEL http://${utils_1.default.address()}/live/${this.vmlinuz}\n`;
137
+ content += `APPEND initrd=http://${utils_1.default.address()}/live/${this.initrd} boot=live config noswap noprompt fetch=http://${utils_1.default.address()}/live/filesystem.squashfs\n`;
138
+ content += `SYSAPPEND 3\n`;
139
+ content += `\n`;
140
+ content += `MENU SEPARATOR\n`;
141
+ for (const iso of this.isos) {
142
+ content += `\n`;
143
+ content += `LABEL isos\n`;
144
+ content += `MENU LABEL ${iso}\n`;
145
+ content += `KERNEL memdisk\n`;
146
+ content += `APPEND iso initrd=http://${utils_1.default.address()}/${iso}\n`;
147
+ }
148
+ let file = `${this.pxeRoot}/pxelinux.cfg/default`;
149
+ fs_1.default.writeFileSync(file, content);
150
+ file = `${this.pxeRoot}/index.html`;
151
+ content = ``;
152
+ content += `<html><title>Penguin's eggs PXE server</title>`;
153
+ content += `<div style="background-image:url('/splash.png');background-repeat:no-repeat;width: 640;height:480;padding:5px;border:1px solid black;">`;
154
+ content += `<h1>Penguin's eggs PXE server</h1>`;
155
+ content += `<body>address: <a href=http://${utils_1.default.address()}>${utils_1.default.address()}</a><br/>`;
156
+ if (!utils_1.default.isLive()) {
157
+ content += `download: <a href='http://${utils_1.default.address()}/${this.isos[0]}'>${this.isos[0]}</a><br/>`;
158
+ }
159
+ else {
160
+ content += `started from live iso image<br/>`;
161
+ }
162
+ content += `<br/>`;
163
+ content += `source: <a href='https://github.com/pieroproietti/penguins-eggs'>https://github.com/pieroproietti/penguins-eggs</a><br/>`;
164
+ 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/>`;
165
+ content += `discuss: <a href='https://t.me/penguins_eggs'>Telegram group<br/></body</html>`;
166
+ fs_1.default.writeFileSync(file, content);
167
+ }
168
+ /**
169
+ *
170
+ */
171
+ async dnsMasq(full = false) {
172
+ await (0, utils_2.exec)(`systemctl stop dnsmasq.service`);
173
+ let domain = `penguins-eggs.lan`;
174
+ let n = new netmask_1.Netmask(`${utils_1.default.address()}/${utils_1.default.netmask()}`);
175
+ let content = ``;
176
+ content += `# cuckoo.conf\n`;
177
+ content += `port=0\n`;
178
+ content += `interface=${await utils_1.default.iface()}\n`;
179
+ content += `bind-interfaces\n`;
180
+ content += `domain=${domain}\n`;
181
+ content += `dhcp-no-override\n`;
182
+ content += `dhcp-option=option:router,${n.first}\n`;
183
+ content += `dhcp-option=option:dns-server,${n.first}\n`;
184
+ content += `dhcp-option=option:dns-server,8.8.8.8\n`;
185
+ content += `dhcp-option=option:dns-server,8.8.4.4\n`;
186
+ content += `enable-tftp\n`;
187
+ content += `tftp-root=${this.pxeRoot}\n`;
188
+ content += `# boot config for BIOS\n`;
189
+ content += `dhcp-match=set:bios-x86,option:client-arch,0\n`;
190
+ content += `dhcp-boot=tag:bios-x86,lpxelinux.0\n`;
191
+ content += `# boot config for UEFI\n`;
192
+ content += `dhcp-match=set:efi-x86_64,option:client-arch,7\n`;
193
+ content += `dhcp-match=set:efi-x86_64,option:client-arch,9\n`;
194
+ content += `dhcp-boot=tag:efi-x86_64,lpxelinux.0\n`;
195
+ /**
196
+ * https://thekelleys.org.uk/dnsmasq/CHANGELOG
197
+ *
198
+ * Don't do any PXE processing, even for clients with the
199
+ * correct vendorclass, unless at least one pxe-prompt or
200
+ * pxe-service option is given. This stops dnsmasq
201
+ * interfering with proxy PXE subsystems when it is just
202
+ * the DHCP server. Thanks to Spencer Clark for spotting this.
203
+ */
204
+ content += `pxe-service=X86PC,"penguin's eggs cuckoo",pxelinux.0\n`;
205
+ if (full) {
206
+ content += `dhcp-range=${await utils_1.default.iface()},${n.first},${n.last},${n.mask},8h\n`;
207
+ }
208
+ else {
209
+ content += `dhcp-range=${await utils_1.default.iface()},${utils_1.default.address()},proxy,${n.mask},${utils_1.default.broadcast()} # dhcp proxy\n`;
210
+ }
211
+ let file = '/etc/dnsmasq.d/cuckoo.conf';
212
+ fs_1.default.writeFileSync(file, content);
213
+ // console.log(content)
214
+ await (0, utils_2.exec)(`systemctl start dnsmasq.service`);
215
+ }
216
+ /**
217
+ *
218
+ * @param cmd
219
+ */
220
+ async tryCatch(cmd = '') {
221
+ try {
222
+ await (0, utils_2.exec)(cmd, this.echo);
223
+ }
224
+ catch (error) {
225
+ console.log(`Error: ${error}`);
226
+ await utils_1.default.pressKeyToExit(cmd);
227
+ }
228
+ }
229
+ /**
230
+ * start http server for images
231
+ *
232
+ */
233
+ async httpStart() {
234
+ const port = 80;
235
+ const httpRoot = this.pxeRoot + "/";
236
+ var file = new (node_static_1.default.Server)(httpRoot);
237
+ http_1.default.createServer(function (req, res) {
238
+ file.serve(req, res);
239
+ }).listen(port);
240
+ }
241
+ }
242
+ exports.default = Pxe;
@@ -6,13 +6,13 @@
6
6
  */
7
7
  import { IRemix, IDistro, IApp, IWorkDir } from '../interfaces';
8
8
  import Incubator from './incubation/incubator';
9
- import { IConfig } from '../interfaces';
9
+ import { IEggsConfig } from '../interfaces';
10
10
  /**
11
11
  * Setting
12
12
  */
13
13
  export default class Settings {
14
14
  app: IApp;
15
- config: IConfig;
15
+ config: IEggsConfig;
16
16
  remix: IRemix;
17
17
  work_dir: IWorkDir;
18
18
  distro: IDistro;
@@ -31,7 +31,7 @@ export default class Settings {
31
31
  *
32
32
  * @param config
33
33
  */
34
- save(config: IConfig): Promise<void>;
34
+ save(config: IEggsConfig): Promise<void>;
35
35
  /**
36
36
  * Load configuration from config_file
37
37
  * @returns {boolean} Success
@@ -79,7 +79,8 @@ class Settings {
79
79
  this.work_dir.merged = this.work_dir.path + 'filesystem.squashfs';
80
80
  this.efi_work = this.work_dir.path + 'efi-work/';
81
81
  this.work_dir.pathIso = this.work_dir.path + 'iso/';
82
- if (this.config.snapshot_basename === 'hostname') {
82
+ // remember: before was hostname, not empty
83
+ if (this.config.snapshot_basename === '') {
83
84
  this.config.snapshot_basename = node_os_1.default.hostname();
84
85
  }
85
86
  if (this.config.make_efi && !pacman_1.default.isUefi()) {
@@ -4,7 +4,7 @@
4
4
  * email: piero.proietti@gmail.com
5
5
  * license: MIT
6
6
  */
7
- interface IConfigTools {
7
+ interface IEggsConfigTools {
8
8
  remoteHost: string;
9
9
  remoteUser: string;
10
10
  remotePathDeb: string;
@@ -23,7 +23,7 @@ export default class Tools {
23
23
  tools_yaml: string;
24
24
  snapshot_dir: string;
25
25
  snapshot_name: string;
26
- config: IConfigTools;
26
+ config: IEggsConfigTools;
27
27
  loadSettings(): Promise<boolean>;
28
28
  }
29
29
  export {};
@@ -194,7 +194,7 @@ export default class Utils {
194
194
  /**
195
195
  * return the name of network device
196
196
  */
197
- static iface(): string;
197
+ static iface(): Promise<string>;
198
198
  /**
199
199
  * address
200
200
  */
@@ -541,7 +541,7 @@ class Utils {
541
541
  /**
542
542
  * return the name of network device
543
543
  */
544
- static iface() {
544
+ static async iface() {
545
545
  // return shx.exec(`ifconfig | awk 'FNR==1 { print $1 }' | tr --d :`, { silent: true }).stdout.trim()
546
546
  const interfaces = Object.keys(os_1.default.networkInterfaces());
547
547
  let netDeviceName = '';