penguins-eggs 9.0.9 → 9.0.31

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 (86) hide show
  1. package/README.md +117 -20
  2. package/addons/eggs/theme/calamares/branding/show.qml +1 -1
  3. package/addons/eggs/theme/livecd/README.md +13 -15
  4. package/addons/eggs/theme/livecd/splash.png +0 -0
  5. package/addons/neon/theme/livecd/splash.png +0 -0
  6. package/addons/{blissos → telos}/theme/applications/install-debian.desktop +0 -0
  7. package/addons/{blissos → telos}/theme/artwork/install-debian.png +0 -0
  8. package/addons/telos/theme/calamares/branding/banner.png +0 -0
  9. package/addons/telos/theme/calamares/branding/branding.desc +25 -0
  10. package/addons/telos/theme/calamares/branding/show.qml +51 -0
  11. package/addons/telos/theme/calamares/branding/slide1.png +0 -0
  12. package/addons/telos/theme/calamares/branding/telos-logo.png +0 -0
  13. package/addons/telos/theme/calamares/branding/welcome.png +0 -0
  14. package/addons/{blissos → telos}/theme/calamares/modules/partition.yml +0 -0
  15. package/addons/{blissos → telos}/theme/livecd/grub.theme.cfg +2 -1
  16. package/addons/{blissos → telos}/theme/livecd/isolinux.theme.cfg +1 -1
  17. package/addons/telos/theme/livecd/splash.png +0 -0
  18. package/addons/templates/grub.template +2 -0
  19. package/addons/waydroid/theme/applications/install-debian.desktop +28 -0
  20. package/addons/waydroid/theme/artwork/install-debian.png +0 -0
  21. package/addons/{blissos → waydroid}/theme/calamares/branding/branding.desc +0 -0
  22. package/addons/{blissos → waydroid}/theme/calamares/branding/languages.png +0 -0
  23. package/addons/{blissos → waydroid}/theme/calamares/branding/show.qml +0 -0
  24. package/addons/{blissos → waydroid}/theme/calamares/branding/slide1.png +0 -0
  25. package/addons/{blissos → waydroid}/theme/calamares/branding/slide2.png +0 -0
  26. package/addons/{blissos → waydroid}/theme/calamares/branding/slide3.png +0 -0
  27. package/addons/{blissos/theme/calamares/branding/blissos-logo.png → waydroid/theme/calamares/branding/waydroid-logo.png} +0 -0
  28. package/addons/{blissos → waydroid}/theme/calamares/branding/welcome.png +0 -0
  29. package/addons/waydroid/theme/calamares/modules/partition.yml +233 -0
  30. package/addons/waydroid/theme/livecd/grub.theme.cfg +43 -0
  31. package/addons/waydroid/theme/livecd/isolinux.theme.cfg +45 -0
  32. package/addons/{blissos → waydroid}/theme/livecd/splash.png +0 -0
  33. package/conf/distros/buster/calamares/calamares-modules/sources-yolk/sources-yolk.sh +57 -38
  34. package/lib/classes/daddy.js +5 -5
  35. package/lib/classes/incubation/incubator.js +5 -0
  36. package/lib/classes/krill_install.d.ts +59 -30
  37. package/lib/classes/krill_install.js +596 -382
  38. package/lib/classes/krill_prepare.d.ts +7 -3
  39. package/lib/classes/krill_prepare.js +67 -26
  40. package/lib/classes/ovary.d.ts +33 -41
  41. package/lib/classes/ovary.js +400 -480
  42. package/lib/classes/systemctl.d.ts +36 -7
  43. package/lib/classes/systemctl.js +63 -28
  44. package/lib/classes/users.d.ts +21 -0
  45. package/lib/classes/users.js +129 -0
  46. package/lib/classes/utils.d.ts +8 -0
  47. package/lib/classes/utils.js +44 -15
  48. package/lib/classes/yolk.d.ts +6 -5
  49. package/lib/classes/yolk.js +30 -29
  50. package/lib/commands/analyze.d.ts +25 -0
  51. package/lib/commands/analyze.js +74 -0
  52. package/lib/commands/export/iso.js +1 -1
  53. package/lib/commands/install.d.ts +1 -0
  54. package/lib/commands/install.js +14 -3
  55. package/lib/commands/kill.js +1 -1
  56. package/lib/commands/produce.js +3 -3
  57. package/lib/commands/syncfrom.d.ts +37 -0
  58. package/lib/commands/syncfrom.js +156 -0
  59. package/lib/commands/syncto.d.ts +48 -0
  60. package/lib/commands/syncto.js +219 -0
  61. package/lib/components/elements/information.js +17 -1
  62. package/lib/components/partitions.d.ts +1 -2
  63. package/lib/components/partitions.js +1 -4
  64. package/lib/interfaces/i-analyze.d.ts +13 -0
  65. package/lib/interfaces/i-analyze.js +18 -0
  66. package/lib/interfaces/i-devices.d.ts +1 -0
  67. package/lib/interfaces/i-krill.d.ts +0 -1
  68. package/lib/lib/cli-autologin.js +8 -3
  69. package/lib/lib/select_installation_device.js +1 -0
  70. package/lib/lib/select_installation_mode.js +1 -1
  71. package/manpages/doc/man/eggs.html +65 -6
  72. package/oclif.manifest.json +1 -1
  73. package/package.json +19 -18
  74. package/scripts/_eggs +36 -6
  75. package/scripts/bros/waydroid-helper.sh +1 -1
  76. package/scripts/eggs.bash +4 -1
  77. package/scripts/{not-used/install-eggs-ppa.sh → install-eggs-ppa.sh} +1 -0
  78. package/scripts/mom-cli.sh +1 -1
  79. package/scripts/{not-used/pve-live.sh → pve-live.sh} +2 -6
  80. package/addons/blissos/theme/livecd/README.md +0 -23
  81. package/addons/eggs/theme/calamares/branding/4tation.png +0 -0
  82. package/addons/neon/theme/livecd/README.md +0 -23
  83. package/addons/neon/theme/livecd/splash.pcx +0 -0
  84. package/scripts/not-used/eggs-cleanup.sh +0 -7
  85. package/scripts/not-used/mkinitramfs +0 -469
  86. package/scripts/update-initramfs +0 -94
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * penguins-eggs: hatching.js
3
+ * penguins-eggs: krill_install
4
4
  *
5
5
  * author: Piero Proietti
6
6
  * mail: piero.proietti@gmail.com
@@ -22,7 +22,6 @@ const pacman_1 = (0, tslib_1.__importDefault)(require("./pacman"));
22
22
  const installer_1 = require("./incubation/installer");
23
23
  const xdg_1 = (0, tslib_1.__importDefault)(require("./xdg"));
24
24
  const distro_1 = (0, tslib_1.__importDefault)(require("./distro"));
25
- const child_process_1 = require("child_process");
26
25
  const utils_2 = require("../lib/utils");
27
26
  /**
28
27
  * hatching: installazione o cova!!!
@@ -35,6 +34,7 @@ class Hatching {
35
34
  this.installer = {};
36
35
  this.installTarget = '/tmp/calamares-krill-root';
37
36
  this.verbose = false;
37
+ this.echo = {};
38
38
  this.efi = false;
39
39
  this.devices = {};
40
40
  this.users = {};
@@ -50,6 +50,10 @@ class Hatching {
50
50
  this.settings = {};
51
51
  this.remix = {};
52
52
  this.distro = {};
53
+ this.luksName = '';
54
+ this.luksFile = '';
55
+ this.luksDevice = '';
56
+ this.luksMountpoint = '';
53
57
  this.installer = (0, installer_1.installer)();
54
58
  this.settings = new settings_1.default();
55
59
  this.language = location.language;
@@ -68,6 +72,11 @@ class Hatching {
68
72
  this.devices.swap = {};
69
73
  this.distro = new distro_1.default(this.remix);
70
74
  this.efi = fs_1.default.existsSync('/sys/firmware/efi/efivars');
75
+ // Per il restore dei dati
76
+ this.luksName = 'luks-eggs-backup';
77
+ this.luksFile = `/run/live/medium/live/${this.luksName}`;
78
+ this.luksDevice = `/dev/mapper/${this.luksName}`;
79
+ this.luksMountpoint = `/mnt`;
71
80
  }
72
81
  /**
73
82
  * install
@@ -77,45 +86,56 @@ class Hatching {
77
86
  */
78
87
  async install(verbose = false) {
79
88
  this.verbose = verbose;
89
+ this.echo = utils_1.default.setEcho(this.verbose);
90
+ if (this.verbose) {
91
+ this.toNull = '';
92
+ }
93
+ // start
80
94
  await this.settings.load();
95
+ // partition
81
96
  let percent = 0.0;
82
97
  let message = "";
83
- if (await this.partition()) {
98
+ let isPartitioned = false;
99
+ message = "Creating partitions";
100
+ percent = 0.01;
101
+ try {
102
+ redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
103
+ isPartitioned = await this.partition();
104
+ }
105
+ catch (error) {
106
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
107
+ }
108
+ if (isPartitioned) {
109
+ // formatting
84
110
  message = "Formatting file system ";
85
- percent = 0.01;
111
+ percent = 0.02;
86
112
  try {
87
113
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
88
114
  await this.mkfs();
89
115
  }
90
116
  catch (error) {
91
- message += JSON.stringify(error);
92
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
117
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
93
118
  }
94
- // await checkIt(message)
95
- // mount
119
+ // mountFs
96
120
  message = "Mounting target file system ";
97
121
  percent = 0.03;
98
122
  try {
99
123
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
100
- await this.mount();
124
+ await this.mountFs();
101
125
  }
102
126
  catch (error) {
103
- message += JSON.stringify(error);
104
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
127
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
105
128
  }
106
- // await checkIt(message)
107
- // mountvfs
108
- message = "Mounting target file system vfs ";
129
+ // mountVfs
130
+ message = "Mounting on target VFS ";
109
131
  percent = 0.06;
110
132
  try {
111
133
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
112
- await this.mountvfs();
134
+ await this.mountVfs();
113
135
  }
114
136
  catch (error) {
115
- message += JSON.stringify(error);
116
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
137
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
117
138
  }
118
- // await checkIt(message)
119
139
  // unpackfs
120
140
  message = "Unpacking filesystem ";
121
141
  percent = 0.10;
@@ -124,36 +144,22 @@ class Hatching {
124
144
  await this.unpackfs();
125
145
  }
126
146
  catch (error) {
127
- message += JSON.stringify(error);
128
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
129
- }
130
- // await checkIt(message)
131
- message = "Syncronize filesystem ";
132
- percent = 0.35;
133
- try {
134
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent, spinner: true }));
135
- await this.syncfs();
136
- }
137
- catch (error) {
138
- message += JSON.stringify(error);
139
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
147
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
140
148
  }
141
- // await checkIt(message)
142
149
  /**
143
- * RESTORE USERS DATA
150
+ * IF RESTORE USERS DATA
144
151
  */
145
- if (fs_1.default.existsSync('/run/live/medium/live/luks-users-data')) {
146
- message = "Restore users data from backup ";
152
+ if (fs_1.default.existsSync(this.luksFile)) {
153
+ // restoring users data
154
+ message = "Restore private data from backup ";
147
155
  percent = 0.37;
148
156
  try {
149
157
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent, spinner: true }));
150
- await this.restoreUsersData();
158
+ await (0, utils_2.exec)('eggs syncfrom --rootdir /tmp/calamares-krill-root/', this.echo);
151
159
  }
152
160
  catch (error) {
153
- message += JSON.stringify(error);
154
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
161
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
155
162
  }
156
- // await checkIt(message)
157
163
  }
158
164
  // sources-yolk
159
165
  message = 'sources-yolk';
@@ -163,10 +169,19 @@ class Hatching {
163
169
  await this.execCalamaresModule('sources-yolk');
164
170
  }
165
171
  catch (error) {
166
- message += JSON.stringify(error);
167
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
172
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
173
+ }
174
+ // machineid
175
+ message = 'machineid';
176
+ percent = 0.41;
177
+ try {
178
+ redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent, spinner: true }));
179
+ await this.machineId();
180
+ }
181
+ catch (error) {
182
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
168
183
  }
169
- // await checkIt(message)
184
+ // timezone
170
185
  message = "Setting time zone ";
171
186
  percent = 0.43;
172
187
  try {
@@ -174,10 +189,9 @@ class Hatching {
174
189
  await this.setTimezone();
175
190
  }
176
191
  catch (error) {
177
- message += JSON.stringify(error);
178
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
192
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
179
193
  }
180
- // await checkIt(message)
194
+ // fstab
181
195
  message = "Creating fstab ";
182
196
  percent = 0.47;
183
197
  try {
@@ -185,30 +199,27 @@ class Hatching {
185
199
  await this.fstab(this.partitions.installationDevice);
186
200
  }
187
201
  catch (error) {
188
- message += JSON.stringify(error);
189
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
202
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
190
203
  }
191
- // await checkIt(message)
204
+ // keyboard
192
205
  message = "settings keyboard ";
193
206
  percent = 0.48;
194
207
  try {
195
208
  this.setKeyboard();
196
209
  }
197
210
  catch (error) {
198
- message += JSON.stringify(error);
199
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
211
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
200
212
  }
201
- // await checkIt(message)
213
+ // networkcfg
202
214
  message = "networkcfg";
203
215
  percent = 0.50;
204
216
  try {
205
217
  this.networkcfg();
206
218
  }
207
219
  catch (error) {
208
- message += JSON.stringify(error);
209
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
220
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
210
221
  }
211
- // await checkIt(message)
222
+ // hostname
212
223
  message = "Create hostname ";
213
224
  percent = 0.53;
214
225
  try {
@@ -216,10 +227,9 @@ class Hatching {
216
227
  await this.hostname();
217
228
  }
218
229
  catch (error) {
219
- message += JSON.stringify(error);
220
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
230
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
221
231
  }
222
- // await checkIt(message)
232
+ // hosts
223
233
  message = "Creating hosts ";
224
234
  percent = 0.60;
225
235
  try {
@@ -227,32 +237,39 @@ class Hatching {
227
237
  await this.hosts();
228
238
  }
229
239
  catch (error) {
230
- message += JSON.stringify(error);
231
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
240
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
232
241
  }
233
- // await checkIt(message)
242
+ // bootloader-config
234
243
  message = "bootloader-config ";
235
- percent = 0.63;
244
+ percent = 0.62;
236
245
  try {
237
246
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
238
247
  await this.execCalamaresModule('bootloader-config');
239
248
  }
240
249
  catch (error) {
241
- message += JSON.stringify(error);
250
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
251
+ }
252
+ // grubcfg
253
+ message = "grubcfg ";
254
+ percent = 0.63;
255
+ try {
242
256
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
257
+ await this.grubcfg();
258
+ }
259
+ catch (error) {
260
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
243
261
  }
244
- // await checkIt(message)
262
+ // bootloader
245
263
  message = "bootloader ";
246
- percent = 0.63;
264
+ percent = 0.64;
247
265
  try {
248
266
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
249
267
  await this.bootloader();
250
268
  }
251
269
  catch (error) {
252
- message += JSON.stringify(error);
253
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
270
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
254
271
  }
255
- // await checkIt(message)
272
+ // initramfsCfg
256
273
  message = "initramfs configure";
257
274
  percent = 0.65;
258
275
  try {
@@ -260,10 +277,9 @@ class Hatching {
260
277
  this.initramfsCfg(this.partitions.installationDevice);
261
278
  }
262
279
  catch (error) {
263
- message += JSON.stringify(error);
264
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
280
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
265
281
  }
266
- // await checkIt(message)
282
+ // initramfs
267
283
  message = "initramfs ";
268
284
  percent = 0.67;
269
285
  try {
@@ -271,10 +287,9 @@ class Hatching {
271
287
  await this.initramfs();
272
288
  }
273
289
  catch (error) {
274
- message += JSON.stringify(error);
275
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
290
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
276
291
  }
277
- // await checkIt(message)
292
+ // delLiveUser
278
293
  message = "Removing user live ";
279
294
  percent = 0.70;
280
295
  try {
@@ -282,16 +297,13 @@ class Hatching {
282
297
  await this.delLiveUser();
283
298
  }
284
299
  catch (error) {
285
- message += JSON.stringify(error);
286
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
300
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
287
301
  }
288
- // await checkIt(message)
289
302
  /**
290
- * IF NOT RESTORE-USERS-ACCOUNTS
291
- *
292
- * create user
303
+ * if NOT restore users data
293
304
  */
294
- if (!fs_1.default.existsSync('/run/live/medium/live/luks-users-data')) {
305
+ if (!fs_1.default.existsSync(this.luksFile)) {
306
+ // addUser
295
307
  message = "Adding user ";
296
308
  percent = 0.73;
297
309
  try {
@@ -299,22 +311,20 @@ class Hatching {
299
311
  await this.addUser(this.users.name, this.users.password, this.users.fullname, '', '', '');
300
312
  }
301
313
  catch (error) {
302
- message += JSON.stringify(error);
314
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
315
+ }
316
+ // changePassword
317
+ message = "adding user password ";
318
+ percent = 0.77;
319
+ try {
303
320
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
321
+ await this.changePassword('root', this.users.rootPassword);
322
+ }
323
+ catch (error) {
324
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
304
325
  }
305
- // await checkIt(message)
306
- }
307
- message = "adding user password ";
308
- percent = 0.77;
309
- try {
310
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
311
- await this.changePassword('root', this.users.rootPassword);
312
- }
313
- catch (error) {
314
- message += JSON.stringify(error);
315
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
316
326
  }
317
- // await checkIt(message)
327
+ // autologin
318
328
  if (pacman_1.default.isInstalledGui()) {
319
329
  try {
320
330
  message = "autologin GUI";
@@ -323,8 +333,7 @@ class Hatching {
323
333
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
324
334
  }
325
335
  catch (error) {
326
- message += JSON.stringify(error);
327
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
336
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
328
337
  }
329
338
  }
330
339
  else { // autologin CLI remove DEFAULT
@@ -335,14 +344,13 @@ class Hatching {
335
344
  await cliAutologin.remove(this.installTarget);
336
345
  }
337
346
  catch (error) {
338
- message += JSON.stringify(error);
339
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
347
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
340
348
  }
341
349
  }
342
- // eggs-cleanup forced
350
+ // cleanup
343
351
  await cliAutologin.msgRemove(`${this.installTarget}/etc/motd`);
344
352
  await cliAutologin.msgRemove(`${this.installTarget}/etc/issue`);
345
- // await checkIt(message)
353
+ // removeInstaller
346
354
  message = "remove installer";
347
355
  percent = 0.87;
348
356
  try {
@@ -350,10 +358,9 @@ class Hatching {
350
358
  await this.removeInstaller();
351
359
  }
352
360
  catch (error) {
353
- message += JSON.stringify(error);
354
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
361
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
355
362
  }
356
- // await checkIt(message)
363
+ // sourcesYolkUmount
357
364
  message = "sources yolk unmount";
358
365
  percent = 0.92;
359
366
  try {
@@ -361,31 +368,37 @@ class Hatching {
361
368
  await this.execCalamaresModule('sources-yolk-unmount');
362
369
  }
363
370
  catch (error) {
364
- message += JSON.stringify(error);
371
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
372
+ }
373
+ // umountVfs
374
+ message = "umount VFS";
375
+ percent = 0.95;
376
+ try {
365
377
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
378
+ await this.umountVfs();
379
+ }
380
+ catch (error) {
381
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
366
382
  }
367
- // await checkIt(message)
383
+ // umount
368
384
  message = "umount";
369
- percent = 0.92;
385
+ percent = 0.97;
370
386
  try {
371
387
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
372
- await this.umountvfs();
373
- await this.umount();
388
+ await this.umountFs();
374
389
  }
375
390
  catch (error) {
376
- message += JSON.stringify(error);
377
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
391
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
378
392
  }
379
- // await checkIt(message)
393
+ // finished
380
394
  message = "finished";
381
395
  percent = 100.0;
382
396
  try {
383
397
  redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
384
- this.finished();
398
+ await this.finished();
385
399
  }
386
400
  catch (error) {
387
- message += JSON.stringify(error);
388
- redraw(react_1.default.createElement(install_1.default, { message: message, percent: percent }));
401
+ await utils_1.default.pressKeyToExit(JSON.stringify(error));
389
402
  }
390
403
  }
391
404
  }
@@ -393,13 +406,12 @@ class Hatching {
393
406
  * setTimezone
394
407
  */
395
408
  async setTimezone() {
396
- const echo = { echo: false, ignore: false };
397
409
  if (fs_1.default.existsSync('/etc/localtime')) {
398
410
  const cmd = `chroot ${this.installTarget} unlink /etc/localtime`;
399
- await (0, utils_2.exec)(cmd, echo);
411
+ await (0, utils_2.exec)(cmd, this.echo);
400
412
  }
401
413
  const cmd = `chroot ${this.installTarget} ln -sf /usr/share/zoneinfo/${this.region}/${this.zone} /etc/localtime`;
402
- await (0, utils_2.exec)(cmd, echo);
414
+ await (0, utils_2.exec)(cmd, this.echo);
403
415
  }
404
416
  /**
405
417
  *
@@ -411,16 +423,15 @@ class Hatching {
411
423
  * @param homePhone
412
424
  */
413
425
  async addUser(name = 'live', password = 'evolution', fullName = '', roomNumber = '', workPhone = '', homePhone = '') {
414
- const echo = { echo: false, ignore: false };
415
426
  const cmd = `chroot ${this.installTarget} \
416
427
  adduser ${name} \
417
428
  --home /home/${name} \
418
429
  --shell /bin/bash \
419
430
  --disabled-password \
420
- --gecos "${fullName},${roomNumber},${workPhone},${homePhone}"`;
421
- await (0, utils_2.exec)(cmd, echo);
422
- await (0, utils_2.exec)(`echo ${name}:${password} | chroot ${this.installTarget} chpasswd `, echo);
423
- await (0, utils_2.exec)(`chroot ${this.installTarget} usermod -aG sudo ${name}`, echo);
431
+ --gecos "${fullName},${roomNumber},${workPhone},${homePhone}" ${this.toNull}`;
432
+ await (0, utils_2.exec)(cmd, this.echo);
433
+ await (0, utils_2.exec)(`echo ${name}:${password} | chroot ${this.installTarget} chpasswd ${this.toNull}`, this.echo);
434
+ await (0, utils_2.exec)(`chroot ${this.installTarget} usermod -aG sudo ${name} ${this.toNull}`, this.echo);
424
435
  }
425
436
  /**
426
437
  * changePassword
@@ -428,20 +439,18 @@ adduser ${name} \
428
439
  * @param newPassword
429
440
  */
430
441
  async changePassword(name = 'live', newPassword = 'evolution') {
431
- const echo = utils_1.default.setEcho(this.verbose);
432
- const cmd = `echo ${name}:${newPassword} | chroot ${this.installTarget} chpasswd `;
433
- await (0, utils_2.exec)(cmd, echo);
442
+ const cmd = `echo ${name}:${newPassword} | chroot ${this.installTarget} chpasswd ${this.toNull}`;
443
+ await (0, utils_2.exec)(cmd, this.echo);
434
444
  }
435
445
  /**
436
446
  * delUser
437
447
  * va corretto con users.conf di calamares
438
448
  */
439
449
  async delLiveUser() {
440
- const echo = { echo: false, ignore: false };
441
450
  if (utils_1.default.isLive()) {
442
451
  const user = this.settings.config.user_opt;
443
- const cmd = `chroot ${this.installTarget} deluser --remove-home ${user}`;
444
- await (0, utils_2.exec)(cmd, echo);
452
+ const cmd = `chroot ${this.installTarget} deluser --remove-home ${user} ${this.toNull}`;
453
+ await (0, utils_2.exec)(cmd, this.echo);
445
454
  }
446
455
  }
447
456
  /**
@@ -450,9 +459,9 @@ adduser ${name} \
450
459
  * @param options
451
460
  */
452
461
  async bootloader() {
453
- await (0, utils_2.exec)('chroot ' + this.installTarget + ' grub-install ' + this.partitions.installationDevice); // + this.toNull
454
- await (0, utils_2.exec)('chroot ' + this.installTarget + ' update-grub'); // + this.toNull
455
- await (0, utils_2.exec)('sleep 1'); // + this.toNull
462
+ await (0, utils_2.exec)(`chroot ${this.installTarget} grub-install ${this.partitions.installationDevice} ${this.toNull}`, this.echo);
463
+ await (0, utils_2.exec)(`chroot ${this.installTarget} update-grub ${this.toNull}`, this.echo);
464
+ await (0, utils_2.exec)(`sleep 1 ${this.toNull}`, this.echo);
456
465
  }
457
466
  /**
458
467
  *
@@ -473,16 +482,41 @@ adduser ${name} \
473
482
  * initramfs()
474
483
  */
475
484
  async initramfs() {
476
- const echo = { echo: false, ignore: false };
477
- await (0, utils_2.exec)('chroot ' + this.installTarget + ' mkinitramfs -o ~/initrd.img-$(uname -r)', echo);
478
- await (0, utils_2.exec)('chroot ' + this.installTarget + ' mv ~/initrd.img-$(uname -r) /boot', echo);
485
+ await (0, utils_2.exec)(`chroot ${this.installTarget} mkinitramfs -o ~/initrd.img-$(uname -r) ${this.toNull}`, this.echo);
486
+ await (0, utils_2.exec)(`chroot ${this.installTarget} mv ~/initrd.img-$(uname -r) /boot ${this.toNull}`, this.echo);
479
487
  }
480
488
  /**
481
489
  * fstab()
482
490
  * @param devices
483
491
  */
484
- async fstab(installDevice) {
485
- const file = this.installTarget + '/etc/fstab';
492
+ async fstab(installDevice, crypted = false) {
493
+ let text = '';
494
+ /**
495
+ * crypttab
496
+ */
497
+ if (this.partitions.installationMode === 'full-encrypted') {
498
+ const crypttab = this.installTarget + '/etc/crypttab';
499
+ text = ``;
500
+ text += `# /etc/crypttab: mappings for encrypted partitions.\n`;
501
+ text += `#\n`;
502
+ text += `# Each mapped device will be created in /dev/mapper, so your /etc/fstab\n`;
503
+ text += `# should use the /dev/mapper/<name> paths for encrypted devices.\n`;
504
+ text += `#\n`;
505
+ text += `# See crypttab(5) for the supported syntax.\n`;
506
+ text += `#\n`;
507
+ text += `# NOTE: You need not list your root (/) partition here, but it must be set up\n`;
508
+ text += `# beforehand by the initramfs (/etc/mkinitcpio.conf). The same applies\n`;
509
+ text += `# to encrypted swap, which should be set up with mkinitcpio-openswap\n`;
510
+ text += `# for resume support.\n`;
511
+ text += `#\n`;
512
+ text += `# <name> <device> <password> <options>\n`;
513
+ text += `#swap_crypted was ${this.devices.swap.cryptedFrom}\n`;
514
+ text += `swap_crypted UUID=${utils_1.default.uuid(this.devices.swap.cryptedFrom)} none luks,discard\n`;
515
+ text += `#root_crypted was ${this.devices.root.cryptedFrom}\n`;
516
+ text += `root_crypted UUID=${utils_1.default.uuid(this.devices.root.cryptedFrom)} none luks,swap\n`;
517
+ utils_1.default.write(crypttab, text);
518
+ }
519
+ const fstab = this.installTarget + '/etc/fstab';
486
520
  let mountOptsRoot = '';
487
521
  let mountOptsBoot = '';
488
522
  let mountOptsData = ``;
@@ -502,7 +536,7 @@ adduser ${name} \
502
536
  mountOptsEfi = 'defaults,noatime 0 2';
503
537
  mountOptsSwap = 'defaults,noatime 0 2';
504
538
  }
505
- let text = '';
539
+ text = ``;
506
540
  text += `# ${this.devices.root.name} ${this.devices.root.mountPoint} ${this.devices.root.fsType} ${mountOptsRoot}\n`;
507
541
  text += `UUID=${utils_1.default.uuid(this.devices.root.name)} ${this.devices.root.mountPoint} ${this.devices.root.fsType} ${mountOptsRoot}\n`;
508
542
  if (this.devices.boot.name !== `none`) {
@@ -519,7 +553,7 @@ adduser ${name} \
519
553
  }
520
554
  text += `# ${this.devices.swap.name} ${this.devices.swap.mountPoint} ${this.devices.swap.fsType} ${mountOptsSwap}\n`;
521
555
  text += `UUID=${utils_1.default.uuid(this.devices.swap.name)} ${this.devices.swap.mountPoint} ${this.devices.swap.fsType} ${mountOptsSwap}\n`;
522
- utils_1.default.write(file, text);
556
+ utils_1.default.write(fstab, text);
523
557
  }
524
558
  /**
525
559
  * setKeyboard
@@ -535,14 +569,16 @@ adduser ${name} \
535
569
  content += '\n';
536
570
  content += 'BACKSPACE="guess"\n';
537
571
  utils_1.default.write(file, content);
538
- // lancio setupcon in chroot per salvare la tastiera
539
- const echo = { echo: false, ignore: false };
540
- const cmd = 'chroot ' + this.installTarget + ' ' + 'setupcon ' + this.toNull;
572
+ /**
573
+ * set keyboard
574
+ */
575
+ const cmd = `chroot ${this.installTarget} setupcon ${this.toNull}`;
541
576
  try {
542
- await (0, utils_2.exec)(cmd, echo);
577
+ await (0, utils_2.exec)(cmd, this.echo);
543
578
  }
544
579
  catch (error) {
545
580
  console.log(error);
581
+ utils_1.default.pressKeyToExit(cmd, true);
546
582
  }
547
583
  }
548
584
  /**
@@ -553,12 +589,15 @@ adduser ${name} \
553
589
  let content = '# created by eggs\n\n';
554
590
  content += 'auto lo\n';
555
591
  content += 'iface lo inet loopback\n\n';
556
- content += 'auto ' + this.network.iface + '\n';
557
- content += 'iface ' + this.network.iface + ' inet ' + this.network.addressType + '\n';
558
- if (this.network.addressType !== 'dhcp') {
559
- content += ' address ' + this.network.address + '\n';
560
- content += ' netmask ' + this.network.netmask + '\n';
561
- content += ' gateway ' + this.network.gateway + '\n';
592
+ // if netplan, don't create entries in /etc/network/interfaces
593
+ if (!pacman_1.default.packageIsInstalled('netplan.io')) {
594
+ content += 'auto ' + this.network.iface + '\n';
595
+ content += 'iface ' + this.network.iface + ' inet ' + this.network.addressType + '\n';
596
+ if (this.network.addressType !== 'dhcp') {
597
+ content += ' address ' + this.network.address + '\n';
598
+ content += ' netmask ' + this.network.netmask + '\n';
599
+ content += ' gateway ' + this.network.gateway + '\n';
600
+ }
562
601
  }
563
602
  utils_1.default.write(file, content);
564
603
  /**
@@ -578,10 +617,9 @@ adduser ${name} \
578
617
  * hostname
579
618
  */
580
619
  async hostname() {
581
- const echo = { echo: false, ignore: false };
582
620
  const file = this.installTarget + '/etc/hostname';
583
621
  const text = this.users.hostname;
584
- await (0, utils_2.exec)(`rm ${file} `, echo);
622
+ await (0, utils_2.exec)(`rm ${file} `, this.echo);
585
623
  fs_1.default.writeFileSync(file, text);
586
624
  }
587
625
  /**
@@ -635,15 +673,14 @@ adduser ${name} \
635
673
  * unpackfs
636
674
  */
637
675
  async unpackfs() {
638
- const echo = utils_1.default.setEcho(this.verbose);
639
- const cmd = 'unsquashfs -d ' + this.installTarget + ' -f ' + this.distro.mountpointSquashFs;
640
- await (0, utils_2.exec)(cmd);
676
+ const echoYes = utils_1.default.setEcho(true);
677
+ const cmd = `unsquashfs -d ${this.installTarget} -f ${this.distro.mountpointSquashFs}`;
678
+ await (0, utils_2.exec)(cmd, echoYes);
641
679
  }
642
680
  /**
643
681
  * syncfs
644
682
  */
645
683
  async syncfs() {
646
- const echo = utils_1.default.setEcho(this.verbose);
647
684
  let cmd = '';
648
685
  let f = '';
649
686
  f += ' --filter="- /cdrom/*"';
@@ -687,274 +724,368 @@ adduser ${name} \
687
724
  --delete -excluded \
688
725
  --info=progress2 \
689
726
  ${f} \
690
- / ${this.installTarget}`;
691
- await (0, utils_2.exec)(cmd.trim());
692
- }
693
- /**
694
- *
695
- */
696
- async restoreUsersData() {
697
- utils_1.default.warning('Opening volume luks-users-data and map it in /dev/mapper/eggs-users-data.');
698
- utils_1.default.warning('You will insert the same passphrase you choose during the backup production');
699
- (0, child_process_1.execSync)('sudo cryptsetup luksOpen /run/live/medium/live/luks-users-data eggs-users-data', { stdio: 'inherit' });
700
- utils_1.default.warning('mounting volume eggs-users-data in /mnt');
701
- (0, child_process_1.execSync)('sudo mount /dev/mapper/eggs-users-data /mnt', { stdio: 'inherit' });
702
- utils_1.default.warning('removing live user in the installed system');
703
- (0, child_process_1.execSync)('rm -rf /tmp/calamares-krill-root/home/*', { stdio: 'inherit' });
704
- utils_1.default.warning('copying users home in the installed system');
705
- (0, child_process_1.execSync)('rsync -a /mnt/home/ /tmp/calamares-krill-root/home/', { stdio: 'inherit' });
706
- utils_1.default.warning('copying users accounts in the installed system');
707
- (0, child_process_1.execSync)('cp /mnt/etc/passwd /tmp/calamares-krill-root/etc/', { stdio: 'inherit' });
708
- (0, child_process_1.execSync)('cp /mnt/etc/shadow /tmp/calamares-krill-root/etc/', { stdio: 'inherit' });
709
- (0, child_process_1.execSync)('cp /mnt/etc/group /tmp/calamares-krill-root/etc/', { stdio: 'inherit' });
710
- utils_1.default.warning('unmount /mnt');
711
- (0, child_process_1.execSync)('umount /mnt', { stdio: 'inherit' });
712
- utils_1.default.warning('closing eggs-users-data');
713
- (0, child_process_1.execSync)('cryptsetup luksClose eggs-users-data', { stdio: 'inherit' });
727
+ / ${this.installTarget} ${this.toNull}`;
728
+ await (0, utils_2.exec)(cmd.trim(), this.echo);
714
729
  }
715
730
  /**
716
731
  * mkfs
717
732
  */
718
733
  async mkfs() {
719
- const echo = { echo: false, ignore: false };
720
734
  const result = true;
721
735
  if (this.efi) {
722
- await (0, utils_2.exec)(`mkdosfs -F 32 -I ${this.devices.efi.name}` + this.toNull, echo);
736
+ await (0, utils_2.exec)(`mkdosfs -F 32 -I ${this.devices.efi.name} ${this.toNull}`, this.echo);
723
737
  }
724
738
  if (this.devices.boot.name !== 'none') {
725
- // controllare se non vada !== undefined
726
739
  if (this.devices.boot.fsType === undefined) {
727
740
  this.devices.boot.fsType = `ext2`;
728
741
  this.devices.boot.mountPoint = '/boot';
729
742
  }
730
- await (0, utils_2.exec)('mke2fs -Ft ' + this.devices.boot.fsType + ' ' + this.devices.boot.name + this.toNull, echo);
743
+ await (0, utils_2.exec)(`mke2fs -Ft ${this.devices.boot.fsType} ${this.devices.boot.name} ${this.toNull}`, this.echo);
731
744
  }
732
745
  if (this.devices.root.name !== 'none') {
733
- await (0, utils_2.exec)('mke2fs -Ft ' + this.devices.root.fsType + ' ' + this.devices.root.name + this.toNull, echo);
746
+ await (0, utils_2.exec)(`mke2fs -Ft ${this.devices.root.fsType} ${this.devices.root.name} ${this.toNull}`, this.echo);
734
747
  }
735
748
  if (this.devices.data.name !== 'none') {
736
- await (0, utils_2.exec)('mke2fs -Ft ' + this.devices.data.fsType + ' ' + this.devices.data.name + this.toNull, echo);
749
+ await (0, utils_2.exec)(`mke2fs -Ft ${this.devices.data.fsType} ${this.devices.data.name} ${this.toNull}`, this.echo);
737
750
  }
738
751
  if (this.devices.swap.name !== 'none') {
739
- await (0, utils_2.exec)('mkswap ' + this.devices.swap.name + this.toNull, echo);
752
+ await (0, utils_2.exec)(`mkswap ${this.devices.swap.name} ${this.toNull}`, this.echo);
740
753
  }
741
754
  return result;
742
755
  }
756
+ /**
757
+ *
758
+ * @param device
759
+ */
760
+ async ifMountedDismount(device = '') {
761
+ if ((await (0, utils_2.exec)(`findmnt -rno SOURCE ${device}`)).data.trim() === device) {
762
+ await (0, utils_2.exec)(`umount ${device} ${this.toNull}`, this.echo);
763
+ await (0, utils_2.exec)('sleep 1', this.echo);
764
+ }
765
+ }
743
766
  /**
744
767
  * mount
745
768
  */
746
- async mount() {
747
- const echo = { echo: false, ignore: false };
769
+ async mountFs() {
748
770
  if (!fs_1.default.existsSync(this.installTarget)) {
749
- await (0, utils_2.exec)(`mkdir ${this.installTarget}` + this.toNull, echo);
771
+ await (0, utils_2.exec)(`mkdir ${this.installTarget} ${this.toNull}`, this.echo);
750
772
  }
751
773
  // root
752
- await (0, utils_2.exec)(`mount ${this.devices.root.name} ${this.installTarget}${this.devices.root.mountPoint}` + this.toNull, echo);
753
- await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.root.name}` + this.toNull, echo);
754
- await (0, utils_2.exec)(`rm -rf ${this.installTarget}/lost+found` + this.toNull, echo);
774
+ await (0, utils_2.exec)(`mount ${this.devices.root.name} ${this.installTarget}${this.devices.root.mountPoint} ${this.toNull}`, this.echo);
775
+ await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.root.name} ${this.toNull}`, this.echo);
776
+ await (0, utils_2.exec)(`rm -rf ${this.installTarget}/lost+found ${this.toNull}`, this.echo);
755
777
  // boot
756
778
  if (this.devices.boot.name !== `none`) {
757
- await (0, utils_2.exec)(`mkdir ${this.installTarget}/boot -p` + this.toNull);
758
- await (0, utils_2.exec)(`mount ${this.devices.boot.name} ${this.installTarget}${this.devices.boot.mountPoint}` + this.toNull, echo);
759
- await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.boot.name}` + this.toNull, echo);
779
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/boot -p ${this.toNull}`, this.echo);
780
+ await (0, utils_2.exec)(`mount ${this.devices.boot.name} ${this.installTarget}${this.devices.boot.mountPoint} ${this.toNull}`, this.echo);
781
+ await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.boot.name} ${this.toNull}`, this.echo);
760
782
  }
761
783
  // data
762
784
  if (this.devices.data.name !== `none`) {
763
- await (0, utils_2.exec)(`mkdir ${this.installTarget}${this.devices.data.mountPoint} -p` + this.toNull);
764
- await (0, utils_2.exec)(`mount ${this.devices.data.name} ${this.installTarget}${this.devices.data.mountPoint}` + this.toNull, echo);
765
- await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.data.name}` + this.toNull, echo);
785
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}${this.devices.data.mountPoint} -p ${this.toNull}`, this.echo);
786
+ await (0, utils_2.exec)(`mount ${this.devices.data.name} ${this.installTarget}${this.devices.data.mountPoint} ${this.toNull}`, this.echo);
787
+ await (0, utils_2.exec)(`tune2fs -c 0 -i 0 ${this.devices.data.name} ${this.toNull}`, this.echo);
766
788
  }
767
789
  // efi
768
790
  if (this.efi) {
769
791
  if (!fs_1.default.existsSync(this.installTarget + this.devices.efi.mountPoint)) {
770
- await (0, utils_2.exec)(`mkdir ${this.installTarget}${this.devices.efi.mountPoint} -p` + this.toNull, echo);
771
- await (0, utils_2.exec)(`mount ${this.devices.efi.name} ${this.installTarget}${this.devices.efi.mountPoint}` + this.toNull, echo);
792
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}${this.devices.efi.mountPoint} -p ${this.toNull}`, this.echo);
793
+ await (0, utils_2.exec)(`mount ${this.devices.efi.name} ${this.installTarget}${this.devices.efi.mountPoint} ${this.toNull}`, this.echo);
772
794
  }
773
795
  }
774
796
  return true;
775
797
  }
776
798
  /**
777
- * umount
799
+ * umountFs
778
800
  */
779
- async umount() {
780
- const echo = { echo: false, ignore: false };
801
+ async umountFs() {
802
+ // efi
781
803
  if (this.efi) {
782
- await (0, utils_2.exec)(`umount ${this.installTarget}/boot/efi` + this.toNull, echo);
783
- await (0, utils_2.exec)('sleep 1', echo);
804
+ await this.umount(this.devices.efi.name);
784
805
  }
785
806
  // data
786
807
  if (this.devices.data.name !== `none`) {
787
- await (0, utils_2.exec)(`umount ${this.devices.data.name}` + this.toNull, echo);
808
+ await this.umount(this.devices.data.name);
788
809
  }
789
- // root
810
+ // boot
790
811
  if (this.devices.boot.name !== `none`) {
791
- await (0, utils_2.exec)(`umount ${this.devices.boot.name}` + this.toNull, echo);
812
+ await this.umount(this.devices.boot.name);
792
813
  }
793
- await (0, utils_2.exec)(`umount ${this.devices.root.name}` + this.toNull, echo);
794
- await (0, utils_2.exec)('sleep 1', echo);
814
+ // root
815
+ await this.umount(this.devices.root.name);
795
816
  return true;
796
817
  }
797
818
  /**
798
819
  * mountvfs()
799
820
  */
800
- async mountvfs() {
801
- const echo = { echo: true, ignore: true };
802
- await (0, utils_2.exec)('mkdir ' + this.installTarget + '/dev' + this.toNull);
803
- await (0, utils_2.exec)('mkdir ' + this.installTarget + '/dev/pts' + this.toNull);
804
- await (0, utils_2.exec)('mkdir ' + this.installTarget + '/proc' + this.toNull);
805
- await (0, utils_2.exec)('mkdir ' + this.installTarget + '/sys' + this.toNull);
806
- await (0, utils_2.exec)('mkdir ' + this.installTarget + '/run' + this.toNull);
807
- await (0, utils_2.exec)(`mount -o bind /dev ${this.installTarget}/dev` + this.toNull, echo);
808
- await (0, utils_2.exec)(`mount -o bind /dev/pts ${this.installTarget}/dev/pts` + this.toNull, echo);
809
- await (0, utils_2.exec)(`mount -o bind /proc ${this.installTarget}/proc` + this.toNull, echo);
810
- await (0, utils_2.exec)(`mount -o bind /sys ${this.installTarget}/sys` + this.toNull, echo);
811
- /**
812
- * I know, that's very old thread, but maybe will help for someone.
813
- * Most guides suggest the same solution to mount virtual filesystems before chroot:
814
- * for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
815
- * But now (maybe related to efivars/efivarfs changes) this loop skips one very special sub-mountpoint
816
- * - /sys/firmware/efi/efivars and efibootmgr/grub fails.
817
- *
818
- * https://unix.stackexchange.com/questions/91620/efi-variables-are-not-supported-on-this-system
819
- */
820
- await (0, utils_2.exec)(`mount -o bind /sys/firmware/efi/efivars ${this.installTarget}/sys/firmware/efi/efivars` + this.toNull, echo);
821
- await (0, utils_2.exec)(`mount -o bind /run ${this.installTarget}/run` + this.toNull, echo);
821
+ async mountVfs() {
822
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/dev ${this.toNull}`, this.echo);
823
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/dev/pts ${this.toNull}`, this.echo);
824
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/proc ${this.toNull}`, this.echo);
825
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/sys ${this.toNull}`, this.echo);
826
+ await (0, utils_2.exec)(`mkdir ${this.installTarget}/run ${this.toNull}`, this.echo);
827
+ await (0, utils_2.exec)(`mount -o bind /dev ${this.installTarget}/dev ${this.toNull}`, this.echo);
828
+ await (0, utils_2.exec)(`mount -o bind /dev/pts ${this.installTarget}/dev/pts ${this.toNull}`, this.echo);
829
+ await (0, utils_2.exec)(`mount -o bind /proc ${this.installTarget}/proc ${this.toNull}`, this.echo);
830
+ await (0, utils_2.exec)(`mount -o bind /sys ${this.installTarget}/sys ${this.toNull}`, this.echo);
831
+ if (this.efi) {
832
+ await (0, utils_2.exec)(`mount -o bind /sys/firmware/efi/efivars ${this.installTarget}/sys/firmware/efi/efivars ${this.toNull}`, this.echo);
833
+ }
834
+ await (0, utils_2.exec)(`mount -o bind /run ${this.installTarget}/run ${this.toNull}`, this.echo);
822
835
  }
823
836
  /**
837
+ *
824
838
  */
825
- async umountvfs() {
826
- const echo = { echo: false, ignore: false };
827
- if (utils_1.default.isMountpoint(`${this.installTarget}/dev/pts`)) {
828
- await (0, utils_2.exec)(`umount ${this.installTarget}/dev/pts` + this.toNull, echo);
829
- await (0, utils_2.exec)('sleep 1', echo);
830
- }
831
- if (utils_1.default.isMountpoint(`${this.installTarget}/dev`)) {
832
- await (0, utils_2.exec)(`umount ${this.installTarget}/dev` + this.toNull, echo);
833
- await (0, utils_2.exec)('sleep 1', echo);
834
- }
835
- if (utils_1.default.isMountpoint(`${this.installTarget}/proc`)) {
836
- await (0, utils_2.exec)(`umount ${this.installTarget}/proc` + this.toNull, echo);
837
- await (0, utils_2.exec)('sleep 1', echo);
838
- }
839
- if (utils_1.default.isMountpoint(`${this.installTarget}/run`)) {
840
- await (0, utils_2.exec)(`umount ${this.installTarget}/run` + this.toNull, echo);
841
- await (0, utils_2.exec)('sleep 1', echo);
842
- }
843
- if (utils_1.default.isMountpoint(`${this.installTarget}/sys/fs/fuse/connections`)) {
844
- await (0, utils_2.exec)(`umount ${this.installTarget}/sys/fs/fuse/connections` + this.toNull, echo);
845
- await (0, utils_2.exec)('sleep 1', echo);
846
- }
847
- if (utils_1.default.isMountpoint(`${this.installTarget}/firmware/efi/efivars`)) {
848
- await (0, utils_2.exec)(`umount ${this.installTarget}/firmware/efi/efivars` + this.toNull, echo);
849
- await (0, utils_2.exec)('sleep 1', echo);
839
+ async umountVfs() {
840
+ await this.umount(`${this.installTarget}/dev/pts`);
841
+ await this.umount(`${this.installTarget}/dev`);
842
+ await this.umount(`${this.installTarget}/proc`);
843
+ await this.umount(`${this.installTarget}/run`);
844
+ if (this.efi) {
845
+ await this.umount(`${this.installTarget}/sys/firmware/efi/efivars`);
850
846
  }
851
- if (utils_1.default.isMountpoint(`${this.installTarget}/sys`)) {
852
- await (0, utils_2.exec)(`umount ${this.installTarget}/sys` + this.toNull, echo);
853
- await (0, utils_2.exec)('sleep 1', echo);
847
+ await this.umount(`${this.installTarget}/sys`);
848
+ }
849
+ /**
850
+ *
851
+ * @param mountpoint
852
+ */
853
+ async umount(mountPoint = '') {
854
+ let message = 'umount: ' + mountPoint;
855
+ if (utils_1.default.isMountpoint(mountPoint)) {
856
+ try {
857
+ await (0, utils_2.exec)(`umount ${mountPoint} ${this.toNull}`, this.echo);
858
+ await (0, utils_2.exec)('sleep 1', this.echo);
859
+ }
860
+ catch (error) {
861
+ message += +mountPoint + JSON.stringify(error);
862
+ redraw(react_1.default.createElement(install_1.default, { message: message, percent: 1 }));
863
+ await utils_1.default.pressKeyToExit(message);
864
+ }
854
865
  }
855
866
  }
856
867
  /**
857
868
  *
858
- * @param p
859
- * @returns
860
869
  */
861
870
  async partition() {
862
- const echo = { echo: false, ignore: false };
871
+ let echoYes = utils_1.default.setEcho(true);
863
872
  let retVal = false;
864
- await (0, utils_2.exec)('wipefs -a ' + this.partitions.installationDevice + this.toNull);
865
- if (this.partitions.installationMode === 'standard' && !this.efi) {
873
+ const installDevice = this.partitions.installationDevice;
874
+ /**
875
+ * Support for NVMe
876
+ *
877
+ * /dev/sda1 = /dev/nvme0n1p1
878
+ */
879
+ let p = '';
880
+ if (installDevice.includes('nvme')) {
881
+ p = 'p';
882
+ }
883
+ const installMode = this.partitions.installationMode;
884
+ if (installMode === 'standard' && !this.efi) {
866
885
  /**
867
- * formattazione standard, BIOS working
886
+ * ===========================================================================================
887
+ * BIOS: working
888
+ * ===========================================================================================
868
889
  */
869
- await (0, utils_2.exec)('parted --script ' + this.partitions.installationDevice + ' mklabel msdos' + this.toNull, echo);
870
- await (0, utils_2.exec)('parted --script --align optimal ' + this.partitions.installationDevice + ' mkpart primary 1MiB 95%' + this.toNull, echo);
871
- await (0, utils_2.exec)('parted --script ' + this.partitions.installationDevice + ' set 1 boot on' + this.toNull, echo);
872
- await (0, utils_2.exec)('parted --script --align optimal ' + this.partitions.installationDevice + ' mkpart primary 95% 100%' + this.toNull, echo);
873
- this.devices.efi.name = `none`;
874
- this.devices.boot.name = `none`;
875
- this.devices.root.name = this.partitions.installationDevice + '1';
890
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel msdos`, this.echo);
891
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary linux-swap 1MiB 8192MiB`, this.echo); //dev/sda1 swap
892
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary ext4 8192MiB 100%`, this.echo); //dev/sda2 root
893
+ await (0, utils_2.exec)(`parted ${installDevice} set 1 boot on`, this.echo);
894
+ await (0, utils_2.exec)(`parted ${installDevice} set 1 esp on`, this.echo);
895
+ // SWAP
896
+ this.devices.swap.name = `${installDevice}${p}1`;
897
+ this.devices.swap.fsType = 'swap';
898
+ this.devices.swap.mountPoint = 'none';
899
+ // ROOT
900
+ this.devices.root.name = `${installDevice}${p}2`;
876
901
  this.devices.root.fsType = 'ext4';
877
902
  this.devices.root.mountPoint = '/';
903
+ // BOOT/DATA/EFI
904
+ this.devices.boot.name = `none`;
878
905
  this.devices.data.name = `none`;
879
- this.devices.swap.name = this.partitions.installationDevice + '2';
906
+ this.devices.efi.name = `none`;
907
+ retVal = true;
908
+ }
909
+ else if (installMode === 'full-encrypted' && !this.efi) {
910
+ /**
911
+ * ===========================================================================================
912
+ * BIOS: full-encrypt:
913
+ * ===========================================================================================
914
+ */
915
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel msdos`, this.echo);
916
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary ext4 1MiB 512MiB`, this.echo); // sda1
917
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary linux-swap 512MiB 8704MiB`, this.echo); // sda2
918
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary ext4 8704MiB 100%`, this.echo); // sda3
919
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 boot on`, this.echo); // sda1
920
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 esp on`, this.echo); // sda1
921
+ // BOOT 512M
922
+ this.devices.boot.name = `${installDevice}${p}1`; // 'boot'
923
+ this.devices.boot.fsType = 'ext4';
924
+ this.devices.boot.mountPoint = '/boot';
925
+ // SWAP 8G
926
+ redraw(react_1.default.createElement(install_1.default, { message: `Formatting LUKS ${installDevice}2`, percent: 0 }));
927
+ let crytoSwap = await (0, utils_2.exec)(`cryptsetup -y -v luksFormat --type luks2 ${installDevice}${p}2`, echoYes);
928
+ if (crytoSwap.code !== 0) {
929
+ utils_1.default.warning(`Error: ${crytoSwap.code} ${crytoSwap.data}`);
930
+ process.exit(1);
931
+ }
932
+ redraw(react_1.default.createElement(install_1.default, { message: `Opening ${installDevice}${p}2 as swap_crypted`, percent: 0 }));
933
+ let crytoSwapOpen = await (0, utils_2.exec)(`cryptsetup luksOpen --type luks2 ${installDevice}${p}2 swap_crypted`, echoYes);
934
+ if (crytoSwapOpen.code !== 0) {
935
+ utils_1.default.warning(`Error: ${crytoSwapOpen.code} ${crytoSwapOpen.data}`);
936
+ process.exit(1);
937
+ }
938
+ this.devices.swap.name = '/dev/mapper/swap_crypted';
939
+ this.devices.swap.cryptedFrom = `${installDevice}${p}2`;
880
940
  this.devices.swap.fsType = 'swap';
881
941
  this.devices.swap.mountPoint = 'none';
942
+ // ROOT
943
+ redraw(react_1.default.createElement(install_1.default, { message: `Formatting LUKS ${installDevice}${p}3`, percent: 0 }));
944
+ let crytoRoot = await (0, utils_2.exec)(`cryptsetup -y -v luksFormat --type luks2 ${installDevice}${p}3`, echoYes);
945
+ if (crytoRoot.code !== 0) {
946
+ utils_1.default.warning(`Error: ${crytoRoot.code} ${crytoRoot.data}`);
947
+ process.exit(1);
948
+ }
949
+ redraw(react_1.default.createElement(install_1.default, { message: `Opening ${installDevice}${p}3 as root_crypted`, percent: 0 }));
950
+ let crytoRootOpen = await (0, utils_2.exec)(`cryptsetup luksOpen --type luks2 ${installDevice}${p}3 root_crypted`, echoYes);
951
+ if (crytoRootOpen.code !== 0) {
952
+ utils_1.default.warning(`Error: ${crytoRootOpen.code} ${crytoRootOpen.data}`);
953
+ process.exit(1);
954
+ }
955
+ this.devices.root.name = '/dev/mapper/root_crypted';
956
+ this.devices.root.cryptedFrom = `${installDevice}${p}3`;
957
+ this.devices.root.fsType = 'ext4';
958
+ this.devices.root.mountPoint = '/';
959
+ // BOOT/DATA/EFI
960
+ this.devices.data.name = `none`;
961
+ this.devices.efi.name = `none`;
882
962
  retVal = true;
883
963
  }
884
- else if (this.partitions.installationMode === 'standard' && this.efi) {
964
+ else if (installMode === 'standard' && this.efi) {
885
965
  /**
886
- * formattazione standard, EFI NOT working
966
+ * ===========================================================================================
967
+ * UEFI: working
968
+ * ===========================================================================================
887
969
  */
888
- await (0, utils_2.exec)('parted --script ' + this.partitions.installationDevice + ' mklabel gpt mkpart primary 0% 1% mkpart primary 1% 95% mkpart primary linux-swap 95% 100%' + this.toNull, echo);
889
- await (0, utils_2.exec)('parted --script ' + this.partitions.installationDevice + ' set 1 boot on' + this.toNull, echo);
890
- await (0, utils_2.exec)('parted --script ' + this.partitions.installationDevice + ' set 1 esp on' + this.toNull, echo);
891
- this.devices.efi.name = this.partitions.installationDevice + '1';
970
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel gpt`, this.echo);
971
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart efi fat32 34s 256MiB`, this.echo); // sda1 EFI
972
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart swap linux-swap 768MiB 8960MiB`, this.echo); // sda2 swap
973
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart root ext4 8960MiB 100%`, this.echo); // sda3 root
974
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 boot on`, this.echo); // sda1
975
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 esp on`, this.echo); // sda1
976
+ this.devices.efi.name = `${installDevice}${p}1`;
892
977
  this.devices.efi.fsType = 'F 32 -I';
893
978
  this.devices.efi.mountPoint = '/boot/efi';
894
979
  this.devices.boot.name = `none`;
895
- this.devices.root.name = this.partitions.installationDevice + '2';
980
+ this.devices.swap.name = `${installDevice}${p}2`;
981
+ this.devices.swap.fsType = 'swap';
982
+ this.devices.root.name = `${installDevice}${p}3`;
896
983
  this.devices.root.fsType = 'ext4';
897
984
  this.devices.root.mountPoint = '/';
985
+ // BOOT/DATA/EFI
986
+ this.devices.boot.name = `none`;
898
987
  this.devices.data.name = `none`;
899
- this.devices.swap.name = this.partitions.installationDevice + '3';
900
- this.devices.swap.fsType = 'swap';
988
+ // this.devices.efi.name = `none`
901
989
  retVal = true;
990
+ }
991
+ else if (installMode === 'full-encrypted' && this.efi) {
902
992
  /**
903
- * formattazione full-encrypted, BIOS standard
904
- * cryptsetup -y -v --type luks2 luksFormat this.partitions.installationDevice
905
- * cryptsetup luksOpen /dev/sda vgeggs
906
- * Enter passphrase for /dev/sda: this.partitions.luksPassphrase
907
- * pv -tpreb /dev/zero | dd of=/dev/mapper/vgeggs bs=128M
908
- * mkfs.ext4 /dev/mapper/vgeggs
909
- * cryptsetup luksClose vgeggs
993
+ * ===========================================================================================
994
+ * UEFI, full-encrypt
995
+ * ===========================================================================================
910
996
  */
911
- }
912
- else if (this.partitions.installationMode === 'full-encrypted' && !this.efi) {
913
- await (0, utils_2.exec)(`cryptsetup -y -v --type luks2 luksFormat ${this.partitions.installationDevice}`, echo);
914
- await (0, utils_2.exec)(`cryptsetup luksOpen ${this.partitions.installationDevice} vgeggs`, echo);
915
- await (0, utils_2.exec)(`pv -tpreb /dev/zero | dd of=/dev/mapper/vgeggs bs=128M`, echo);
916
- this.devices.efi.name = `none`;
917
- this.devices.boot.name = `none`;
918
- this.devices.root.name = '/dev/mapper/vgeggs';
919
- this.devices.root.fsType = this.partitions.filesystemType;
997
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel gpt`, this.echo);
998
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart efi fat32 34s 256MiB`, this.echo); // sda1 EFI
999
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart boot ext4 256MiB 768MiB`, this.echo); // sda2 boot
1000
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart swap linux-swap 768MiB 8960MiB`, this.echo); // sda3 swap
1001
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart root ext4 8960MiB 100%`, this.echo); // sda4 root
1002
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 boot on`, this.echo); // sda1
1003
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 esp on`, this.echo); // sda1
1004
+ // EFI 256M
1005
+ this.devices.efi.name = `${installDevice}${p}1`; // 'efi'
1006
+ this.devices.efi.fsType = 'F 32 -I';
1007
+ this.devices.efi.mountPoint = '/boot/efi';
1008
+ // BOOT 512M
1009
+ this.devices.boot.name = `${installDevice}${p}2`; // 'boot'
1010
+ this.devices.boot.fsType = 'ext4';
1011
+ this.devices.boot.mountPoint = '/boot';
1012
+ /**
1013
+ * cryptsetup return codes are:
1014
+ *
1015
+ * 1 wrong parameters,
1016
+ * 2 no permission (bad passphrase),
1017
+ * 3 out of memory,
1018
+ * 4 wrong device specified,
1019
+ * 5 device already exists or device is busy.
1020
+ *
1021
+ * sometime due scarce memory 2GB, we can have the process killed
1022
+ */
1023
+ // SWAP 8G
1024
+ redraw(react_1.default.createElement(install_1.default, { message: `Formatting LUKS ${installDevice}${p}3`, percent: 0 }));
1025
+ let crytoSwap = await (0, utils_2.exec)(`cryptsetup -y -v luksFormat --type luks2 ${installDevice}${p}3`, echoYes);
1026
+ if (crytoSwap.code !== 0) {
1027
+ utils_1.default.warning(`Error: ${crytoSwap.code} ${crytoSwap.data}`);
1028
+ process.exit(1);
1029
+ }
1030
+ redraw(react_1.default.createElement(install_1.default, { message: `Opening ${installDevice}${p}3 as swap_crypted`, percent: 0 }));
1031
+ let crytoSwapOpen = await (0, utils_2.exec)(`cryptsetup luksOpen --type luks2 ${installDevice}${p}3 swap_crypted`, echoYes);
1032
+ if (crytoSwapOpen.code !== 0) {
1033
+ utils_1.default.warning(`Error: ${crytoSwapOpen.code} ${crytoSwapOpen.data}`);
1034
+ process.exit(1);
1035
+ }
1036
+ this.devices.swap.name = '/dev/mapper/swap_crypted';
1037
+ this.devices.swap.cryptedFrom = `${installDevice}${p}3`;
1038
+ this.devices.swap.fsType = 'swap';
1039
+ this.devices.swap.mountPoint = 'none';
1040
+ // ROOT
1041
+ redraw(react_1.default.createElement(install_1.default, { message: `Formatting LUKS ${installDevice}${p}4`, percent: 0 }));
1042
+ let crytoRoot = await (0, utils_2.exec)(`cryptsetup -y -v luksFormat --type luks2 ${installDevice}${p}4`, echoYes);
1043
+ if (crytoRoot.code !== 0) {
1044
+ utils_1.default.warning(`Error: ${crytoRoot.code} ${crytoRoot.data}`);
1045
+ process.exit(1);
1046
+ }
1047
+ redraw(react_1.default.createElement(install_1.default, { message: `Opening ${installDevice}${p}4 as root_crypted`, percent: 0 }));
1048
+ let crytoRootOpen = await (0, utils_2.exec)(`cryptsetup luksOpen --type luks2 ${installDevice}${p}4 root_crypted`, echoYes);
1049
+ if (crytoRootOpen.code !== 0) {
1050
+ utils_1.default.warning(`Error: ${crytoRootOpen.code} ${crytoRootOpen.data}`);
1051
+ process.exit(1);
1052
+ }
1053
+ this.devices.root.name = '/dev/mapper/root_crypted';
1054
+ this.devices.root.cryptedFrom = `${installDevice}${p}4`;
1055
+ this.devices.root.fsType = 'ext4';
920
1056
  this.devices.root.mountPoint = '/';
1057
+ // BOOT/DATA/EFI
1058
+ // this.devices.boot.name = `none`
921
1059
  this.devices.data.name = `none`;
922
- this.devices.swap.name = 'none';
923
- this.devices.swap.fsType = 'none';
924
- this.devices.swap.mountPoint = 'none';
1060
+ // this.devices.efi.name = `none`
925
1061
  retVal = true;
926
1062
  }
927
- else if (this.partitions.installationMode === 'lvm2' && !this.efi) {
1063
+ else if (installMode === 'lvm2' && !this.efi) {
928
1064
  /**
929
- * LVM2, non EFI PROXMOX-VE
1065
+ * ===========================================================================================
1066
+ * PROXMOX VE: BIOS and lvm2
1067
+ * ===========================================================================================
930
1068
  */
931
- await (0, utils_2.exec)(`parted --script ${this.partitions.installationDevice} mklabel msdos`);
932
1069
  // Creo partizioni
933
- await (0, utils_2.exec)(`parted --script ${this.partitions.installationDevice} mkpart primary ext2 1 512`);
934
- await (0, utils_2.exec)(`parted --script --align optimal ${this.partitions.installationDevice} set 1 boot on`);
935
- await (0, utils_2.exec)(`parted --script --align optimal ${this.partitions.installationDevice} mkpart primary ext2 512 100%`);
936
- await (0, utils_2.exec)(`parted --script ${this.partitions.installationDevice} set 2 lvm on`);
937
- // Partizione LVM
938
- const lvmPartname = shx.exec(`fdisk $1 -l | grep 8e | awk '{print $1}' | cut -d "/" -f3`).stdout.trim();
939
- const lvmByteSize = Number(shx.exec(`cat /proc/partitions | grep ${lvmPartname}| awk '{print $3}' | grep "[0-9]"`).stdout.trim());
940
- const lvmSize = lvmByteSize / 1024;
941
- // La partizione di root viene posta ad 1/4 della partizione LVM.
942
- // Viene limitata fino ad un massimo di 100 GB
943
- const lvmSwapSize = 4 * 1024;
944
- let lvmRootSize = lvmSize / 8;
945
- if (lvmRootSize < 20480) {
946
- lvmRootSize = 20480;
947
- }
948
- const lvmDataSize = lvmSize - lvmRootSize - lvmSwapSize;
949
- await (0, utils_2.exec)(`pvcreate /dev/${lvmPartname}`);
950
- await (0, utils_2.exec)(`vgcreate pve /dev/${lvmPartname}`);
951
- await (0, utils_2.exec)(`vgchange -an`);
952
- await (0, utils_2.exec)(`lvcreate -L ${lvmSwapSize} -nswap pve`);
953
- await (0, utils_2.exec)(`lvcreate -L ${lvmRootSize} -nroot pve`);
954
- await (0, utils_2.exec)(`lvcreate -l 100%FREE -ndata pve`);
955
- await (0, utils_2.exec)(`vgchange -a y pve`);
1070
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel msdos`, this.echo);
1071
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart primary ext2 1 512`, this.echo); // sda1
1072
+ await (0, utils_2.exec)(`parted --script --align optimal ${installDevice} mkpart primary ext2 512 100%`, this.echo); // sda2
1073
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 boot on`, this.echo); // sda1
1074
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 2 lvm on`, this.echo); // sda2
1075
+ const lvmPartInfo = await this.lvmPartInfo(installDevice);
1076
+ const lvmPartname = lvmPartInfo[0];
1077
+ const lvmSwapSize = lvmPartInfo[1];
1078
+ const lvmRootSize = lvmPartInfo[2];
1079
+ //const lvmDataSize = lvmPartInfo[3]
1080
+ await (0, utils_2.exec)(`pvcreate /dev/${lvmPartname}`, this.echo);
1081
+ await (0, utils_2.exec)(`vgcreate pve /dev/${lvmPartname}`, this.echo);
1082
+ await (0, utils_2.exec)(`vgchange -an`, this.echo);
1083
+ await (0, utils_2.exec)(`lvcreate -L ${lvmSwapSize} -nswap pve`, this.echo);
1084
+ await (0, utils_2.exec)(`lvcreate -L ${lvmRootSize} -nroot pve`, this.echo);
1085
+ await (0, utils_2.exec)(`lvcreate -l 100%FREE -ndata pve`, this.echo);
1086
+ await (0, utils_2.exec)(`vgchange -a y pve`, this.echo);
956
1087
  this.devices.efi.name = `none`;
957
- this.devices.boot.name = `${this.partitions.installationDevice}1`;
1088
+ this.devices.boot.name = `${installDevice}${p}1`;
958
1089
  this.devices.root.fsType = 'ext2';
959
1090
  this.devices.root.mountPoint = '/boot';
960
1091
  this.devices.root.name = `/dev/pve/root`;
@@ -968,13 +1099,63 @@ adduser ${name} \
968
1099
  }
969
1100
  else if (this.partitions.installationMode === 'lvm2' && this.efi) {
970
1101
  /**
971
- * LVM2, EFI
1102
+ * ===========================================================================================
1103
+ * PROXMOX VE: lvm2 and UEFI
1104
+ * ===========================================================================================
972
1105
  */
973
- console.log('LVM2 on UEFI: to be implemented!');
974
- process.exit(0);
1106
+ await (0, utils_2.exec)(`parted --script ${installDevice} mklabel gpt`, this.echo);
1107
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart efi fat32 34s 256MiB`, this.echo); // sda1 EFI
1108
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart boot ext2 256MiB 768MiB`, this.echo); // sda2 boot
1109
+ await (0, utils_2.exec)(`parted --script ${installDevice} mkpart lvm ext4 768MiB 100%`, this.echo); // sda3 lmv2
1110
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 boot on`, this.echo); // sda1
1111
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 1 esp on`, this.echo); // sda1
1112
+ await (0, utils_2.exec)(`parted --script ${installDevice} set 3 lvm on`, this.echo); // sda3
1113
+ const lvmPartInfo = await this.lvmPartInfo(installDevice);
1114
+ const lvmPartname = lvmPartInfo[0];
1115
+ const lvmSwapSize = lvmPartInfo[1];
1116
+ const lvmRootSize = lvmPartInfo[2];
1117
+ //const lvmDataSize = lvmPartInfo[3]
1118
+ await (0, utils_2.exec)(`pvcreate /dev/${lvmPartname}`, this.echo);
1119
+ await (0, utils_2.exec)(`vgcreate pve /dev/${lvmPartname}`, this.echo);
1120
+ await (0, utils_2.exec)(`vgchange -an`, this.echo);
1121
+ await (0, utils_2.exec)(`lvcreate -L ${lvmSwapSize} -nswap pve`, this.echo);
1122
+ await (0, utils_2.exec)(`lvcreate -L ${lvmRootSize} -nroot pve`, this.echo);
1123
+ await (0, utils_2.exec)(`lvcreate -l 100%FREE -ndata pve`, this.echo);
1124
+ await (0, utils_2.exec)(`vgchange -a y pve`, this.echo);
1125
+ this.devices.efi.name = `${installDevice}${p}1`;
1126
+ this.devices.efi.fsType = 'F 32 -I';
1127
+ this.devices.efi.mountPoint = '/boot/efi';
1128
+ this.devices.boot.name = `${installDevice}${p}2`;
1129
+ this.devices.boot.fsType = 'ext4';
1130
+ this.devices.boot.mountPoint = '/boot';
1131
+ this.devices.root.name = `/dev/pve/root`;
1132
+ this.devices.root.fsType = 'ext4';
1133
+ this.devices.root.mountPoint = '/';
1134
+ this.devices.data.name = `/dev/pve/data`;
1135
+ this.devices.data.fsType = 'ext4';
1136
+ this.devices.data.mountPoint = '/var/lib/vz';
1137
+ this.devices.swap.name = `/dev/pve/swap`;
1138
+ retVal = true;
975
1139
  }
976
1140
  return retVal;
977
1141
  }
1142
+ /**
1143
+ * Return lvmPartname, lvmSwapSize, lvmRootSize
1144
+ */
1145
+ async lvmPartInfo(installDevice = '/dev/sda') {
1146
+ // Partizione LVM
1147
+ const lvmPartname = shx.exec(`fdisk ${installDevice} -l | grep LVM | awk '{print $1}' | cut -d "/" -f3`).stdout.trim();
1148
+ const lvmByteSize = Number(shx.exec(`cat /proc/partitions | grep ${lvmPartname}| awk '{print $3}' | grep "[0-9]"`).stdout.trim());
1149
+ const lvmSize = lvmByteSize / 1024;
1150
+ // La partizione di root viene posta ad 1/4 della partizione LVM, limite max 100 GB
1151
+ const lvmSwapSize = 8192;
1152
+ let lvmRootSize = lvmSize / 8;
1153
+ if (lvmRootSize < 20480) {
1154
+ lvmRootSize = 20480;
1155
+ }
1156
+ const lvmDataSize = lvmSize - lvmRootSize - lvmSwapSize;
1157
+ return [lvmPartname, lvmSwapSize, lvmRootSize, lvmDataSize];
1158
+ }
978
1159
  /**
979
1160
  * isRotational
980
1161
  * @param device
@@ -995,24 +1176,21 @@ adduser ${name} \
995
1176
  * @param name
996
1177
  */
997
1178
  async execCalamaresModule(name) {
998
- const echo = { echo: false, ignore: false };
999
- const moduleName = this.installer.multiarchModules + name + '/module.desc';
1000
- if (fs_1.default.existsSync(moduleName)) {
1001
- console.log('analyzing: ' + moduleName);
1002
- const calamaresModule = js_yaml_1.default.load(fs_1.default.readFileSync(moduleName, 'utf8'));
1003
- let command = calamaresModule.command;
1004
- console.log('command: ' + command);
1005
- if (command !== '' || command !== undefined) {
1006
- command += this.toNull;
1007
- (0, child_process_1.execSync)(command);
1008
- }
1179
+ /**
1180
+ * patch per ubuntu sostituisce bootloader-config e bootloader
1181
+ */
1182
+ if (name === 'bootloader-config' && this.distro.distroLike === 'ubuntu') {
1183
+ await this.bootloaderConfigUbuntu();
1009
1184
  }
1010
1185
  else {
1011
- /**
1012
- * patch per ubuntu sostituisce bootloader-config e bootloader
1013
- */
1014
- if (name === 'bootloader-config') {
1015
- await this.bootloaderConfigUbuntu();
1186
+ const moduleName = this.installer.multiarchModules + name + '/module.desc';
1187
+ if (fs_1.default.existsSync(moduleName)) {
1188
+ const calamaresModule = js_yaml_1.default.load(fs_1.default.readFileSync(moduleName, 'utf8'));
1189
+ let command = calamaresModule.command;
1190
+ if (command !== '' || command !== undefined) {
1191
+ command += this.toNull;
1192
+ await (0, utils_2.exec)(command, this.echo);
1193
+ }
1016
1194
  }
1017
1195
  }
1018
1196
  }
@@ -1020,84 +1198,127 @@ adduser ${name} \
1020
1198
  *
1021
1199
  */
1022
1200
  async bootloaderConfigUbuntu() {
1023
- const echo = { echo: false, ignore: false };
1024
1201
  let cmd = '';
1025
1202
  try {
1026
- cmd = 'chroot ' + this.installTarget + ' ' + 'apt-get update -y ' + this.toNull;
1027
- await (0, utils_2.exec)(cmd, echo);
1203
+ cmd = `chroot ${this.installTarget} apt-get update -y ${this.toNull}`;
1204
+ await (0, utils_2.exec)(cmd, this.echo);
1028
1205
  }
1029
1206
  catch (error) {
1030
1207
  console.log(error);
1208
+ await utils_1.default.pressKeyToExit(cmd, true);
1031
1209
  }
1032
1210
  try {
1033
- cmd = 'chroot ' + this.installTarget + ' sleep 1' + this.toNull;
1034
- await (0, utils_2.exec)(cmd, echo);
1211
+ cmd = `chroot ${this.installTarget} sleep 1 ${this.toNull}`;
1212
+ await (0, utils_2.exec)(cmd, this.echo);
1035
1213
  }
1036
1214
  catch (error) {
1037
1215
  console.log(error);
1216
+ await utils_1.default.pressKeyToExit(cmd, true);
1038
1217
  }
1039
1218
  let aptInstallOptions = ' apt install -y --no-upgrade --allow-unauthenticated -o Acquire::gpgv::Options::=--ignore-time-conflict ';
1040
1219
  if (this.efi) {
1041
1220
  try {
1042
- cmd = 'chroot ' + this.installTarget + aptInstallOptions + ' grub-efi-' + utils_1.default.machineArch() + ' --allow-unauthenticated ' + this.toNull;
1043
- await (0, utils_2.exec)(cmd, echo);
1221
+ cmd = `chroot ${this.installTarget} ${aptInstallOptions} grub-efi-${utils_1.default.machineArch()} --allow-unauthenticated ${this.toNull}`;
1222
+ await (0, utils_2.exec)(cmd, this.echo);
1044
1223
  }
1045
1224
  catch (error) {
1046
- console.log('cmd: ' + cmd + ' error: ' + error);
1225
+ console.log(error);
1226
+ await utils_1.default.pressKeyToExit(cmd, true);
1047
1227
  }
1048
1228
  }
1049
1229
  else {
1050
1230
  try {
1051
- cmd = 'chroot ' + this.installTarget + aptInstallOptions + ' grub-pc' + this.toNull;
1052
- await (0, utils_2.exec)(cmd, echo);
1231
+ cmd = `chroot ${this.installTarget} ${aptInstallOptions} grub-pc ${this.toNull}`;
1232
+ await (0, utils_2.exec)(cmd, this.echo);
1053
1233
  }
1054
1234
  catch (error) {
1055
- console.log('cmd: ' + cmd + ' error: ' + error);
1235
+ console.log(error);
1236
+ await utils_1.default.pressKeyToExit(cmd, true);
1056
1237
  }
1057
1238
  }
1058
1239
  try {
1059
- cmd = 'chroot ' + this.installTarget + ' sleep 1' + this.toNull;
1060
- await (0, utils_2.exec)(cmd, echo);
1240
+ cmd = `chroot ${this.installTarget} sleep 1 ${this.toNull}`;
1241
+ await (0, utils_2.exec)(cmd, this.echo);
1061
1242
  }
1062
1243
  catch (error) {
1063
- console.log('cmd: ' + cmd + ' error: ' + error);
1244
+ console.log(error);
1245
+ await utils_1.default.pressKeyToExit(cmd, true);
1064
1246
  }
1065
1247
  try {
1066
- cmd = 'chroot ' + this.installTarget + ' grub-install ' + this.partitions.installationDevice + this.toNull;
1067
- await (0, utils_2.exec)(cmd, echo);
1248
+ cmd = `chroot ${this.installTarget} grub-install ${this.partitions.installationDevice} ${this.toNull}`;
1249
+ await (0, utils_2.exec)(cmd, this.echo);
1068
1250
  }
1069
1251
  catch (error) {
1070
- console.log('cmd: ' + cmd + ' error: ' + error);
1252
+ console.log(error);
1253
+ await utils_1.default.pressKeyToExit(cmd, true);
1071
1254
  }
1072
1255
  try {
1073
- cmd = 'chroot ' + this.installTarget + ' grub-mkconfig -o /boot/grub/grub.cfg' + this.toNull;
1074
- await (0, utils_2.exec)(cmd, echo);
1256
+ cmd = `chroot ${this.installTarget} grub-mkconfig -o /boot/grub/grub.cfg ${this.toNull}`;
1257
+ await (0, utils_2.exec)(cmd, this.echo);
1075
1258
  }
1076
1259
  catch (error) {
1077
- console.log('cmd: ' + cmd + ' error: ' + error);
1260
+ console.log(error);
1261
+ await utils_1.default.pressKeyToExit(cmd, true);
1078
1262
  }
1079
- // await Utils.customConfirmAbort(cmd)
1080
1263
  try {
1081
- cmd = 'chroot ' + this.installTarget + ' update-grub' + this.toNull;
1082
- await (0, utils_2.exec)(cmd, echo);
1264
+ cmd = `chroot ${this.installTarget} update-grub ${this.toNull}`;
1265
+ await (0, utils_2.exec)(cmd, this.echo);
1083
1266
  }
1084
1267
  catch (error) {
1085
- console.log('cmd: ' + cmd + ' error: ' + error);
1268
+ console.log(error);
1269
+ await utils_1.default.pressKeyToExit(cmd, true);
1086
1270
  }
1087
1271
  try {
1088
- cmd = 'chroot ' + this.installTarget + ' sleep 1' + this.toNull;
1089
- await (0, utils_2.exec)(cmd, echo);
1272
+ cmd = `chroot ${this.installTarget} sleep 1 ${this.toNull}`;
1273
+ await (0, utils_2.exec)(cmd, this.echo);
1090
1274
  }
1091
1275
  catch (error) {
1092
- console.log('cmd: ' + cmd + ' error: ' + error);
1276
+ console.log(error);
1277
+ await utils_1.default.pressKeyToExit(cmd, true);
1093
1278
  }
1094
1279
  }
1280
+ /**
1281
+ * grubcfg
1282
+ * - open /etc/default/grub
1283
+ * - find GRUB_CMDLINE_LINUX_DEFAULT=
1284
+ * - replace with GRUB_CMDLINE_LINUX_DEFAULT=
1285
+ * 's/GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT=/g'
1286
+ */
1287
+ grubcfg() {
1288
+ let file = `${this.installTarget}/etc/default/grub`;
1289
+ let content = '';
1290
+ const grubs = fs_1.default.readFileSync(file, 'utf-8').split('\n');
1291
+ for (let i = 0; i < grubs.length; i++) {
1292
+ if (grubs[i].includes('GRUB_CMDLINE_LINUX_DEFAULT=')) {
1293
+ if (this.partitions.installationMode === 'full-encrypted') {
1294
+ grubs[i] = `GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=${utils_1.default.uuid(this.devices.swap.name)}"`;
1295
+ }
1296
+ else {
1297
+ grubs[i] = `GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=${utils_1.default.uuid(this.devices.swap.name)}"`;
1298
+ }
1299
+ }
1300
+ content += grubs[i] + '\n';
1301
+ }
1302
+ fs_1.default.writeFileSync(file, content, 'utf-8');
1303
+ }
1304
+ /**
1305
+ * On Ubuntu
1306
+ * /etc/machine-id must exist to be re-created
1307
+ * https://unix.stackexchange.com/questions/402999/is-it-ok-to-change-etc-machine-id
1308
+ */
1309
+ async machineId() {
1310
+ let file = `${this.installTarget}/etc/machine-id`;
1311
+ if (fs_1.default.existsSync(file)) {
1312
+ await (0, utils_2.exec)(`rm ${file}`, this.echo);
1313
+ }
1314
+ await (0, utils_2.exec)(`touch ${file}`);
1315
+ }
1095
1316
  /**
1096
1317
  * only show the result
1097
1318
  */
1098
- finished() {
1319
+ async finished() {
1099
1320
  redraw(react_1.default.createElement(finished_1.default, { installationDevice: this.partitions.installationDevice, hostName: this.users.hostname, userName: this.users.name }));
1100
- require('child_process').spawnSync('read _ ', { shell: true, stdio: [0, 1, 2] });
1321
+ utils_1.default.pressKeyToExit('Press a key to reboot...');
1101
1322
  shx.exec('reboot');
1102
1323
  }
1103
1324
  }
@@ -1115,10 +1336,3 @@ function redraw(elem) {
1115
1336
  shx.exec('clear');
1116
1337
  (0, ink_1.render)(elem, opt);
1117
1338
  }
1118
- /**
1119
- *
1120
- * @param message
1121
- */
1122
- async function checkIt(message) {
1123
- await utils_1.default.customConfirm(message);
1124
- }