penguins-eggs 9.3.22 → 9.3.24

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 (39) hide show
  1. package/.oclif.manifest.json +1 -1
  2. package/README.md +128 -65
  3. package/dist/commands/adapt.js +4 -2
  4. package/dist/commands/analyze.js +2 -2
  5. package/dist/commands/calamares.js +7 -2
  6. package/dist/commands/config.js +6 -3
  7. package/dist/commands/cuckoo.js +4 -6
  8. package/dist/commands/dad.js +6 -1
  9. package/dist/commands/export/deb.js +6 -1
  10. package/dist/commands/export/iso.js +6 -1
  11. package/dist/commands/install.js +6 -2
  12. package/dist/commands/kill.js +4 -2
  13. package/dist/commands/mom.js +5 -2
  14. package/dist/commands/produce.js +7 -8
  15. package/dist/commands/status.js +4 -1
  16. package/dist/commands/syncfrom.js +5 -3
  17. package/dist/commands/syncto.js +5 -3
  18. package/dist/commands/tools/clean.js +4 -2
  19. package/dist/commands/tools/ppa.js +5 -1
  20. package/dist/commands/tools/skel.js +5 -6
  21. package/dist/commands/tools/stat.js +6 -1
  22. package/dist/commands/tools/yolk.js +4 -2
  23. package/dist/commands/update.js +4 -2
  24. package/dist/commands/wardrobe/get.js +6 -2
  25. package/dist/commands/wardrobe/list.js +6 -2
  26. package/dist/commands/wardrobe/show.js +7 -2
  27. package/dist/commands/wardrobe/wear.js +7 -2
  28. package/dist/krill/krill-sequence.js +5 -4
  29. package/dist/krill/modules/locale-cfg.js +2 -1
  30. package/dist/krill/modules/locale.js +1 -1
  31. package/dist/krill/modules/m-keyboard.js +1 -1
  32. package/dist/lib/dependencies.js +7 -6
  33. package/package.json +3 -3
  34. package/scripts/README.md +120 -0
  35. package/scripts/includes/easybashgui +1695 -0
  36. package/scripts/includes/easybashgui.lib +8039 -0
  37. package/scripts/includes/easybashlib +550 -0
  38. package/scripts/mom.sh +246 -0
  39. package/scripts/mom-cli.sh +0 -403
@@ -0,0 +1,550 @@
1
+ # easybashlib - EasyBash Library...
2
+ #
3
+ # For more lib modules and improvement ideas see:
4
+ # http://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/
5
+
6
+
7
+ # To learn how to include easybashlib in your scripts,
8
+ # have a look into easybashgui.
9
+ # It contains instructions on how to load easbashgui as a module,
10
+ # and is at the same time an example of including easybashlib.
11
+
12
+
13
+ # prevent repeated inclusion
14
+ if [ "${eb_incl_easybashlib__imported+defined}" = "defined" ]
15
+ then
16
+ echo "easybashlib: ERR: easybashlib not sourced (already sourced)."
17
+ return 0
18
+ fi
19
+ #
20
+ #echo -e "...easybashlib sourcing..."
21
+ #
22
+ #eb_incl_easybashlib__imported=1
23
+ eb_incl_easybashlib__imported=please_prevent_next_time
24
+
25
+ #
26
+ ###################
27
+ # Debugging stuff #
28
+ ###################
29
+ #
30
+
31
+
32
+ # Bash debugging:
33
+ : we_are_here
34
+ [ $(declare | grep "BASH_SOURCE=" | wc -c ) -eq 0 ] && declare BASH_SOURCE ; \
35
+ [ "${BASH_SOURCE:-unset}" = "unset" ] && declare -r BASH_SOURCE="${eb_runtime_invoke_name}"
36
+ [ $(declare | grep "LINENO=" | wc -c ) -eq 0 ] && declare LINENO ; \
37
+ [ "${LINENO:-unset}" = "unset" ] && declare -ir LINENO="0"
38
+ [ $(declare | grep "FUNCNAME=" | wc -c ) -eq 0 ] && declare FUNCNAME ; \
39
+ [ "${FUNCNAME:-unset}" = "unset" ] && declare -r FUNCNAME="unknown_function"
40
+ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
41
+
42
+ #set -o verbose -o xtrace
43
+ [ "${BASHPID:-unset}" = "unset" ] && declare -ir BASHPID="${PPID}"
44
+
45
+
46
+
47
+ #
48
+ ##########################################à
49
+ #
50
+ if [ "${easybashgui_debug_mode}" = "YES" ]
51
+ then
52
+ # enable some sane default checks to make bash scripts more robust
53
+ # http://www.davidpashley.com/articles/writing-robust-shell-scripts.html
54
+ echo "easybashgui_debug_mode ON" ; echo
55
+ set -o nounset -o errexit
56
+ shopt -s extdebug
57
+ #
58
+ elif [ "${easybashgui_debug_mode}" = "NO" ]
59
+ then
60
+ #
61
+ #echo "easybashgui_debug_mode OFF"
62
+ set +o nounset +o errexit
63
+ shopt -u extdebug
64
+ #
65
+ else
66
+ #
67
+ echo "easybashgui_debug_mode UNSET"
68
+ :
69
+ #
70
+ fi
71
+ ##########################################à
72
+
73
+ # Note that a lot of code out there (e.g. easybashgui) gives errors if run with the checks enabled,
74
+ # and has thus a high potetial to do unexpected things on errors.
75
+ # The following function allows to executes such code without the checks (but you have been warned):
76
+ eb_skip_exit_on_err_or_unset()
77
+ {
78
+ set +o nounset +o errexit
79
+ shopt -u extdebug
80
+ #echo "easybashgui_debug_mode OFF"
81
+ "$@"
82
+ exit_code=$?
83
+ #
84
+ ##########################################
85
+ #
86
+ if [ "${easybashgui_debug_mode}" = "YES" ]
87
+ then
88
+ # enable some sane default checks to make bash scripts more robust
89
+ # http://www.davidpashley.com/articles/writing-robust-shell-scripts.html
90
+ echo "easybashgui_debug_mode ON" ; echo
91
+ set -o nounset -o errexit
92
+ shopt -s extdebug
93
+ #
94
+ elif [ "${easybashgui_debug_mode}" = "NO" ]
95
+ then
96
+ #
97
+ #echo "easybashgui_debug_mode OFF"
98
+ set +o nounset +o errexit
99
+ shopt -u extdebug
100
+ #
101
+ else
102
+ #
103
+ echo "easybashgui_debug_mode UNSET"
104
+ :
105
+ #
106
+ fi
107
+ ##########################################à
108
+ #
109
+ return $exit_code
110
+ }
111
+
112
+
113
+ # Hint to write code that runns with the checks enabled:
114
+ # Catch error codes by using "if <command>; then..." statements,
115
+ # or "<command> || true" (if you really don't need to act on any error),
116
+ # and catch (dynamically set) unset variables like this: "${variablename:-unset}".
117
+
118
+
119
+
120
+ # Configuring eb_debug_action=1 will not enable debug output during initialization
121
+ # (before load_base_config has run), however executing "export eb_debug_action=1"
122
+ # prior to starting sucsynct will do it.
123
+ #eb_debug_action="1"
124
+
125
+
126
+
127
+ # commands preceeded by eb_debug_action should only execute with the debug-flag set or eb_debug_action=1
128
+ function eb_debug_action() {
129
+ if [ -s "${eb_state_dir:-}/debug-flag" ] \
130
+ || [ ! -e "${eb_state_dir:-}/debug-flag" -a "${eb_debug_action:-0}" = "1" ]
131
+ then
132
+ $@ || true # || true, so the return code is always 0
133
+ fi
134
+ }
135
+
136
+
137
+ function eb_debug() {
138
+ if [ -s "${eb_state_dir:-}/debug-flag" ] \
139
+ || [ ! -e "${eb_state_dir:-}/debug-flag" -a "${eb_debug_action:-0}" = "1" ]
140
+ then
141
+ return 0
142
+ else
143
+ return 1
144
+ fi
145
+ }
146
+
147
+ function eb_debug_output()
148
+ {
149
+ eb_debug_action echo -e "${eb_process_scope:-$eb_runtime_invoke_name} (S$$-P$BASHPID): $@"
150
+ }
151
+
152
+
153
+ function eb_stop_debug()
154
+ {
155
+ eb_debug_output "Disabling debug output."
156
+ echo -n "" > "${eb_state_dir}/debug-flag"
157
+ }
158
+
159
+ function eb_start_debug()
160
+ {
161
+ echo -n "set (non-empty) at runtime" > "${eb_state_dir}/debug-flag"
162
+ eb_debug_output "Debug output enabled."
163
+ }
164
+
165
+
166
+
167
+ function eb_error_output()
168
+ {
169
+ echo -e "${eb_process_scope:-$eb_runtime_invoke_name} (S$$-P$BASHPID): $@" 1>&2
170
+ }
171
+
172
+
173
+
174
+
175
+ #####################
176
+ # Process managment #
177
+ #####################
178
+
179
+
180
+ function eb_kill_process_tree_of_pid() {
181
+ # Grows a process tree that can kill an existing process tree beginning with
182
+ # the given PID as parent.
183
+ # (Spawning a killtree allows to avoid to kill 0 (the process group) that may even kill parent and sibling processes.)
184
+ # Basic idea on http://stackoverflow.com/questions/392022/best-way-to-kill-all-child-processes
185
+
186
+ # To support decending the process tree, the calling script must call this function if
187
+ # the script is executed as: $0 killtree ${this_descendant_pid} ${kill_signal}
188
+
189
+ local target_pid=$1
190
+ local kill_signal=${2-TERM}
191
+ local this_descendant_pid
192
+ local this_descendant_pname
193
+
194
+ local descendant_pids=$(ps -o pid --no-headers --ppid ${target_pid})
195
+
196
+ #echo "$BASHPID: descendant_pids=${descendant_pids:-}"
197
+ # newline separated!
198
+
199
+ # Kill the target process right away (may even be the calling process),
200
+ # to prevent it from spawning new processes.
201
+ #echo "$BASHPID: killing target ${target_pid}"
202
+ kill -${kill_signal} ${target_pid} || true
203
+ eb_debug_output "Signaled ${kill_signal} to ${target_pid}."
204
+
205
+
206
+ # call a killtree for each child process (except self and other killtree processes)
207
+ for this_descendant_pid in ${descendant_pids:-}
208
+ do
209
+ #echo "$BASHPID: -${this_descendant_pid}-"
210
+ if [ -e /proc/${this_descendant_pid} ]
211
+ then
212
+ this_descendant_pname="$(</proc/${this_descendant_pid}/cmdline)"
213
+ else
214
+ this_descendant_pname="maybe killed by another killtree"
215
+ fi
216
+ #if [ "${this_descendant_pid}" != "$BASHPID" ] &&
217
+ if [[ "${this_descendant_pname}" != *killtree* ]]
218
+ then
219
+ #echo "$BASHPID: calling killtree ${this_descendant_pid}"
220
+ eb_debug_output "Spawning ${kill_signal} killtree for ${this_descendant_pid}."
221
+ $0 killtree ${this_descendant_pid} ${kill_signal}
222
+ #eb_kill_process_tree_of_pid ${this_descendant_pid} ${kill_signal}
223
+
224
+ else
225
+ true
226
+ #echo "$BASHPID: not killing ${this_descendant_pid} ${this_descendant_pname}"
227
+ fi
228
+ done
229
+
230
+ }
231
+
232
+
233
+
234
+
235
+ # Define a mechanism for automatic clean up on exit, based upon the idea
236
+ # http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files
237
+ #
238
+ #declare -a eb_on_exit_commands #UNUSEFUL since causes "unbound variable" because array is set ONLY if at least element exists...
239
+ #ebg_on_exit_commands=( "echo -en \"\nEBG v.${MODULE_VERSION} exiting... \" 1>&2" )
240
+ ebg_on_exit_commands=( ":" )
241
+ #echo "1) How many elements in array \${ebg_on_exit_commands[@]}: ${#ebg_on_exit_commands[@]} .........DEBUG" 1>&2
242
+
243
+ ebg_on_exit()
244
+ {
245
+ # evaluate ebg_on_exit_commands() in reverse order of registration ...
246
+ #
247
+ #echo "3) How many elements in array \${ebg_on_exit_commands[@]}: ${#ebg_on_exit_commands[*]} .........DEBUG" 1>&2
248
+ for (( i = $(( ${#ebg_on_exit_commands[@]} - 1 )) ; i > -1; i-- ))
249
+ do
250
+ #echo "ebg_on_exit $i: ${ebg_on_exit_commands[${i}]} .........DEBUG" 1>&2
251
+ eb_debug_output "ebg_on_exit ${i}: ${ebg_on_exit_commands[${i}]}"
252
+ eval "${ebg_on_exit_commands[${i}]}"
253
+ done
254
+ #
255
+ #echo -e "Bye!" 1>&2
256
+ #
257
+ # Hint: Scripts that fork should start with "ebg_on_exit $0 killtree $BASHPID", to clean up child
258
+ # processes. (Also remember to kill all disowned processes if appropriate.)
259
+ #
260
+ #echo "Exiting. .........DEBUG" 1>&2
261
+ eb_debug_output "Exiting."
262
+ #
263
+ exit
264
+ }
265
+
266
+ ebg_add_on_exit()
267
+ {
268
+ #
269
+ #echo "2) How many elements in array \${ebg_on_exit_commands[@]}: ${#ebg_on_exit_commands[@]} .........DEBUG" 1>&2
270
+ #
271
+ local n=${#ebg_on_exit_commands[@]}
272
+ #
273
+ #echo "ebg_on_exit: ${ebg_on_exit_commands[$n]} .........DEBUG" 1>&2
274
+ eb_debug_output "ebg_on_exit: ${ebg_on_exit_commands[${n}]}"
275
+ #
276
+ if [[ ${n} -eq 1 ]]
277
+ then
278
+ #echo "Setting ebg_on_exit trap. .........DEBUG" 1>&2
279
+ eb_debug_output "Setting ebg_on_exit trap."
280
+ trap ebg_on_exit EXIT
281
+ fi
282
+ #
283
+ ebg_on_exit_commands[${n}]="$*"
284
+ #
285
+ }
286
+
287
+
288
+
289
+
290
+
291
+
292
+ ###############
293
+ # Directories #
294
+ ###############
295
+
296
+
297
+ # determine eb_conf_dir
298
+ if [ "${USERPROFILE:-undefined}" = undefined ]
299
+ then
300
+ if [ "${HOME:-undefined}" = undefined ]
301
+ then
302
+ eb_conf_basedir="c:/.config"
303
+ else
304
+ if [ "${XDG_DATA_HOME:-undefined}" = undefined ]
305
+ then
306
+ eb_conf_basedir="${HOME}/.config"
307
+ else
308
+ eb_conf_basedir="${XDG_DATA_HOME}"
309
+ fi
310
+ fi
311
+ else
312
+ eb_conf_basedir="${USERPROFILE}/.config}"
313
+ fi
314
+ eb_conf_dir="${eb_conf_basedir}/${eb_runtime_invoke_name}"
315
+ eb_debug_output "eb_conf_dir is set to $eb_conf_dir"
316
+
317
+
318
+
319
+ # determine eb_log_dir
320
+ if [[ "$EUID" -ne 0 ]]
321
+ then
322
+ if [ "${USERPROFILE:-undefined}" = undefined ]
323
+ then
324
+ if [ "${HOME:-undefined}" = undefined ]
325
+ then
326
+ eb_log_basedir="c:/var/log"
327
+ else
328
+ eb_log_basedir="${HOME}/.local/var/log"
329
+ fi
330
+ else
331
+ eb_log_basedir="${USERPROFILE}/.local/var/log"
332
+ fi
333
+ else
334
+ eb_log_basedir=/var/log
335
+ fi
336
+ eb_log_dir="${eb_log_basedir}/${eb_runtime_invoke_name}"
337
+ eb_debug_output "eb_log_dir is set to $eb_log_dir"
338
+
339
+
340
+
341
+
342
+ # determine eb_persistence_dir
343
+ if [ "${USERPROFILE:-undefined}" = undefined ]
344
+ then
345
+ if [ "${HOME:-undefined}" = undefined ]
346
+ then
347
+ eb_persistence_basedir="c:/var/log"
348
+ else
349
+ eb_persistence_basedir="${HOME}/.local/var"
350
+ fi
351
+ else
352
+ eb_persistence_basedir="${USERPROFILE}/.local/var"
353
+ fi
354
+ eb_persistence_dir="${eb_persistence_basedir}/${eb_runtime_invoke_name}"
355
+ eb_debug_output "eb_persistence_dir is set to $eb_persistence_dir"
356
+
357
+
358
+
359
+
360
+ # determine eb_state_dir
361
+ [ -e "/dev/shm" ] && export eb_state_basedir=/dev/shm || export eb_state_basedir=/tmp #This is for old *BSD systems without /dev/shm...
362
+
363
+ function eb_get_state_dir()
364
+ {
365
+ local process_name="${1:-${eb_runtime_invoke_name}}"
366
+ local -a files
367
+ local candidate_file
368
+ local file_count=0
369
+ local old_IFS
370
+
371
+ # enumerate all directories with the right name and permissions in $files array
372
+ old_IFS=$IFS
373
+ #
374
+ find ${eb_state_basedir}/${process_name}-${USER}.* -maxdepth 0 -perm 0700 -user $USER -type d -print0 2>/dev/null \
375
+ | while IFS= read -r -d '' candidate_file
376
+ do
377
+ files[file_count++]="$candidate_file"
378
+ done
379
+ IFS=$old_IFS
380
+
381
+ # if we found matching directories, use the first one
382
+ if [ "${#files[@]}" -gt 0 ]
383
+ then
384
+ echo -n "${files[0]}"
385
+ fi
386
+ }
387
+
388
+
389
+ function eb_set_state_dir()
390
+ {
391
+ # if emptied, we still need to identify the state dir (again)
392
+ if [ "${eb_state_dir:-undefined}" = "undefined" ] || [ "${eb_state_dir}" = "" ]
393
+ then
394
+
395
+ # Because $eb_state_dir is a simple string, we are able to export it here to make it available
396
+ # in subshells.
397
+ export eb_state_dir
398
+ eb_state_dir="$(eb_get_state_dir)"
399
+
400
+ # if nothing was found, create new eb_state_dir
401
+ if [ "${eb_state_dir}" = "" ]
402
+ then
403
+ if [ -e "/dev/shm" ] #This is for old *BSD systems without /dev/shm...
404
+ then
405
+ #eb_state_dir=$( mktemp --tmpdir=/dev/shm -d ${eb_runtime_invoke_name}-${USER}.XXXXXXX )
406
+ eb_state_dir=$(cd /dev/shm ; mktemp -d ${eb_runtime_invoke_name}-${USER}.XXXXXXX ; cd - )
407
+ else
408
+ eb_state_dir=$(cd /tmp ; mktemp -d ${eb_runtime_invoke_name}-${USER}.XXXXXXX ; cd - )
409
+ fi
410
+ # TODO: call function that only removes eb_state_dir if quiting all (not if just closing admin-ui)
411
+ #eb_add_on_exit "rm -rf $eb_state_dir"
412
+ fi
413
+ fi
414
+ eb_debug_output "eb_state_dir is set to $eb_state_dir"
415
+ }
416
+
417
+
418
+
419
+ if [ "${eb_state_dir:-undefined}" = "undefined" ]
420
+ then
421
+ eb_set_state_dir
422
+ fi
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+ ##########
431
+ # Checks #
432
+ ##########
433
+
434
+
435
+ function eb_gen_check_code()
436
+ # Generates code to check the tests given as parameters (all tests if none was specified).
437
+ # Usefull to run selections of tests in context as needed.
438
+ # The code lists testing results and exits with appropriate error code.
439
+ {
440
+
441
+ # echoing the requested code to stdout
442
+
443
+ # declaring vars
444
+ # remote (busybox) may not support associative arrays
445
+ echo "#generated checking code:"
446
+ echo "declare error_code=0"
447
+ echo "declare -a check_names"
448
+ echo "declare -a check_commands"
449
+ echo "declare -a check_reasons"
450
+
451
+ # populating array
452
+ if [ "$#" = "0" ]
453
+ then
454
+ for this_test in "${!eb_test_commands[@]}"
455
+ do
456
+ echo -e "check_names+=( \"${this_test}\" )"
457
+ echo -e "check_commands+=( \"${eb_test_commands[$this_test]}\" )"
458
+ echo -e "check_reasons+=( \"${eb_test_reasons[$this_test]}\" )"
459
+ done
460
+ else
461
+ for this_test in "$@"
462
+ do
463
+ echo -e "check_names+=( \"${this_test}\" )"
464
+ echo -e "check_commands+=( \"${eb_test_commands[$this_test]}\" )"
465
+ echo -e "check_reasons+=( \"${eb_test_reasons[$this_test]}\" )"
466
+ done
467
+ fi
468
+
469
+ # giving context
470
+ echo "echo -e \"Dependency checking results from host: \$HOSTNAME\""
471
+
472
+ # loop over specified checks
473
+ cat << "_____checking_loop____END"
474
+ for this_check in "${!check_names[@]}"
475
+ do
476
+ echo -e "\nChecking for ${check_names[$this_check]}:"
477
+ if eval ${check_commands[$this_check]} 2>&1
478
+ then
479
+ echo -e "\n\t Passed.\n"
480
+ else
481
+ echo -e "\n\t FAILED! (${check_reasons[$this_check]})\n"
482
+ error_code=1
483
+ fi
484
+ done
485
+ _____checking_loop____END
486
+
487
+
488
+ # if a check failed, exit with error, else exit cleanly
489
+ echo "[ \"\$error_code\" = \"1\" ] && exit 1"
490
+ echo "exit 0"
491
+ }
492
+
493
+
494
+
495
+ function eb_check_local()
496
+ {
497
+ eb_gen_check_code "$@" | bash
498
+ return $?
499
+ }
500
+
501
+
502
+
503
+
504
+
505
+ ##############################################################
506
+ # Shared key-value paist in current state or persistent maps #
507
+ ##############################################################
508
+ # In contrast to associative arrays that can not be exported,
509
+ # these maps can be shared between processes and instances.
510
+
511
+
512
+ # Example uses:
513
+ # eb_map put persistent "FavoriteSportOf" "Adam" "tennis"
514
+ # blocked_activity=$(eb_map get state "ActivityOf" "Adam")
515
+
516
+
517
+ eb_map() {
518
+ #parameters: action, storage_type, key, value, process_name
519
+
520
+ [ "${#}" -lt 2 ] && exit 1
521
+ local action="${1}"
522
+ local storage_type="${2}"
523
+ local mapname="${3}"
524
+ local key="${4}"
525
+ local value="${5}"
526
+ local process_name="${6:-${eb_runtime_invoke_name}}"
527
+ local mapdir
528
+
529
+ if [ "${storage_type}" = "persistent" ]
530
+ then
531
+ mapdir="${eb_persistence_basedir}/${process_name}/eb_key-value-maps"
532
+ else
533
+ mapdir="$(eb_get_state_dir ${process_name})/eb_key-value-maps"
534
+ fi
535
+
536
+ if [ "${action}" = "put" ]
537
+ then
538
+ [ -d "${mapdir}/${mapname}" ] || mkdir -p "${mapdir}/${mapname}"
539
+ echo $value >"${mapdir}/${mapname}/${key}"
540
+ elif [ "${action}" = "get" ]
541
+ then
542
+ cat "${mapdir}/${mapname}/${key}"
543
+ fi
544
+ }
545
+
546
+
547
+ return
548
+
549
+
550
+