penguins-eggs 10.0.27 → 10.0.28

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 (324) hide show
  1. package/.oclif.manifest.json +2 -1463
  2. package/README.md +3 -741
  3. package/manpages/doc/man/eggs.1.gz +0 -0
  4. package/manpages/doc/man/eggs.html +4 -4
  5. package/package.json +3 -3
  6. package/scripts/love +2 -2
  7. package/dist/classes/bleach.d.ts +0 -32
  8. package/dist/classes/bleach.js +0 -136
  9. package/dist/classes/cfs.d.ts +0 -17
  10. package/dist/classes/cfs.js +0 -39
  11. package/dist/classes/cli-autologin.d.ts +0 -52
  12. package/dist/classes/cli-autologin.js +0 -230
  13. package/dist/classes/compressors.d.ts +0 -54
  14. package/dist/classes/compressors.js +0 -109
  15. package/dist/classes/daddy.d.ts +0 -26
  16. package/dist/classes/daddy.js +0 -161
  17. package/dist/classes/distro.d.ts +0 -36
  18. package/dist/classes/distro.js +0 -346
  19. package/dist/classes/families/alpine.d.ts +0 -55
  20. package/dist/classes/families/alpine.js +0 -108
  21. package/dist/classes/families/archlinux.d.ts +0 -61
  22. package/dist/classes/families/archlinux.js +0 -140
  23. package/dist/classes/families/debian.d.ts +0 -65
  24. package/dist/classes/families/debian.js +0 -138
  25. package/dist/classes/families/fedora.d.ts +0 -52
  26. package/dist/classes/families/fedora.js +0 -100
  27. package/dist/classes/families/mockup.d.ts +0 -60
  28. package/dist/classes/families/mockup.js +0 -79
  29. package/dist/classes/families/opensuse.d.ts +0 -52
  30. package/dist/classes/families/opensuse.js +0 -104
  31. package/dist/classes/incubation/branding.d.ts +0 -17
  32. package/dist/classes/incubation/branding.js +0 -89
  33. package/dist/classes/incubation/distros/bionic.d.ts +0 -32
  34. package/dist/classes/incubation/distros/bionic.js +0 -83
  35. package/dist/classes/incubation/distros/buster.d.ts +0 -32
  36. package/dist/classes/incubation/distros/buster.js +0 -85
  37. package/dist/classes/incubation/distros/jessie.d.ts +0 -31
  38. package/dist/classes/incubation/distros/jessie.js +0 -44
  39. package/dist/classes/incubation/distros/noble.d.ts +0 -32
  40. package/dist/classes/incubation/distros/noble.js +0 -85
  41. package/dist/classes/incubation/distros/rolling.d.ts +0 -32
  42. package/dist/classes/incubation/distros/rolling.js +0 -82
  43. package/dist/classes/incubation/fisherman-helper/displaymanager.d.ts +0 -11
  44. package/dist/classes/incubation/fisherman-helper/displaymanager.js +0 -39
  45. package/dist/classes/incubation/fisherman-helper/packages.d.ts +0 -20
  46. package/dist/classes/incubation/fisherman-helper/packages.js +0 -72
  47. package/dist/classes/incubation/fisherman-helper/settings.d.ts +0 -15
  48. package/dist/classes/incubation/fisherman-helper/settings.js +0 -83
  49. package/dist/classes/incubation/fisherman.d.ts +0 -77
  50. package/dist/classes/incubation/fisherman.js +0 -251
  51. package/dist/classes/incubation/incubator.d.ts +0 -40
  52. package/dist/classes/incubation/incubator.js +0 -328
  53. package/dist/classes/incubation/installer.d.ts +0 -13
  54. package/dist/classes/incubation/installer.js +0 -64
  55. package/dist/classes/keyboards.d.ts +0 -50
  56. package/dist/classes/keyboards.js +0 -217
  57. package/dist/classes/locales.d.ts +0 -21
  58. package/dist/classes/locales.js +0 -80
  59. package/dist/classes/n8.d.ts +0 -18
  60. package/dist/classes/n8.js +0 -36
  61. package/dist/classes/network.d.ts +0 -37
  62. package/dist/classes/network.js +0 -98
  63. package/dist/classes/ovary.d.ts +0 -214
  64. package/dist/classes/ovary.js +0 -1879
  65. package/dist/classes/pacman.d.ts +0 -149
  66. package/dist/classes/pacman.js +0 -701
  67. package/dist/classes/pve-live.d.ts +0 -17
  68. package/dist/classes/pve-live.js +0 -52
  69. package/dist/classes/pxe.d.ts +0 -74
  70. package/dist/classes/pxe.js +0 -410
  71. package/dist/classes/settings.d.ts +0 -53
  72. package/dist/classes/settings.js +0 -185
  73. package/dist/classes/sources_list.d.ts +0 -28
  74. package/dist/classes/sources_list.js +0 -89
  75. package/dist/classes/systemctl.d.ts +0 -47
  76. package/dist/classes/systemctl.js +0 -86
  77. package/dist/classes/tailor.d.ts +0 -46
  78. package/dist/classes/tailor.js +0 -539
  79. package/dist/classes/tools.d.ts +0 -30
  80. package/dist/classes/tools.js +0 -54
  81. package/dist/classes/users.d.ts +0 -28
  82. package/dist/classes/users.js +0 -143
  83. package/dist/classes/utils.d.ts +0 -323
  84. package/dist/classes/utils.js +0 -946
  85. package/dist/classes/xdg.d.ts +0 -45
  86. package/dist/classes/xdg.js +0 -329
  87. package/dist/classes/yolk.d.ts +0 -33
  88. package/dist/classes/yolk.js +0 -114
  89. package/dist/commands/adapt.d.ts +0 -17
  90. package/dist/commands/adapt.js +0 -33
  91. package/dist/commands/analyze.d.ts +0 -26
  92. package/dist/commands/analyze.js +0 -95
  93. package/dist/commands/calamares.d.ts +0 -29
  94. package/dist/commands/calamares.js +0 -110
  95. package/dist/commands/config.d.ts +0 -35
  96. package/dist/commands/config.js +0 -192
  97. package/dist/commands/cuckoo.d.ts +0 -16
  98. package/dist/commands/cuckoo.js +0 -62
  99. package/dist/commands/dad.d.ts +0 -20
  100. package/dist/commands/dad.js +0 -46
  101. package/dist/commands/export/deb.d.ts +0 -19
  102. package/dist/commands/export/deb.js +0 -51
  103. package/dist/commands/export/iso.d.ts +0 -19
  104. package/dist/commands/export/iso.js +0 -55
  105. package/dist/commands/install.d.ts +0 -37
  106. package/dist/commands/install.js +0 -92
  107. package/dist/commands/kill.d.ts +0 -24
  108. package/dist/commands/kill.js +0 -50
  109. package/dist/commands/mom.d.ts +0 -16
  110. package/dist/commands/mom.js +0 -30
  111. package/dist/commands/produce.d.ts +0 -34
  112. package/dist/commands/produce.js +0 -199
  113. package/dist/commands/status.d.ts +0 -23
  114. package/dist/commands/status.js +0 -31
  115. package/dist/commands/syncfrom.d.ts +0 -45
  116. package/dist/commands/syncfrom.js +0 -152
  117. package/dist/commands/syncto.d.ts +0 -40
  118. package/dist/commands/syncto.js +0 -175
  119. package/dist/commands/tools/clean.d.ts +0 -18
  120. package/dist/commands/tools/clean.js +0 -37
  121. package/dist/commands/tools/ppa.d.ts +0 -26
  122. package/dist/commands/tools/ppa.js +0 -138
  123. package/dist/commands/tools/skel.d.ts +0 -18
  124. package/dist/commands/tools/skel.js +0 -44
  125. package/dist/commands/tools/stat.d.ts +0 -31
  126. package/dist/commands/tools/stat.js +0 -70
  127. package/dist/commands/tools/yolk.d.ts +0 -24
  128. package/dist/commands/tools/yolk.js +0 -45
  129. package/dist/commands/update.d.ts +0 -47
  130. package/dist/commands/update.js +0 -140
  131. package/dist/commands/wardrobe/get.d.ts +0 -23
  132. package/dist/commands/wardrobe/get.js +0 -52
  133. package/dist/commands/wardrobe/list.d.ts +0 -24
  134. package/dist/commands/wardrobe/list.js +0 -125
  135. package/dist/commands/wardrobe/show.d.ts +0 -25
  136. package/dist/commands/wardrobe/show.js +0 -97
  137. package/dist/commands/wardrobe/wear.d.ts +0 -26
  138. package/dist/commands/wardrobe/wear.js +0 -81
  139. package/dist/components/finished.d.ts +0 -15
  140. package/dist/components/finished.js +0 -55
  141. package/dist/components/information.d.ts +0 -8
  142. package/dist/components/information.js +0 -153
  143. package/dist/components/install.d.ts +0 -15
  144. package/dist/components/install.js +0 -56
  145. package/dist/components/keyboard.d.ts +0 -16
  146. package/dist/components/keyboard.js +0 -54
  147. package/dist/components/location.d.ts +0 -16
  148. package/dist/components/location.js +0 -59
  149. package/dist/components/network.d.ts +0 -19
  150. package/dist/components/network.js +0 -65
  151. package/dist/components/partitions.d.ts +0 -16
  152. package/dist/components/partitions.js +0 -73
  153. package/dist/components/steps.d.ts +0 -13
  154. package/dist/components/steps.js +0 -148
  155. package/dist/components/summary.d.ts +0 -24
  156. package/dist/components/summary.js +0 -82
  157. package/dist/components/title.d.ts +0 -11
  158. package/dist/components/title.js +0 -35
  159. package/dist/components/users.d.ts +0 -24
  160. package/dist/components/users.js +0 -80
  161. package/dist/components/welcome.d.ts +0 -13
  162. package/dist/components/welcome.js +0 -63
  163. package/dist/index.d.ts +0 -8
  164. package/dist/index.js +0 -8
  165. package/dist/interfaces/i-addons.d.ts +0 -13
  166. package/dist/interfaces/i-addons.js +0 -8
  167. package/dist/interfaces/i-analyze.d.ts +0 -17
  168. package/dist/interfaces/i-analyze.js +0 -17
  169. package/dist/interfaces/i-app.d.ts +0 -14
  170. package/dist/interfaces/i-app.js +0 -8
  171. package/dist/interfaces/i-branding.d.ts +0 -36
  172. package/dist/interfaces/i-branding.js +0 -8
  173. package/dist/interfaces/i-calamares-partition.d.ts +0 -18
  174. package/dist/interfaces/i-calamares-partition.js +0 -8
  175. package/dist/interfaces/i-config-tools.d.ts +0 -18
  176. package/dist/interfaces/i-config-tools.js +0 -8
  177. package/dist/interfaces/i-devices.d.ts +0 -20
  178. package/dist/interfaces/i-devices.js +0 -8
  179. package/dist/interfaces/i-distro.d.ts +0 -27
  180. package/dist/interfaces/i-distro.js +0 -8
  181. package/dist/interfaces/i-drive-list.d.ts +0 -33
  182. package/dist/interfaces/i-drive-list.js +0 -8
  183. package/dist/interfaces/i-eggs-config.d.ts +0 -32
  184. package/dist/interfaces/i-eggs-config.js +0 -8
  185. package/dist/interfaces/i-excludes.d.ts +0 -14
  186. package/dist/interfaces/i-excludes.js +0 -8
  187. package/dist/interfaces/i-exec.d.ts +0 -11
  188. package/dist/interfaces/i-exec.js +0 -8
  189. package/dist/interfaces/i-initrd.d.ts +0 -13
  190. package/dist/interfaces/i-initrd.js +0 -8
  191. package/dist/interfaces/i-install.d.ts +0 -16
  192. package/dist/interfaces/i-install.js +0 -8
  193. package/dist/interfaces/i-installer.d.ts +0 -17
  194. package/dist/interfaces/i-installer.js +0 -8
  195. package/dist/interfaces/i-krill-config.d.ts +0 -33
  196. package/dist/interfaces/i-krill-config.js +0 -8
  197. package/dist/interfaces/i-krill.d.ts +0 -42
  198. package/dist/interfaces/i-krill.js +0 -8
  199. package/dist/interfaces/i-materia.d.ts +0 -41
  200. package/dist/interfaces/i-materia.js +0 -8
  201. package/dist/interfaces/i-net.d.ts +0 -16
  202. package/dist/interfaces/i-net.js +0 -8
  203. package/dist/interfaces/i-packages.d.ts +0 -16
  204. package/dist/interfaces/i-packages.js +0 -8
  205. package/dist/interfaces/i-partitions.d.ts +0 -16
  206. package/dist/interfaces/i-partitions.js +0 -8
  207. package/dist/interfaces/i-pxe.d.ts +0 -45
  208. package/dist/interfaces/i-pxe.js +0 -1
  209. package/dist/interfaces/i-remix.d.ts +0 -21
  210. package/dist/interfaces/i-remix.js +0 -8
  211. package/dist/interfaces/i-settings.d.ts +0 -33
  212. package/dist/interfaces/i-settings.js +0 -8
  213. package/dist/interfaces/i-user.d.ts +0 -14
  214. package/dist/interfaces/i-user.js +0 -8
  215. package/dist/interfaces/i-workdir.d.ts +0 -14
  216. package/dist/interfaces/i-workdir.js +0 -8
  217. package/dist/interfaces/i-xkb-model.d.ts +0 -24
  218. package/dist/interfaces/i-xkb-model.js +0 -8
  219. package/dist/interfaces/index.d.ts +0 -25
  220. package/dist/interfaces/index.js +0 -8
  221. package/dist/krill/modules/add-user.d.ts +0 -20
  222. package/dist/krill/modules/add-user.js +0 -50
  223. package/dist/krill/modules/bootloader-config-arch.d.ts +0 -14
  224. package/dist/krill/modules/bootloader-config-arch.js +0 -37
  225. package/dist/krill/modules/bootloader-config-debian.d.ts +0 -10
  226. package/dist/krill/modules/bootloader-config-debian.js +0 -50
  227. package/dist/krill/modules/bootloader-config.d.ts +0 -10
  228. package/dist/krill/modules/bootloader-config.js +0 -16
  229. package/dist/krill/modules/bootloader.d.ts +0 -14
  230. package/dist/krill/modules/bootloader.js +0 -30
  231. package/dist/krill/modules/change-password.d.ts +0 -15
  232. package/dist/krill/modules/change-password.js +0 -18
  233. package/dist/krill/modules/del-live-user.d.ts +0 -14
  234. package/dist/krill/modules/del-live-user.js +0 -38
  235. package/dist/krill/modules/fstab.d.ts +0 -14
  236. package/dist/krill/modules/fstab.js +0 -121
  237. package/dist/krill/modules/grubcfg.d.ts +0 -17
  238. package/dist/krill/modules/grubcfg.js +0 -29
  239. package/dist/krill/modules/hostname.d.ts +0 -13
  240. package/dist/krill/modules/hostname.js +0 -50
  241. package/dist/krill/modules/initramfs-cfg.d.ts +0 -14
  242. package/dist/krill/modules/initramfs-cfg.js +0 -25
  243. package/dist/krill/modules/initramfs.d.ts +0 -13
  244. package/dist/krill/modules/initramfs.js +0 -48
  245. package/dist/krill/modules/locale-cfg.d.ts +0 -10
  246. package/dist/krill/modules/locale-cfg.js +0 -61
  247. package/dist/krill/modules/locale.d.ts +0 -13
  248. package/dist/krill/modules/locale.js +0 -48
  249. package/dist/krill/modules/m-keyboard.d.ts +0 -14
  250. package/dist/krill/modules/m-keyboard.js +0 -79
  251. package/dist/krill/modules/m-timezone.d.ts +0 -14
  252. package/dist/krill/modules/m-timezone.js +0 -22
  253. package/dist/krill/modules/machine-id.d.ts +0 -15
  254. package/dist/krill/modules/machine-id.js +0 -30
  255. package/dist/krill/modules/mkfs.d.ts +0 -13
  256. package/dist/krill/modules/mkfs.js +0 -48
  257. package/dist/krill/modules/mount-fs.d.ts +0 -17
  258. package/dist/krill/modules/mount-fs.js +0 -60
  259. package/dist/krill/modules/mount-vfs.d.ts +0 -17
  260. package/dist/krill/modules/mount-vfs.js +0 -40
  261. package/dist/krill/modules/network-cfg.d.ts +0 -19
  262. package/dist/krill/modules/network-cfg.js +0 -64
  263. package/dist/krill/modules/packages.d.ts +0 -14
  264. package/dist/krill/modules/packages.js +0 -105
  265. package/dist/krill/modules/partition.d.ts +0 -20
  266. package/dist/krill/modules/partition.js +0 -324
  267. package/dist/krill/modules/remove-installer-link.d.ts +0 -13
  268. package/dist/krill/modules/remove-installer-link.js +0 -35
  269. package/dist/krill/modules/umount.d.ts +0 -14
  270. package/dist/krill/modules/umount.js +0 -27
  271. package/dist/krill/modules/unpackfs.d.ts +0 -13
  272. package/dist/krill/modules/unpackfs.js +0 -19
  273. package/dist/krill/prepare.d.ts +0 -78
  274. package/dist/krill/prepare.js +0 -626
  275. package/dist/krill/sequence.d.ts +0 -157
  276. package/dist/krill/sequence.js +0 -665
  277. package/dist/lib/get_address.d.ts +0 -8
  278. package/dist/lib/get_address.js +0 -23
  279. package/dist/lib/get_dns.d.ts +0 -8
  280. package/dist/lib/get_dns.js +0 -23
  281. package/dist/lib/get_domain.d.ts +0 -8
  282. package/dist/lib/get_domain.js +0 -23
  283. package/dist/lib/get_gateway.d.ts +0 -8
  284. package/dist/lib/get_gateway.js +0 -23
  285. package/dist/lib/get_hostname.d.ts +0 -8
  286. package/dist/lib/get_hostname.js +0 -23
  287. package/dist/lib/get_netmask.d.ts +0 -8
  288. package/dist/lib/get_netmask.js +0 -23
  289. package/dist/lib/get_password.d.ts +0 -8
  290. package/dist/lib/get_password.js +0 -36
  291. package/dist/lib/get_userfullname.d.ts +0 -8
  292. package/dist/lib/get_userfullname.js +0 -23
  293. package/dist/lib/get_username.d.ts +0 -8
  294. package/dist/lib/get_username.js +0 -23
  295. package/dist/lib/kill_me_softly.d.ts +0 -11
  296. package/dist/lib/kill_me_softly.js +0 -61
  297. package/dist/lib/select_address_type.d.ts +0 -8
  298. package/dist/lib/select_address_type.js +0 -24
  299. package/dist/lib/select_filesystem_type.d.ts +0 -8
  300. package/dist/lib/select_filesystem_type.js +0 -45
  301. package/dist/lib/select_installation_device.d.ts +0 -8
  302. package/dist/lib/select_installation_device.js +0 -30
  303. package/dist/lib/select_installation_mode.d.ts +0 -8
  304. package/dist/lib/select_installation_mode.js +0 -24
  305. package/dist/lib/select_interface.d.ts +0 -8
  306. package/dist/lib/select_interface.js +0 -24
  307. package/dist/lib/select_keyboard_layout.d.ts +0 -11
  308. package/dist/lib/select_keyboard_layout.js +0 -36
  309. package/dist/lib/select_keyboard_model.d.ts +0 -11
  310. package/dist/lib/select_keyboard_model.js +0 -34
  311. package/dist/lib/select_keyboard_option.d.ts +0 -11
  312. package/dist/lib/select_keyboard_option.js +0 -34
  313. package/dist/lib/select_keyboard_variant.d.ts +0 -11
  314. package/dist/lib/select_keyboard_variant.js +0 -35
  315. package/dist/lib/select_languages.d.ts +0 -8
  316. package/dist/lib/select_languages.js +0 -28
  317. package/dist/lib/select_regions.d.ts +0 -8
  318. package/dist/lib/select_regions.js +0 -24
  319. package/dist/lib/select_user_swap_choice.d.ts +0 -8
  320. package/dist/lib/select_user_swap_choice.js +0 -34
  321. package/dist/lib/select_zones.d.ts +0 -8
  322. package/dist/lib/select_zones.js +0 -518
  323. package/dist/lib/utils.d.ts +0 -34
  324. package/dist/lib/utils.js +0 -79
@@ -1,946 +0,0 @@
1
- /**
2
- * ./src/classes/utils.tsx
3
- * penguins-eggs v.10.0.0 / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import shx from 'shelljs';
9
- import fs from 'fs';
10
- import dns from 'dns';
11
- import path from 'path';
12
- import os from 'os';
13
- import inquirer from 'inquirer';
14
- import { execSync, spawnSync } from 'child_process';
15
- import chalk from 'chalk';
16
- import { Netmask } from 'netmask';
17
- import Distro from './distro.js';
18
- // pjson
19
- import { createRequire } from 'module';
20
- const require = createRequire(import.meta.url);
21
- const pjson = require('../../package.json');
22
- // __dirname
23
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
24
- /**
25
- * Utils: general porpourse utils
26
- * @remarks all the utilities
27
- */
28
- export default class Utils {
29
- /**
30
- * Custom function to sort object keys
31
- * @param obj
32
- * @returns
33
- */
34
- static sortObjectKeys(obj) {
35
- const sorted = {};
36
- Object.keys(obj)
37
- .sort()
38
- .forEach(key => {
39
- sorted[key] = obj[key];
40
- });
41
- return sorted;
42
- }
43
- /**
44
- *
45
- * @param file
46
- * @param search
47
- * @returns value
48
- */
49
- static searchOnFile(file = '', search = '') {
50
- const lines = fs.readFileSync(file, 'utf8').split("\n");
51
- let value = '';
52
- lines.forEach(line => {
53
- line = line.replace(/\s+/g, ' '); // Remove multiple spaces with single space
54
- if (line.includes(search)) {
55
- value = line.substring(line.indexOf('=') + 1);
56
- }
57
- });
58
- value = value.replaceAll('"', ''); // Remove "
59
- return value.trim();
60
- }
61
- /**
62
- * Restituisce il prefisso della iso
63
- * @param distroId
64
- * @param codenameId
65
- */
66
- static snapshotPrefix(distroId, codenameId) {
67
- let result = '';
68
- if (codenameId === 'rolling' || codenameId === '') {
69
- result = 'egg-of_' + distroId.toLowerCase() + '-';
70
- }
71
- else {
72
- result = 'egg-of_' + distroId.toLowerCase() + '-' + codenameId.toLowerCase() + '-';
73
- }
74
- result = result.replace(`/`, '-');
75
- return result;
76
- }
77
- /**
78
- * Controlla se il sistema è avviato con systemd
79
- * funziona anche in MX che utilizza systemd
80
- * ma viene avviato con init
81
- */
82
- static isSystemd() {
83
- const checkFile = '/tmp/checksystemd';
84
- execSync(`cat /proc/1/comm >${checkFile}`);
85
- const isSystemd = fs.readFileSync(checkFile).includes('systemd');
86
- execSync(`rm ${checkFile}`);
87
- return isSystemd;
88
- }
89
- /**
90
- *
91
- * @returns
92
- */
93
- static isOpenRc() {
94
- const checkFile = '/tmp/checkinit';
95
- execSync(`command -v openrc >${checkFile} 2>&1`);
96
- const isOpenrc = fs.readFileSync(checkFile).includes('openrc');
97
- execSync(`rm ${checkFile}`);
98
- return isOpenrc;
99
- }
100
- /**
101
- *
102
- * @returns
103
- */
104
- static isSysvinit() {
105
- const checkFile = '/tmp/checkinit';
106
- execSync(`cat /proc/1/comm >${checkFile}`);
107
- const isSysvinit = fs.readFileSync(checkFile).includes('init');
108
- execSync(`rm ${checkFile}`);
109
- return isSysvinit;
110
- }
111
- /**
112
- * ricava path per vmlinuz
113
- * Normalmente cerca BOOT_IMAGE
114
- * BOOT_IMAGE=/boot/vmlinuz-5.16.0-3-amd64 root=UUID=13768873-d6ba-4ae5-9e14-b5011f5aa31c ro quiet splash resume=UUID=beafb9b4-c429-4e1f-a268-4270b63a14e6
115
- * se non è presente, come nel caso di Franco, cerca initrd e ricostruisce vmlinuz
116
- * ro root=UUID=3dc0f202-8ac8-4686-9316-dddcec060c48 initrd=boot\initrd.img-5.15.0-0.bpo.3-amd64 // Conidi
117
- */
118
- static vmlinuz() {
119
- let distro = new Distro();
120
- let vmlinuz = '';
121
- // find vmlinuz in /proc/cmdline
122
- const cmdline = fs.readFileSync('/proc/cmdline', 'utf8').split(" ");
123
- cmdline.forEach(cmd => {
124
- if (cmd.includes('BOOT_IMAGE')) {
125
- vmlinuz = cmd.substring(cmd.indexOf('=') + 1);
126
- // patch per fedora BOOT_IMAGE=(hd0,gpt2)/vmlinuz-6.9.9-200.fc40.x86_64
127
- if (vmlinuz.includes(")")) {
128
- vmlinuz = cmd.substring(cmd.indexOf(')') + 1);
129
- }
130
- if (!fs.existsSync(vmlinuz)) {
131
- if (fs.existsSync(`/boot/${vmlinuz}`)) {
132
- vmlinuz = `/boot/${vmlinuz}`;
133
- }
134
- }
135
- }
136
- });
137
- // btrfs
138
- if (vmlinuz.indexOf('@') > 0) {
139
- vmlinuz = vmlinuz.substring(vmlinuz.indexOf('@') + 1);
140
- }
141
- /**
142
- * blendOS: BOOT_IMAGE=/vmlinuz-linux
143
- * but =/vmlinuz-linux exists in /boot/
144
- */
145
- if (vmlinuz === '/vmlinuz-linux' || vmlinuz === '/vmlinuz-linux-zen') {
146
- if (fs.existsSync(`/boot${vmlinuz}`)) {
147
- vmlinuz = `/boot${vmlinuz}`;
148
- }
149
- }
150
- if (process.arch === 'arm64') {
151
- const kernelVersion = shx.exec('uname -r', { silent: true }).stdout.trim();
152
- vmlinuz = `/boot/vmlinuz-${kernelVersion}`;
153
- }
154
- /**
155
- * If vmlinuz not found
156
- */
157
- if (vmlinuz === '') {
158
- let version = 'linux';
159
- if (distro.familyId === 'debian') {
160
- cmdline.forEach(cmd => {
161
- if (cmd.includes('initrd.img')) {
162
- version = cmd.substring(cmd.indexOf('initrd.img') + 10);
163
- }
164
- });
165
- }
166
- else if (distro.distroId === 'Manjaro') {
167
- cmdline.forEach(cmd => {
168
- if (cmd.includes('initrd.img')) {
169
- version = cmd.substring(cmd.indexOf('initrd.img') + 10);
170
- }
171
- });
172
- }
173
- vmlinuz = '/boot/vmlinuz-' + version;
174
- }
175
- /**
176
- * if not exists exit
177
- */
178
- if (!fs.existsSync(vmlinuz)) {
179
- console.log(vmlinuz + ' not exists!');
180
- process.exit();
181
- }
182
- return vmlinuz;
183
- }
184
- /**
185
- * ricava path per initrdImg
186
- */
187
- static initrdImg() {
188
- let separator = "-";
189
- const vmlinuz = Utils.vmlinuz();
190
- const path = vmlinuz.substring(0, vmlinuz.lastIndexOf('/')) + '/';
191
- let initrd = 'initrd.img';
192
- let version = 'linux';
193
- let suffix = '';
194
- let distro = new Distro();
195
- if (distro.familyId === 'debian') {
196
- version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
197
- }
198
- else if (distro.familyId === 'archlinux') {
199
- initrd = 'initramfs';
200
- suffix = '.img';
201
- }
202
- else if (distro.familyId === 'alpine') {
203
- initrd = 'initramfs';
204
- separator = '-';
205
- version = 'lts';
206
- suffix = '';
207
- }
208
- if (distro.distroId === 'Manjaro') {
209
- version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
210
- }
211
- initrd = path + initrd + separator + version + suffix;
212
- return initrd;
213
- }
214
- /**
215
- * Occore vedere un modo per creare machine-id dove non esiste
216
- */
217
- static machineId() {
218
- let result = '';
219
- if (fs.existsSync('/etc/machine-id')) {
220
- result = fs.readFileSync('/etc/machine-id', 'utf-8').trim();
221
- }
222
- else if (fs.existsSync('/var/lib/dbus/machine-id')) {
223
- result = fs.readFileSync('/var/lib/dbus/machine-id', 'utf-8').trim();
224
- }
225
- return result;
226
- }
227
- /**
228
- *
229
- * @param msg
230
- */
231
- static warning(msg = '') {
232
- console.log(pjson.shortName + ' >>> ' + chalk.cyanBright(msg) + '.');
233
- }
234
- static error(msg = '') {
235
- console.error(pjson.shortName + ' >>> ' + chalk.bgMagentaBright(chalk.whiteBright(msg)) + '.');
236
- }
237
- /**
238
- * Return the primary user's name
239
- */
240
- static async getPrimaryUser() {
241
- const { execSync } = require('child_process');
242
- let primaryUser = '';
243
- try {
244
- // Attempt to get the user from logname
245
- primaryUser = execSync('/usr/bin/logname 2>/dev/null', { encoding: 'utf-8' }).trim();
246
- }
247
- catch (error) {
248
- // console.log("logname failed, so we continue with other methods")
249
- }
250
- if (primaryUser === 'root') {
251
- primaryUser = '';
252
- }
253
- if (primaryUser === '') {
254
- try {
255
- // Check if doas is installed and get the DOAS_USER
256
- execSync('command -v doas', { stdio: 'ignore' });
257
- primaryUser = execSync('echo $DOAS_USER', { encoding: 'utf-8' }).trim();
258
- }
259
- catch (error) {
260
- // console.log("doas is not installed or DOAS_USER is not set, continue with the next method")
261
- }
262
- }
263
- if (primaryUser === '') {
264
- try {
265
- // Check for the SUDO_USER
266
- primaryUser = execSync('echo $SUDO_USER', { encoding: 'utf-8' }).trim();
267
- }
268
- catch (error) {
269
- // console.log("SUDO_USER is not set, continue with the next method")
270
- }
271
- }
272
- if (primaryUser === '') {
273
- // console.log("Fallback to the USER environment variable")
274
- primaryUser = process.env.USER || '';
275
- }
276
- if (primaryUser === '') {
277
- console.error('Cannot determine the primary user.');
278
- process.exit(1);
279
- }
280
- return primaryUser;
281
- }
282
- /**
283
- * restituisce uuid
284
- * @param device
285
- */
286
- static uuid(device) {
287
- const uuid = shx.exec(`blkid -s UUID -o value ${device}`).stdout.trim();
288
- return uuid;
289
- }
290
- /**
291
- *
292
- * @param date
293
- */
294
- static formatDate(date) {
295
- const d = new Date(date);
296
- let month = String(d.getMonth() + 1);
297
- let day = String(d.getDate());
298
- const year = d.getFullYear();
299
- let hh = String(d.getHours());
300
- let mm = String(d.getMinutes());
301
- if (month.length < 2) {
302
- month = '0' + month;
303
- }
304
- if (day.length < 2) {
305
- day = '0' + day;
306
- }
307
- if (hh.length < 2) {
308
- hh = '0' + hh;
309
- }
310
- if (mm.length < 2) {
311
- mm = '0' + mm;
312
- }
313
- return [year, month, day].join('-') + '_' + hh + mm;
314
- }
315
- /**
316
- * return the name of the package: penguins-eggs
317
- * @returns penguins-eggs
318
- */
319
- static getPackageName() {
320
- return pjson.shortName;
321
- }
322
- /**
323
- * Count the eggs present in the nest
324
- * @returns {number} Numero degli snapshot presenti
325
- */
326
- static getSnapshotCount(snapshot_dir = '/') {
327
- if (fs.existsSync(snapshot_dir)) {
328
- const files = fs.readdirSync(snapshot_dir);
329
- let nIsos = 0;
330
- for (const f of files) {
331
- if (f.endsWith('.iso')) {
332
- nIsos++;
333
- }
334
- }
335
- return nIsos;
336
- }
337
- return 0;
338
- }
339
- /**
340
- * Get the syze of the snapshot
341
- * @returns {string} grandezza dello snapshot in Byte
342
- */
343
- static getSnapshotSize(snapshot_dir = '/') {
344
- let fileSizeInBytes = 0;
345
- const size = shx.exec(`/usr/bin/find ${snapshot_dir} -maxdepth 1 -type f -name '*.iso' -exec du -sc {} + | tail -1 | awk '{print $1}'`, { silent: true }).stdout.trim();
346
- if (size === '') {
347
- fileSizeInBytes = 0;
348
- }
349
- else {
350
- fileSizeInBytes = Number(size);
351
- }
352
- return fileSizeInBytes;
353
- }
354
- /**
355
- * uefiArch
356
- * @returns arch
357
- */
358
- static uefiArch() {
359
- let arch = '';
360
- if (process.arch === 'ia32') {
361
- arch = 'i386';
362
- //
363
- if (shx.exec('uname -m', { silent: true }).stdout.trim() === 'x86_64') {
364
- arch = 'amd64';
365
- }
366
- }
367
- else if (process.arch === 'x64') {
368
- arch = 'amd64';
369
- }
370
- else if (process.arch === 'arm64') {
371
- arch = 'arm64';
372
- }
373
- return arch;
374
- }
375
- /**
376
- * i386-efi,
377
- * x86_64-efi,
378
- * arm64-efi,
379
- */
380
- static uefiFormat() {
381
- let format = '';
382
- if (process.arch === 'ia32') {
383
- format = 'i386-efi';
384
- if (shx.exec('uname -m', { silent: true }).stdout.trim() === 'x86_64') {
385
- format = 'x86_64-efi';
386
- }
387
- }
388
- else if (process.arch === 'x64') {
389
- format = 'x86_64-efi';
390
- }
391
- else if (process.arch === 'arm64') {
392
- format = 'arm64-efi';
393
- }
394
- return format;
395
- }
396
- /**
397
- *
398
- * @returns
399
- */
400
- static uefiBN() {
401
- let bn = 'nothing.efi';
402
- if (process.arch === 'x64') {
403
- bn = 'bootx64.efi';
404
- }
405
- else if (process.arch === 'arm64') {
406
- bn = 'bootaa64.efi';
407
- }
408
- return bn;
409
- }
410
- /**
411
- *
412
- * @returns
413
- */
414
- static usrLibPath() {
415
- let path = '';
416
- if (process.arch === 'x64') {
417
- path = 'x86_64-linux-gnu';
418
- }
419
- else if (process.arch === 'arm64') {
420
- path = 'aarch64-linux-gnu';
421
- }
422
- return path;
423
- }
424
- /**
425
- *
426
- * @param prefix
427
- * @param backup
428
- * @returns
429
- */
430
- static getPrefix(prefix, backup = false) {
431
- if (backup) {
432
- if (prefix.substring(0, 7) === 'egg-of_') {
433
- prefix = 'egg-bk_' + prefix.substring(7);
434
- }
435
- else {
436
- prefix = 'egg-bk_' + prefix;
437
- }
438
- }
439
- return prefix;
440
- }
441
- /**
442
- *
443
- * @param volid
444
- */
445
- static getVolid(volid = 'unknown') {
446
- // // 28 + 4 .iso = 32 lunghezza max di volid
447
- if (volid.length >= 32) {
448
- volid = volid.substring(0, 32);
449
- }
450
- return volid;
451
- }
452
- /**
453
- * Return postfix
454
- * @param basename
455
- * @returns eggName
456
- */
457
- static getPostfix() {
458
- let postfix = '_' + Utils.formatDate(new Date()) + '.iso';
459
- return postfix;
460
- }
461
- /**
462
- * Calculate the space used on the disk
463
- * @return {void}
464
- */
465
- static getUsedSpace() {
466
- let fileSizeInBytes = 0;
467
- if (this.isLive()) {
468
- fileSizeInBytes = 0; // this.getLiveRootSpace()
469
- }
470
- else {
471
- fileSizeInBytes = Number(shx.exec(`df /home | /usr/bin/awk 'NR==2 {print $3}'`, {
472
- silent: true
473
- }).stdout);
474
- }
475
- return fileSizeInBytes;
476
- }
477
- /**
478
- * Extimate the linuxfs dimension
479
- * probably is better to rename it as
480
- * getLiveSpaceRootNeed
481
- * @returns {number} Byte
482
- */
483
- static getLiveRootSpace(type = 'debian-live') {
484
- let squashFs = '/run/live/medium/live/filesystem.squashfs';
485
- if (type === 'mx') {
486
- squashFs = '/live/boot-dev/antiX/linuxfs';
487
- }
488
- // Ottengo la dimensione del file compresso
489
- const compressedFs = fs.statSync(squashFs).size;
490
- // get compression factor by reading the linuxfs squasfs file, if available
491
- const compressedFs_compression_type = shx.exec(`dd if=${compressedFs} bs=1 skip=20 count=2 status=none 2>/dev/null| /usr/bin/od -An -tdI`);
492
- let compression_factor = 0;
493
- if (compressedFs_compression_type === '1') {
494
- compression_factor = 37; // gzip
495
- }
496
- else if (compressedFs_compression_type === '2') {
497
- compression_factor = 52; // lzo, not used by antiX
498
- }
499
- else if (compressedFs_compression_type === '3') {
500
- compression_factor = 52; // lzma, not used by antiX
501
- }
502
- else if (compressedFs_compression_type === '4') {
503
- compression_factor = 31; // xz
504
- }
505
- else if (compressedFs_compression_type === '5') {
506
- compression_factor = 52; // lz4
507
- }
508
- else {
509
- compression_factor = 30; // anything else or linuxfs not reachable (toram), should be pretty conservative
510
- }
511
- let rootfs_file_size = 0;
512
- const linuxfs_file_size = (Number(shx.exec('df /live/linux --output=used --total | /usr/bin/tail -n1').stdout.trim()) * 1024 * 100) / compression_factor;
513
- if (fs.existsSync('/live/persist-root')) {
514
- rootfs_file_size = Number(shx.exec('df /live/persist-root --output=used --total | /usr/bin/tail -n1').stdout.trim()) * 1024;
515
- }
516
- let rootSpaceNeeded;
517
- if (type === 'mx') {
518
- /**
519
- * add rootfs file size to the calculated linuxfs file size. Probaby conservative, as rootfs will likely have some overlap with linuxfs
520
- */
521
- rootSpaceNeeded = linuxfs_file_size + rootfs_file_size;
522
- }
523
- else {
524
- rootSpaceNeeded = linuxfs_file_size;
525
- }
526
- return rootSpaceNeeded / 1073741824.0; // Converte in GB
527
- }
528
- /**
529
- * Return true if i686 architecture
530
- * @remarks to move in Utils
531
- * @returns {boolean} true se l'architettura è i686
532
- */
533
- static isi686() {
534
- return process.arch === 'ia32';
535
- }
536
- /**
537
- * Controlla se è un pacchetto deb
538
- * /usr/lib/penguins-eggs/bin/node
539
- */
540
- static isDebPackage() {
541
- let ret = false;
542
- //if (process.execPath !== '/usr/bin/node') {
543
- if (process.execPath === '/usr/lib/penguins-eggs/bin/node') {
544
- ret = true;
545
- }
546
- return ret;
547
- }
548
- /**
549
- * Controlla se è un pacchetto sorgente
550
- */
551
- static isSources() {
552
- let ret = false;
553
- if (__dirname.substring(0, 6) === '/home/') {
554
- ret = true;
555
- }
556
- return ret;
557
- }
558
- /**
559
- * Controlla se è un pacchetto npm
560
- */
561
- static isNpmPackage() {
562
- return !(this.isDebPackage() || this.isSources());
563
- }
564
- /**
565
- *
566
- */
567
- static rootPenguin() {
568
- return path.resolve(__dirname, '../../');
569
- }
570
- /**
571
- * return the short name of the package: eggs
572
- * @returns eggs
573
- */
574
- static getFriendName() {
575
- return pjson.shortName;
576
- }
577
- /**
578
- * return the version of the package
579
- * @returns version example 8.0.0
580
- */
581
- static getPackageVersion() {
582
- return pjson.version;
583
- }
584
- /**
585
- * Get author name
586
- */
587
- static getAuthorName() {
588
- return 'Piero Proietti piero.proietti@gmail.com';
589
- }
590
- /**
591
- * Return the Debian version
592
- * @returns {number} Versione di Debian
593
- */
594
- static getDebianVersion() {
595
- const cmd = "cat /etc/debian_version | /usr/bin/cut -f1 -d'.'";
596
- const version = Number(shx.exec(cmd, { silent: true }).stdout);
597
- return version;
598
- }
599
- /**
600
- * Return true if live system
601
- * @returns {boolean} isLive
602
- */
603
- static isLive() {
604
- let retVal = false;
605
- const paths = [
606
- '/lib/live/mount', // debian-live
607
- '/lib/live/mount/rootfs/filesystem.squashfs', // ubuntu bionic
608
- '/live/aufs', // mx-linux
609
- '/run/miso/sfs/livefs', // ManjaroLinux
610
- '/run/archiso/airootfs', // Arch
611
- '/media/root-rw' // AlpineLinux
612
- ];
613
- for (let i = 0; i < paths.length; i++) {
614
- if (Utils.isMountpoint(paths[i])) {
615
- retVal = true;
616
- }
617
- }
618
- return retVal;
619
- }
620
- /**
621
- * Ritorna vero se path è un mountpoint
622
- * @param path
623
- */
624
- static isMountpoint(path = '') {
625
- const cmd = `mountpoint -q ${path}`;
626
- // return 0 if the directory is a mountpoint, non-zero if not.
627
- const result = shx.exec(cmd, { silent: true }).code;
628
- return result === 0;
629
- }
630
- /**
631
- *
632
- * @param device
633
- * @returns
634
- */
635
- static isBlockDevice(device = '') {
636
- const cmd = `lsblk -d -o name | grep ${device}`;
637
- const result = shx.exec(cmd, { silent: true }).code;
638
- return result === 0;
639
- }
640
- /**
641
- * return true if eggs run as root
642
- * @returns isRoot
643
- */
644
- static isRoot(command = '') {
645
- if (process.getuid && process.getuid() === 0) {
646
- return true;
647
- }
648
- return false;
649
- }
650
- /**
651
- *
652
- * @param command
653
- */
654
- static useRoot(command = '') {
655
- Utils.titles(pjson.shortName + ' ' + command + ` need to run with root privileges. Please, prefix it with sudo`);
656
- }
657
- /**
658
- * get the kernel version
659
- */
660
- static kernelVersion() {
661
- return os.release();
662
- }
663
- /**
664
- * return the name of network device
665
- */
666
- static async iface() {
667
- // return shx.exec(`ifconfig | awk 'FNR==1 { print $1 }' | tr --d :`, { silent: true }).stdout.trim()
668
- const interfaces = Object.keys(os.networkInterfaces());
669
- let netDeviceName = '';
670
- for (const k in interfaces) {
671
- if (interfaces[k] != 'lo') {
672
- netDeviceName = interfaces[k];
673
- }
674
- }
675
- return netDeviceName;
676
- }
677
- /**
678
- * address
679
- */
680
- static address() {
681
- const interfaces = os.networkInterfaces();
682
- let address = '';
683
- if (interfaces !== undefined) {
684
- for (const devName in interfaces) {
685
- const iface = interfaces[devName];
686
- if (iface !== undefined) {
687
- for (const alias of iface) {
688
- if (alias.family === 'IPv4' &&
689
- alias.address !== '127.0.0.1' &&
690
- !alias.internal) {
691
- // take just the first!
692
- if (address === '') {
693
- address = alias.address;
694
- }
695
- }
696
- }
697
- }
698
- }
699
- }
700
- return address;
701
- }
702
- /**
703
- * netmask
704
- */
705
- static netmask() {
706
- const interfaces = os.networkInterfaces();
707
- let netmask = '';
708
- if (interfaces !== undefined) {
709
- for (const devName in interfaces) {
710
- const iface = interfaces[devName];
711
- if (iface !== undefined) {
712
- for (const alias of iface) {
713
- if (alias.family === 'IPv4' &&
714
- alias.address !== '127.0.0.1' &&
715
- !alias.internal) {
716
- // take just the first!
717
- if (netmask === '') {
718
- netmask = alias.netmask;
719
- }
720
- }
721
- }
722
- }
723
- }
724
- }
725
- return netmask;
726
- }
727
- /**
728
- * cidr
729
- */
730
- static cidr() {
731
- const interfaces = os.networkInterfaces();
732
- let cidr = '';
733
- if (interfaces !== undefined) {
734
- for (const devName in interfaces) {
735
- const iface = interfaces[devName];
736
- if (iface !== undefined) {
737
- for (const alias of iface) {
738
- if (alias.family === 'IPv4' &&
739
- alias.address !== '127.0.0.1' &&
740
- !alias.internal) {
741
- // take just the first!
742
- if (cidr === '') {
743
- if (alias.cidr !== null) {
744
- cidr = alias.cidr;
745
- }
746
- }
747
- }
748
- }
749
- }
750
- }
751
- }
752
- return cidr;
753
- }
754
- /**
755
- *
756
- * broadcast
757
- */
758
- static broadcast() {
759
- let n = new Netmask(Utils.cidr());
760
- return n.broadcast;
761
- }
762
- /**
763
- * dns
764
- */
765
- static getDns() {
766
- return dns.getServers();
767
- }
768
- /**
769
- * getDomain
770
- */
771
- static getDomain() {
772
- return shx.exec('domainname', { silent: true }).stdout.trim();
773
- // return shx.exec(`route -n | grep 'UG[ \t]' | awk '{print $2}'`, { silent: true }).stdout.trim()
774
- }
775
- /**
776
- * @returns gateway
777
- */
778
- static gateway() {
779
- return shx.exec(`ip r | grep 'default' | awk '{print $3}'`, { silent: true }).stdout.trim();
780
- //return shx.exec(`route -n | grep 'UG[ \t]' | awk '{print $2}'`, { silent: true }).stdout.trim()
781
- }
782
- /**
783
- * write a file
784
- * @param file
785
- * @param text
786
- */
787
- static write(file, text) {
788
- text = text.trim() + '\n';
789
- text = text.trim() + '\n';
790
- file = file.trim();
791
- fs.writeFileSync(file, text);
792
- }
793
- /**
794
- *
795
- * @param file
796
- * @param cmd
797
- */
798
- static writeX(file, cmd) {
799
- let text = `#!/bin/sh\n\n`;
800
- text += `# Created at: ${Utils.formatDate(new Date())}\n`;
801
- text += `# By: penguins_eggs v. ${Utils.getPackageVersion()}\n`;
802
- text += `# ==> Perri\'s Brewery edition <== \n\n`;
803
- text += cmd;
804
- Utils.write(file, text);
805
- shx.chmod('+x', file);
806
- }
807
- /**
808
- *
809
- * @param file
810
- * @param cmd
811
- */
812
- static writeXs(file, cmds) {
813
- let cmd = '';
814
- for (const elem of cmds) {
815
- cmd += elem + '\n';
816
- }
817
- Utils.writeX(file, cmd);
818
- }
819
- /**
820
- *
821
- * @param msg
822
- */
823
- static async customConfirm(msg = 'Select yes to continue... ') {
824
- const varResult = await Utils.customConfirmCompanion(msg);
825
- const result = JSON.parse(varResult);
826
- if (result.confirm === 'Yes') {
827
- return true;
828
- }
829
- else {
830
- return false;
831
- }
832
- }
833
- /**
834
- *
835
- * @param msg
836
- */
837
- static async customConfirmCompanion(msg = 'Select yes to continue... ') {
838
- return new Promise(function (resolve) {
839
- const questions = [
840
- {
841
- type: 'list',
842
- name: 'confirm',
843
- message: msg,
844
- choices: ['No', 'Yes'],
845
- default: 'No'
846
- }
847
- ];
848
- inquirer.prompt(questions).then(function (options) {
849
- resolve(JSON.stringify(options));
850
- });
851
- });
852
- }
853
- /**
854
- *
855
- * @param msg
856
- */
857
- static async customConfirmAbort(msg = 'Confirm') {
858
- return new Promise(function (resolve) {
859
- const questions = [
860
- {
861
- type: 'list',
862
- name: 'confirm',
863
- message: msg,
864
- choices: ['No', 'Yes', 'Abort'],
865
- default: 'No'
866
- }
867
- ];
868
- inquirer.prompt(questions).then(function (options) {
869
- resolve(JSON.stringify(options));
870
- });
871
- });
872
- }
873
- /**
874
- *
875
- */
876
- static async pressKeyToExit(warming = 'Process will end', procContinue = true) {
877
- Utils.warning(warming);
878
- let msg = 'Press a key to exit...';
879
- if (procContinue) {
880
- msg = 'Press a key to continue...';
881
- }
882
- console.log(msg);
883
- const pressKeyToExit = spawnSync('read _ ', { shell: true, stdio: [0, 1, 2] });
884
- if (!procContinue) {
885
- process.exit(0);
886
- }
887
- }
888
- /**
889
- * titles
890
- * Penguin's are gettings alive!
891
- */
892
- static titles(command = '') {
893
- console.clear();
894
- console.log('');
895
- console.log(' E G G S: the reproductive system of penguins');
896
- console.log('');
897
- console.log(Utils.flag());
898
- console.log('command: ' + chalk.bgBlack.white(command) + '\n');
899
- }
900
- /**
901
- *
902
- * @returns flag
903
- */
904
- static flag() {
905
- return chalk.bgGreen.whiteBright(' ' + pjson.name + ' ') +
906
- chalk.bgWhite.blue(" Perri's Brewery edition ") +
907
- chalk.bgRed.whiteBright(' ver. ' + pjson.version + ' ');
908
- }
909
- /**
910
- *
911
- * @param verbose
912
- */
913
- static setEcho(verbose = false) {
914
- let echo = { echo: false, ignore: true };
915
- if (verbose) {
916
- echo = { echo: true, ignore: false };
917
- }
918
- return echo;
919
- }
920
- /**
921
- *
922
- * @param bytes
923
- * @param decimals
924
- * @returns
925
- */
926
- static formatBytes(bytes, decimals = 2) {
927
- if (bytes === 0)
928
- return '0 Bytes';
929
- const k = 1024;
930
- const dm = decimals < 0 ? 0 : decimals;
931
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
932
- const i = Math.floor(Math.log(bytes) / Math.log(k));
933
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + sizes[i];
934
- }
935
- /**
936
- *
937
- * @returns wardrobe
938
- */
939
- static async wardrobe() {
940
- let wardrobe = `${os.homedir()}/.wardrobe`;
941
- if (Utils.isRoot()) {
942
- wardrobe = `/home/${await Utils.getPrimaryUser()}/.wardrobe`;
943
- }
944
- return wardrobe;
945
- }
946
- }