@dotpi/tools 1.4.0 → 2.3.2

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 (151) hide show
  1. package/NOTES.md +41 -1
  2. package/README.md +3 -13
  3. package/dotpi_root/bin/dotpi +1 -0
  4. package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
  5. package/dotpi_root/bin/dotpi_prepare_system +108 -68
  6. package/dotpi_root/bin/package.json +6 -0
  7. package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
  8. package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
  9. package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
  10. package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
  11. package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
  12. package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
  13. package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
  14. package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
  15. package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
  16. package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
  17. package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
  18. package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
  19. package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
  20. package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
  21. package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
  22. package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
  23. package/dotpi_root/dist/@dotpi/module/package.json +22 -0
  24. package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
  25. package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
  26. package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
  27. package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
  28. package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
  29. package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
  30. package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
  31. package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
  32. package/dotpi_root/etc/dotpi_modules.json +8 -0
  33. package/dotpi_root/lib/package.json +6 -0
  34. package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
  35. package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
  36. package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
  37. package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
  38. package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
  39. package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
  40. package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
  41. package/dotpi_root/share/dotpi_functions.bash +4 -4
  42. package/dotpi_root/share/dotpi_init.bash +7 -1
  43. package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +7 -6
  44. package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -1
  45. package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
  46. package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
  47. package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
  48. package/lerna.json +4 -0
  49. package/package.json +12 -2
  50. package/projects/led-test/.dotpi +3 -0
  51. package/projects/led-test/README.md +16 -0
  52. package/projects/led-test/dotpi_project.bash +29 -0
  53. package/projects/qsddsqsd/.dotpi +3 -0
  54. package/projects/qsddsqsd/README.md +16 -0
  55. package/projects/qsddsqsd/dotpi_project.bash +29 -0
  56. package/src/constants.js +4 -4
  57. package/src/create-project.js +124 -56
  58. package/src/templates/dotpi_project.bash +5 -7
  59. package/src/utils.js +2 -2
  60. package/test/create-project.test.js +0 -1
  61. package/PIPEWIRE.md +0 -280
  62. package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +0 -149
  63. package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +0 -177
  64. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +0 -425
  65. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +0 -620
  66. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +0 -82
  67. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +0 -100
  68. package/dotpi_root/bin/.editorbackup/dotpi~ +0 -61
  69. package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +0 -252
  70. package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +0 -49
  71. package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  72. package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +0 -33
  73. package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +0 -4
  74. package/dotpi_root/share/.editorbackup/coucou~ +0 -1
  75. package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +0 -9
  76. package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +0 -11
  77. package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +0 -420
  78. package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +0 -358
  79. package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +0 -18
  80. package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +0 -15
  81. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +0 -24
  82. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +0 -80
  83. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +0 -26
  84. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +0 -30
  85. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +0 -21
  86. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +0 -256
  87. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +0 -287
  88. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +0 -7
  89. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +0 -428
  90. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +0 -194
  91. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +0 -26
  92. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +0 -287
  93. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +0 -12
  94. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +0 -158
  95. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +0 -152
  96. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +0 -20
  97. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +0 -17
  98. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +0 -20
  99. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +0 -16
  100. package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +0 -5
  101. package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +0 -15
  102. package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +0 -5
  103. package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +0 -23
  104. package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
  105. package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
  106. package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
  107. package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
  108. package/dotpi_root/share/jackd/jackd.service +0 -22
  109. package/dotpi_root/share/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +0 -1
  110. package/projects/old/dev.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  111. package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +0 -33
  112. package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  113. package/projects/old/dev.bak/dotpi_environment_instance.bash +0 -1
  114. package/projects/old/dev.bak/dotpi_environment_project.bash +0 -46
  115. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  116. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +0 -24
  117. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  118. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +0 -22
  119. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +0 -23
  120. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +0 -23
  121. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +0 -23
  122. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +0 -24
  123. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +0 -24
  124. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +0 -23
  125. package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  126. package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +0 -24
  127. package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  128. package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +0 -22
  129. package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +0 -23
  130. package/projects/old/dev.bak/network/AccueilCie.nmconnection +0 -24
  131. package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +0 -23
  132. package/projects/old/dev.bak/network/DOTPI.nmconnection +0 -23
  133. package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +0 -25
  134. package/projects/old/dev.bak/network/onze.nmconnection +0 -24
  135. package/projects/old/dev.bak/network/welcome.nmconnection +0 -23
  136. package/projects/old/dev.bak/network/wifi-access-point.nmconnection +0 -23
  137. package/projects/old/dev.bak/network/wifi-internet.nmconnection +0 -24
  138. package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +0 -24
  139. package/projects/old/dev.bak/network/wifi-local.nmconnection +0 -22
  140. package/projects/old/dev.bak/network/wifi-welcome.nmconnection +0 -24
  141. package/projects/old/dev.bak/wpa_supplicant.conf +0 -43
  142. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  143. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +0 -26
  144. package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +0 -21
  145. package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +0 -3
  146. package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  147. package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +0 -21
  148. package/projects/old/example-complete.bak/configuration/dotpi_project.bash +0 -21
  149. package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +0 -14
  150. package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +0 -14
  151. /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
package/NOTES.md CHANGED
@@ -33,6 +33,47 @@
33
33
  - [x] rename to `@dotpi/tools` rather than `@dotpi/install`
34
34
  - [x] make it work using `npx`
35
35
 
36
+ ### Modules
37
+
38
+ #### support apt dependencies
39
+
40
+ - [ ] add `aptDependecies` to `package.json`
41
+ - [ ] generate `<package>/DEBIAN/control` file from `package.json`
42
+
43
+ ```
44
+ Package: ${package.name.replace(/@/, '').toLowerCase().replace(/[^a-z0-9.+-]/, '-')
45
+ }
46
+ Description: ${package.description}
47
+ Version: ${package.version || '0.0.0'}
48
+ Maintainer: ${package.maintainer || 'nobody <no@mail.com>'}
49
+ Section: embedded
50
+ Priority: optional
51
+ Architecture: all
52
+ Standards-Version: 11.0.0
53
+ Depends: ${package.aptDependencies}
54
+ ```
55
+
56
+ - [ ] `dotpi_install`:
57
+ - [ ] `sudo dotpi module install apt-packages`
58
+ - [ ] generate debian package and install
59
+
60
+ ```sh
61
+ sudo dpkg-deb --root-owner-group --build <package>
62
+ sudo chmod a+rw <package>
63
+ sudo cp <package> /tmp
64
+ sudo dotpi apt-get install /tmp/<package>
65
+ ```
66
+
67
+ - [ ] `dotpi_uninstall`:
68
+ - [ ]`sudo dotpi module uninstall apt-packages`
69
+ - [ ] uninstall debian package
70
+
71
+ ```sh
72
+ sudo apt-get uninstall <package>
73
+ sudo dotpi apt-get autoremove
74
+
75
+ ```
76
+
36
77
  ## Questions
37
78
 
38
79
  - [ ] add a level of indirection in config files?
@@ -40,7 +81,6 @@
40
81
  - [ ] system to check for new version
41
82
  + `npm view @soundworks/core version`
42
83
 
43
-
44
84
  ## Final File Structure
45
85
 
46
86
  ```sh
package/README.md CHANGED
@@ -320,22 +320,12 @@ Please do report them.
320
320
 
321
321
  ## Todo
322
322
 
323
- - [x] option not to install dotpi-manager
324
-
325
323
  - [ ] allow to use configuration files from project
326
- - [ ] jack
327
324
  - [ ] dotpi-led
328
325
 
329
- - [ ] dotpi-manager: dependency to jackd should be soft
326
+ - [ ] dotpi-manager: dependency to audio should be soft
330
327
  - [ ] allow client to run without audio
331
328
  - [ ] client should continue to run if audio stops
332
329
 
333
- - [ ] Make a command-line interface
334
- - [ ] choose between options
335
- - [ ] project name
336
- - [ ] audio device model
337
- - [ ] jackd configuration
338
- - [ ] make pair of ssh keys
339
- - [ ] wifi/network configuration
340
-
341
- - [ ] share dotpi_manager_update w/ install
330
+ - [ ] @dotpi/audio module
331
+ - [ ] generate
@@ -64,3 +64,4 @@ fi
64
64
 
65
65
 
66
66
  "dotpi_${sub_command}" "${@:2}"
67
+ exit $?
@@ -140,6 +140,9 @@ if [[ "$(uname)" == "Darwin" ]] ; then
140
140
  fi
141
141
  tar_options+=( '--no-xattrs' )
142
142
 
143
+ # no locally installed node_modules
144
+ tar_options+=( '--exclude' 'node_modules' )
145
+
143
146
  #### copy defaults from dotpi_root
144
147
 
145
148
  source_path="$DOTPI_ROOT"
@@ -152,6 +155,20 @@ mkdir -p -- "$destination_path"
152
155
  exit 1
153
156
  }
154
157
 
158
+ ### copy local over-rides of file-system
159
+
160
+ source_path="${project_path}/dotpi_filesystem"
161
+ if [[ -d "$source_path" ]] && [[ -r "$source_path" ]] ; then
162
+ destination_path="${file_system_mirror}/opt/dotpi"
163
+ mkdir -p -- "$destination_path"
164
+ (set -o pipefail ; \
165
+ cd -- "$source_path" && tar c "${tar_options[@]}" '.' \
166
+ | tar x -C "$destination_path") || {
167
+ dotpi_echo_error "Error while copying file-system over-rides from ${source_path} to ${destination_path}"
168
+ exit 1
169
+ }
170
+ fi
171
+
155
172
  #### copy project configuration
156
173
 
157
174
  source_path="$project_path"
@@ -275,7 +292,7 @@ destination_path="${DOTPI_ROOT}/etc/ssh"
275
292
  mkdir -p -- "$destination_path"
276
293
  if [ -d "$source_path" ] && [ -r "$source_path" ] ; then
277
294
  (set -o pipefail ; \
278
- cd -- "$source_path" && tar c "${tar_options[@]}" *.pub \
295
+ cd -- "$source_path" && tar c "${tar_options[@]}" -- *.pub \
279
296
  | tar x -C "$destination_path") || {
280
297
  dotpi_echo_error "No public key found in ${source_path}"
281
298
  exit 1
@@ -289,7 +306,7 @@ destination_path="${DOTPI_ROOT}/etc/network"
289
306
  mkdir -p -- "$destination_path"
290
307
  if [ -d "$source_path" ] && [ -r "$source_path" ] ; then
291
308
  (set -o pipefail ; \
292
- cd -- "$source_path" && tar c "${tar_options[@]}" *.nmconnection \
309
+ cd -- "$source_path" && tar c "${tar_options[@]}" -- *.nmconnection \
293
310
  | tar x -C "$destination_path") || {
294
311
  dotpi_echo_error "No network connection found in ${source_path}"
295
312
  exit 1
@@ -330,12 +347,16 @@ if [[ "$(uname)" =~ "Darwin" ]] ; then
330
347
 
331
348
  # try to mount if unmounted (but not ejected)
332
349
  if type -P diskutil &> /dev/null ; then
333
- diskutil mount "$bootfs_name"
350
+ diskutil mount "$bootfs_name" || {
351
+ exitCode=$?
352
+ dotpi_echo_error "Error with SD card: Unable to mount ${bootfs_name}"
353
+ exit $exitCode
354
+ }
334
355
  fi
335
356
 
336
357
  # avoid spotlight errors
337
358
  bootfs_path="$(find /Volumes -name "$bootfs_name" 2> /dev/null)"
338
- elif [[ "$(uname -a)" =~ "Microsoft" ]] ; then
359
+ elif [[ "$(uname -a)" =~ [Mm]icrosoft ]] ; then
339
360
  echo ""
340
361
  echo "Windows Subsystem for Linux system detected"
341
362
  echo ""
@@ -348,7 +369,9 @@ elif [[ "$(uname -a)" =~ "Microsoft" ]] ; then
348
369
  bootfs_mount_target="${tmp_path}/${bootfs_name}"
349
370
  mkdir -p "$bootfs_mount_target"
350
371
  mount -t drvfs "$bootfs_mount_source" "$bootfs_mount_target" || {
351
- dotpi_echo_error "Unable to mount ${bootfs_mount_source} to ${bootfs_mount_target}"
372
+ exitCode=$?
373
+ dotpi_echo_error "Error with SD card: Unable to mount ${bootfs_mount_source} to ${bootfs_mount_target}"
374
+ exit $exitCode
352
375
  }
353
376
  fi
354
377
 
@@ -369,7 +392,11 @@ elif [[ "$(uname)" =~ "Linux" ]] ; then
369
392
 
370
393
  # try to mount if unmounted (but not ejected)
371
394
  if type -P udisksctl &> /dev/null ; then
372
- udisksctl mount --block-device "/dev/disk/by-label/${bootfs_name}"
395
+ udisksctl mount --block-device "/dev/disk/by-label/${bootfs_name}"|| {
396
+ exitCode=$?
397
+ dotpi_echo_error "Error with SD card: Unable to mount ${bootfs_name}"
398
+ exit $exitCode
399
+ }
373
400
  fi
374
401
 
375
402
  bootfs_path="$(lsblk --output MOUNTPOINT | grep "/${bootfs_name}")"
@@ -443,23 +470,9 @@ fi
443
470
 
444
471
  ######### audio device
445
472
 
446
- # set model before, as it will select jackd configuration
473
+ # set model first, to use it for audio configuration
447
474
  dotpi_audio_device_select --model "$dotpi_audio_device" --config "$config_file"
448
475
 
449
- # copy configuration files from project for over-rides
450
- source_path="${project_path}/jackd"
451
- destination_path="${DOTPI_ROOT}/share/jackd"
452
- mkdir -p -- "$destination_path"
453
- if [ -d "$source_path" ] && [ -r "$source_path" ] ; then
454
- (set -o pipefail ; \
455
- cd -- "$source_path" && tar c "${tar_options[@]}" '.' \
456
- | tar x -C "$destination_path") || {
457
- dotpi_echo_error "Unable to install files from ${source_path}"
458
- exit 1
459
- }
460
- fi
461
-
462
-
463
476
  # back-up imager config
464
477
 
465
478
  destination_filename="imager_${config_filename}"
@@ -613,4 +626,3 @@ dotpi_echo_info "You can monitor the preparation of the system with the followin
613
626
  dotpi_echo_info "(You will have to wait until the network is ready.)"
614
627
  dotpi_echo_info ''
615
628
  dotpi_echo_info "ssh ${dotpi_user}@${dotpi_instance_hostname}.local 'tail -f /opt/dotpi/var/log/dotpi_prepare_system_*.log'"
616
-
@@ -49,8 +49,13 @@ sudo dpkg --configure -a || {
49
49
  error_exit $? dpkg $error_exit_code_package
50
50
  }
51
51
 
52
- dotpi echo_info "Uninstall apt packages: ${dotpi_apt_uninstall_default[@]} ${dotpi_apt_uninstall[@]}"
53
- sudo dotpi apt_get purge "${dotpi_apt_uninstall_default[@]}" "${dotpi_apt_uninstall[@]}" || {
52
+ declare -A apt_uninstall_packages
53
+ for package in "${dotpi_apt_uninstall_default[@]}" "${dotpi_apt_uninstall[@]}" ; do
54
+ apt_uninstall_packages["$package"]=1
55
+ done
56
+
57
+ dotpi echo_info "Uninstall apt packages:" "${!apt_uninstall_packages[@]}"
58
+ sudo dotpi apt_get purge "${!apt_uninstall_package[@]}" || {
54
59
  error_exit $? 'apt_get purge' $error_exit_code_package
55
60
  }
56
61
 
@@ -69,8 +74,16 @@ sudo dotpi apt_get dist-upgrade || {
69
74
  error_exit $? 'apt_get dist-upgrade' $error_exit_code_package
70
75
  }
71
76
 
72
- dotpi echo_info "Install apt packages: ${dotpi_apt_install_default[@]} ${dotpi_apt_install[@]}"
73
- sudo dotpi apt_get install "${dotpi_apt_install_default[@]}" "${dotpi_apt_install[@]}" || {
77
+ declare -A apt_install_packages
78
+ for package in "${dotpi_apt_install_default[@]}" "${dotpi_apt_install[@]}" ; do
79
+ # install only packages not required to be uninstalled
80
+ if [[ "${apt_uninstall_packages["$package"]}" == '' ]] ; then
81
+ apt_install_packages["$package"]=1
82
+ fi
83
+ done
84
+
85
+ dotpi echo_info "Install apt packages:" "${!apt_install_packages[@]}"
86
+ sudo dotpi apt_get install "${!apt_install_packages[@]}" || {
74
87
  error_exit $? 'apt_get install' $error_exit_code_package
75
88
  }
76
89
 
@@ -99,7 +112,7 @@ sudo mkdir -p -- "$N_PREFIX" || {
99
112
  }
100
113
 
101
114
  while ! curl -L https://bit.ly/n-install -o /tmp/n-install ; do
102
- dotpi echo_warning "Error while retriving n-install"
115
+ dotpi echo_warning "Error while retrieving n-install"
103
116
  sleep 1
104
117
  echo "trying again"
105
118
  done
@@ -140,35 +153,76 @@ for executable in "${executables[@]}" ; do
140
153
  }
141
154
  done
142
155
 
143
- ############## services
156
+ ############## services and modules
144
157
  error_exit_code_services=4
145
158
 
146
- # allow to run user services without login
159
+ dotpi echo_info "Enable linger to run user services without login"
160
+
147
161
  sudo loginctl enable-linger "$FIRSTUSER" || {
148
162
  error_exit $? "loginctl enable-linger" $error_exit_code_services
149
163
  }
150
164
 
151
- ############# avahi (multicast DNS, bonjour)
165
+ ############# dotpi module manager
166
+
167
+ # bootstrap-install
168
+ module_name="@dotpi/module"
169
+ source_path="${DOTPI_ROOT}/dist/${module_name}"
170
+ destination_prefix="${DOTPI_ROOT}/lib"
171
+ destination_path="${destination_prefix}/node_modules/${module_name}"
172
+ {
173
+ dotpi echo_info "Install ${modules_name}"
174
+ # minimal install in the modules directory
175
+ sudo npm install --no-fund \
176
+ --prefix "$destination_prefix" \
177
+ --install-strategy nested \
178
+ --omit dev \
179
+ --save \
180
+ --ignore-scripts \
181
+ -- \
182
+ "$source_path" || {
183
+ error_exit $? "dotpi_module: error when installing '${module_name}'" $error_exit_code_services
184
+ }
185
+
186
+ (
187
+ echo "# Install '${module_name}' dependencies"
188
+ # complete install within the module itself
189
+ # be sure to install links for relative dependencies also
190
+ # run postinstall script
152
191
 
153
- # restart when hostname is not resolved by mDNS
154
- sudo dotpi service_install "${DOTPI_ROOT}/share/dotpi_avahi_monitor/dotpi_avahi_monitor.service" || {
155
- error_exit $? "install dotpi_avahi_monitor.service" $error_exit_code_services
192
+ sudo rm -rf "${destination_path}/node_modules" || {
193
+ error_exit $? "rm ${destination_path}/node_modules" $error_exit_code_services
194
+ }
195
+
196
+ sudo npm install --no-fund \
197
+ --prefix "$destination_path" \
198
+ --omit dev \
199
+ --install-links \
200
+ || {
201
+ error_exit $? "dotpi_module: error when installing '${module_name}' dependencies'" $error_exit_code_services
202
+ }
203
+ )
204
+ } || {
205
+ error_exit $? "${module_name}" $error_exit_code_services
156
206
  }
157
207
 
158
- ############## pipewire (and jackd compatibility)
208
+ ############## audio
159
209
  error_exit_code_audio=6
160
210
 
211
+ # @TODO: @dotpi/audio
212
+
213
+ dotpi echo_info "Configure audio"
214
+
161
215
  # set alsa default output volume and unmute
162
216
  sudo dotpi audio_device_init || {
163
- dotpi echo_warning "Error while setting default output volume and unmute for ${dotpi_audio_device} device" \
217
+ dotpi echo_warning "Error while setting default output volume and unmute for ${dotpi_audio_device} device"
164
218
  $error_exit_code_audio
165
219
  }
166
220
 
167
- # over-ride calls to jackd
168
- # copy with prefix 0- to ensure it is loaded before default aarch64-linux-gnu.conf
221
+ # over-ride calls to jack, to use pipewire instead
222
+ # copy with prefix 000- to ensure it is loaded before default aarch64-linux-gnu.conf
169
223
  for f in /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf ; do
170
224
  source_basename="$(basename "$f")"
171
- destination_basename="0-${source_basename}"
225
+ destination_basename="000-${source_basename}"
172
226
  sudo cp "$f" "/etc/ld.so.conf.d/${destination_basename}" || {
173
227
  error_exit $? "install ${f}" $error_exit_code_audio
174
228
  }
@@ -177,6 +231,27 @@ sudo ldconfig || {
177
231
  error_exit $? "ldconfig" $error_exit_code_audio
178
232
  }
179
233
 
234
+ # settings over-rides
235
+ source_path="${DOTPI_ROOT}/share/wireplumber"
236
+ destination_path='/usr/share/wireplumber'
237
+ if [ -r "$source_path" ] ; then
238
+ sudo mkdir -p "$destination_path"
239
+ tar c -C "$source_path" '.' | sudo tar x -C "$destination_path"
240
+ exit_code=$?
241
+ pipe_status="${PIPESTATUS[0]}"
242
+ if (( exit_code || pipe_status )) ; then
243
+ if (( exit_code )) ; then
244
+ dotpi echo_error "Error code: $exit_code"
245
+ fi
246
+
247
+ if (( pipe_status )) ; then
248
+ dotpi echo_error "Pipe status: $pipe_status"
249
+ fi
250
+
251
+ error_exit "$((exit_code ? exit_code : pipe_status))" "Error while copying ${source_path} to ${destination_path}" $error_exit_code_audio
252
+ fi
253
+ fi
254
+
180
255
  systemctl --user enable --now wireplumber.service || {
181
256
  dotpi echo_warning "error while enabling wireplumber.service now: ${?}"
182
257
  dotpi echo_warning "wireplumber.service will be available after a reboot"
@@ -188,63 +263,28 @@ systemctl --user enable --now wireplumber.service || {
188
263
  # do not exit
189
264
  }
190
265
 
191
- ############## dotpi-manager
192
- error_exit_code_dotpi_manager=7
266
+ ############## dotpi modules
267
+ error_exit_code_dotpi_modules=10
193
268
 
194
- if [[ "$dotpi_manager_install" == "yes" ]]; then (
195
- destination="${DOTPI_ROOT}/share/dotpi-manager"
196
- sudo mkdir -p -- "$destination" || {
197
- error_exit $? "dotpi-manager: mkdir ${destination}" $error_exit_code_dotpi_manager
198
- }
199
- cd -- "$destination" || {
200
- error_exit $? "dotpi-manager: cd ${destination}" $error_exit_code_dotpi_manager
201
- }
202
269
 
203
- destination_runtime="${destination}/runtime"
204
- sudo rm -rf -- "$destination_runtime" || {
205
- error_exit $? "dotpi-manager: rm ${destination_runtime}" $error_exit_code_dotpi_manager
206
- }
207
- sudo git clone --depth=1 https://github.com/ircam-ismm/dotpi-manager.git "$destination_runtime" || {
208
- error_exit $? "dotpi-manager: git clone" $error_exit_code_dotpi_manager
209
- }
210
- # bootstrap-install
211
- sudo bash -c "\
212
- source '${DOTPI_ROOT}/share/dotpi_init.bash' && \
213
- source runtime/dotpi/dotpi-manager.bash && \
214
- dotpi_manager_update \
215
- " || {
216
- error_exit $? "dotpi_manager_update" $error_exit_code_dotpi_manager
217
- }
218
- ) fi
270
+ declare -A dotpi_module_uninstall_modules
271
+ for module in "${dotpi_module_uninstall_default[@]}" "${dotpi_module_uninstall[@]}" ; do
272
+ dotpi_module_uninstall_modules["$module"]=1
273
+ done
219
274
 
220
- ############## dotpi-led
221
- error_exit_code_dotpi_led=8
275
+ dotpi echo_info "Uninstall dotpi modules packages:" "${!dotpi_module_uninstall_modules[@]}"
276
+ sudo dotpi module uninstall "${!dotpi_module_uninstall_modules[@]}"
222
277
 
223
- if [[ "$dotpi_led_install" == "yes" ]]; then (
224
- destination="${DOTPI_ROOT}/share/dotpi-led"
225
- sudo mkdir -p -- "$destination" || {
226
- error_exit $? "dotpi-led: mkdir ${destination}" $error_exit_code_dotpi_led
227
- }
228
- cd -- "$destination" || {
229
- error_exit $? "dotpi-led: cd ${destination}" $error_exit_code_dotpi_led
230
- }
278
+ declare -A dotpi_module_install_modules
279
+ for module in "${dotpi_module_install_default[@]}" "${dotpi_module_install[@]}" ; do
280
+ # install only modules not required to be uninstalled
281
+ if [[ "${dotpi_module_uninstall_modules["$module"]}" == '' ]] ; then
282
+ dotpi_module_install_modules["$module"]=1
283
+ fi
284
+ done
231
285
 
232
- destination_runtime="${destination}/runtime"
233
- sudo rm -rf -- "$destination_runtime" || {
234
- error_exit $? "dotpi-led: rm ${destination_runtime}" $error_exit_code_dotpi_led
235
- }
236
- sudo git clone --depth=1 https://github.com/ircam-ismm/dotpi-led.git "$destination_runtime" || {
237
- error_exit $? "dotpi-led: git clone" $error_exit_code_dotpi_led
238
- }
239
- # bootstrap-install
240
- sudo bash -c "\
241
- source '${DOTPI_ROOT}/share/dotpi_init.bash' && \
242
- source runtime/dotpi/dotpi-led.bash && \
243
- dotpi_led_update \
244
- " || {
245
- error_exit $? "dotpi-led: dotpi_led_update" $error_exit_code_dotpi_led
246
- }
247
- ) fi
286
+ dotpi echo_info "Install dotpi modules packages:" "${!dotpi_module_install_modules[@]}"
287
+ sudo dotpi module install "${!dotpi_module_install_modules[@]}"
248
288
 
249
289
  ############## finalisation
250
290
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@dotpi/bin",
3
+ "description": "dotpi bin configuration for node.js",
4
+ "version": "1.0.0",
5
+ "type": "module"
6
+ }
@@ -4,11 +4,7 @@ After=avahi-daemon.service
4
4
 
5
5
  [Service]
6
6
  Type=exec
7
- LimitRTPRIO=infinity
8
- LimitMEMLOCK=infinity
9
- User=pi
10
- Group=audio
11
- ExecStart=/opt/dotpi/share/dotpi_avahi_monitor/dotpi_avahi_monitor_command
7
+ ExecStart=/opt/dotpi/lib/dotpi_modules/@dotpi/avahi_monitor/dotpi_avahi_monitor_command
12
8
  Restart=always
13
9
 
14
10
  # wait before restarting
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ if ! dotpi system_is_raspberry_pi &> /dev/null ; then
4
+ echo "INFO: System is not a Raspberry Pi with dotpi: no installation"
5
+ # no error
6
+ exit 0
7
+ fi
8
+
9
+ if [[ "$USER" != "root" ]]; then
10
+ dotpi echo_error "This command must be run as root"
11
+ exit 1
12
+ fi
13
+
14
+ local_file="$(dotpi readlink_follow "$0")"
15
+ local_path="$(dirname -- "$local_file")"
16
+
17
+ service_name="dotpi_avahi_monitor.service"
18
+ service_file="${local_path}/${service_name}"
19
+
20
+ dotpi echo_info "Install ${service_file}"
21
+ dotpi service_install "${service_file}"
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ if ! dotpi system_is_raspberry_pi &> /dev/null ; then
4
+ echo "INFO: System is not a Raspberry Pi with dotpi: no uninstallation"
5
+ # no error
6
+ exit 0
7
+ fi
8
+
9
+ if [[ "$USER" != "root" ]]; then
10
+ dotpi echo_error "This command must be run as root"
11
+ exit 1
12
+ fi
13
+
14
+ service_name="dotpi_avahi_monitor.service"
15
+
16
+ dotpi echo_info "Uninstall ${service_name}"
17
+ dotpi service_uninstall "${service_name}"
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@dotpi/avahi_monitor",
3
+ "version": "1.1.2",
4
+ "description": "A tool to monitor and restart Avahi service",
5
+ "scripts": {
6
+ "postinstall": "./dotpi_install",
7
+ "preuninstall": "./dotpi_uninstall"
8
+ },
9
+ "license": "BSD-3-clause"
10
+ }
@@ -0,0 +1,103 @@
1
+ import nodePath from 'node:path';
2
+
3
+ import{ $ } from 'execa';
4
+
5
+ import { dotpiRootGet } from './system.js';
6
+
7
+ export async function dotpiInitSourceFileGet({
8
+ dotpiRoot,
9
+ } = {}) {
10
+ dotpiRoot ??= await dotpiRootGet();
11
+
12
+ return nodePath.resolve(dotpiRoot, 'share', 'dotpi_init.bash');
13
+ }
14
+
15
+ export async function sourceAndExecute({
16
+ sourceFiles = [],
17
+ sourceFile,
18
+ uid, // optional to run as another user, see user/regularUserIdGet
19
+ command = ':', // default to no-op
20
+ } = {}) {
21
+
22
+ try {
23
+ let _sourceFiles = [...sourceFiles];
24
+ if (typeof sourceFile === 'string') {
25
+ _sourceFiles.push(sourceFile);
26
+ }
27
+
28
+ const commandPrefix = _sourceFiles.reduce((prefix, _sourceFile) => {
29
+ return `${prefix}source '${_sourceFile}' && `;
30
+ }, '');
31
+
32
+ const commandPrefixed = `${commandPrefix} { ${command} ; }`;
33
+
34
+ const output = await $({
35
+ uid,
36
+ shell: '/bin/bash',
37
+ all: true,
38
+ })(commandPrefixed);
39
+
40
+ return output;
41
+
42
+ } catch (error) {
43
+ throw error;
44
+ }
45
+ }
46
+ export async function variableRead({
47
+ sourceFiles = [],
48
+ sourceFile, // optional to read from environment
49
+ variable, // required, bash variable to read
50
+ uid, // optional to run as another user, see user/regularUserIdGet
51
+ } = {}) {
52
+
53
+ try {
54
+
55
+ const { stdout } = await sourceAndExecute({
56
+ sourceFiles,
57
+ sourceFile,
58
+ uid,
59
+ command: ` \
60
+ for v in "\${${variable}[@]}" ; do \
61
+ printf "\$v\\0" ; \
62
+ done \
63
+ `,
64
+ });
65
+
66
+ if (stdout.length === 0) {
67
+ // '' when no value
68
+ return undefined;
69
+ }
70
+
71
+ let values = stdout.split('\0');
72
+ // remove last empty string
73
+ values.pop();
74
+
75
+ if (values.length === 1) {
76
+ return values[0];
77
+ }
78
+
79
+ return values;
80
+
81
+ } catch (error) {
82
+ throw error;
83
+ }
84
+
85
+ }
86
+
87
+ // this handles '~', '$HOME', and other bash expansions
88
+ export async function pathResolve({
89
+ uid,
90
+ path,
91
+ sourceFiles = [],
92
+ sourceFile, // optional to read from environment
93
+ } = {
94
+ }) {
95
+ const { stdout } = await sourceAndExecute({
96
+ uid,
97
+ sourceFiles,
98
+ sourceFile,
99
+ command: `echo ${path}`,
100
+ });
101
+
102
+ return nodePath.resolve(stdout);
103
+ }
@@ -0,0 +1,13 @@
1
+ import chalk from 'chalk';
2
+
3
+ export function info(...message) {
4
+ console.log(chalk.green('INFO:'), ...message);
5
+ }
6
+
7
+ export function warning(...message) {
8
+ console.log(chalk.yellow('WARNING:'), ...message);
9
+ }
10
+
11
+ export function error(...message) {
12
+ console.log(chalk.red('ERROR:'), ...message);
13
+ }
@@ -0,0 +1,25 @@
1
+ import fs from 'node:fs/promises';
2
+
3
+ // like node:fs.symlink but replace destination
4
+ export async function symlink(source, destination) {
5
+
6
+ try {
7
+ const destinationTmp = `${destination}_dotpi_tmp_${process.pid}`;
8
+ await fs.symlink(source, destinationTmp);
9
+ // atomic in POSIX. Replace file or symlink (not directory)
10
+ await fs.rename(destinationTmp, destination)
11
+ .catch(async (error) => {
12
+ if (error.code === 'EISDIR') {
13
+ // remove existing directory and try again
14
+ await fs.rm(destination, { recursive: true, force: true });
15
+ return await fs.rename(destinationTmp, destination);
16
+ }
17
+
18
+ // give up for other errors
19
+ throw error;
20
+ });
21
+ } catch (error) {
22
+ throw error;
23
+ }
24
+
25
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@dotpi/javascript",
3
+ "version": "1.5.0",
4
+ "description": "dotpi javascript utilities",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "dependencies": {
8
+ "chalk": "^5.4.0",
9
+ "execa": "^9.5.2",
10
+ "template-literal": "^1.0.4"
11
+ }
12
+ }