@dotpi/tools 1.4.0 → 2.3.3

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 (150) 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/bin/dotpi_module +13 -0
  20. package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
  21. package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
  22. package/dotpi_root/dist/@dotpi/module/package.json +21 -0
  23. package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
  24. package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
  25. package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
  26. package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
  27. package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
  28. package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
  29. package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
  30. package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
  31. package/dotpi_root/etc/dotpi_modules.json +8 -0
  32. package/dotpi_root/lib/package.json +6 -0
  33. package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
  34. package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
  35. package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
  36. package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
  37. package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
  38. package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
  39. package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
  40. package/dotpi_root/share/dotpi_functions.bash +4 -4
  41. package/dotpi_root/share/dotpi_init.bash +7 -1
  42. package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +7 -6
  43. package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -1
  44. package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
  45. package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
  46. package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
  47. package/lerna.json +4 -0
  48. package/package.json +12 -2
  49. package/projects/led-test/.dotpi +3 -0
  50. package/projects/led-test/README.md +16 -0
  51. package/projects/led-test/dotpi_project.bash +29 -0
  52. package/projects/qsddsqsd/.dotpi +3 -0
  53. package/projects/qsddsqsd/README.md +16 -0
  54. package/projects/qsddsqsd/dotpi_project.bash +29 -0
  55. package/src/constants.js +4 -4
  56. package/src/create-project.js +124 -56
  57. package/src/templates/dotpi_project.bash +5 -7
  58. package/src/utils.js +2 -2
  59. package/test/create-project.test.js +0 -1
  60. package/PIPEWIRE.md +0 -280
  61. package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +0 -149
  62. package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +0 -177
  63. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +0 -425
  64. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +0 -620
  65. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +0 -82
  66. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +0 -100
  67. package/dotpi_root/bin/.editorbackup/dotpi~ +0 -61
  68. package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +0 -252
  69. package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +0 -49
  70. package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  71. package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +0 -33
  72. package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +0 -4
  73. package/dotpi_root/share/.editorbackup/coucou~ +0 -1
  74. package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +0 -9
  75. package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +0 -11
  76. package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +0 -420
  77. package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +0 -358
  78. package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +0 -18
  79. package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +0 -15
  80. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +0 -24
  81. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +0 -80
  82. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +0 -26
  83. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +0 -30
  84. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +0 -21
  85. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +0 -256
  86. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +0 -287
  87. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +0 -7
  88. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +0 -428
  89. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +0 -194
  90. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +0 -26
  91. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +0 -287
  92. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +0 -12
  93. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +0 -158
  94. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +0 -152
  95. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +0 -20
  96. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +0 -17
  97. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +0 -20
  98. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +0 -16
  99. package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +0 -5
  100. package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +0 -15
  101. package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +0 -5
  102. package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +0 -23
  103. package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
  104. package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
  105. package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
  106. package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
  107. package/dotpi_root/share/jackd/jackd.service +0 -22
  108. package/dotpi_root/share/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +0 -1
  109. package/projects/old/dev.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  110. package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +0 -33
  111. package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  112. package/projects/old/dev.bak/dotpi_environment_instance.bash +0 -1
  113. package/projects/old/dev.bak/dotpi_environment_project.bash +0 -46
  114. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  115. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +0 -24
  116. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  117. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +0 -22
  118. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +0 -23
  119. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +0 -23
  120. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +0 -23
  121. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +0 -24
  122. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +0 -24
  123. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +0 -23
  124. package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  125. package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +0 -24
  126. package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  127. package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +0 -22
  128. package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +0 -23
  129. package/projects/old/dev.bak/network/AccueilCie.nmconnection +0 -24
  130. package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +0 -23
  131. package/projects/old/dev.bak/network/DOTPI.nmconnection +0 -23
  132. package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +0 -25
  133. package/projects/old/dev.bak/network/onze.nmconnection +0 -24
  134. package/projects/old/dev.bak/network/welcome.nmconnection +0 -23
  135. package/projects/old/dev.bak/network/wifi-access-point.nmconnection +0 -23
  136. package/projects/old/dev.bak/network/wifi-internet.nmconnection +0 -24
  137. package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +0 -24
  138. package/projects/old/dev.bak/network/wifi-local.nmconnection +0 -22
  139. package/projects/old/dev.bak/network/wifi-welcome.nmconnection +0 -24
  140. package/projects/old/dev.bak/wpa_supplicant.conf +0 -43
  141. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  142. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +0 -26
  143. package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +0 -21
  144. package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +0 -3
  145. package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  146. package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +0 -21
  147. package/projects/old/example-complete.bak/configuration/dotpi_project.bash +0 -21
  148. package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +0 -14
  149. package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +0 -14
  150. /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
@@ -0,0 +1,180 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ import { $ } from 'execa';
5
+ import { globby } from 'globby';
6
+
7
+ import * as echo from '@dotpi/javascript/echo.js';
8
+
9
+ import { dotpiConfigurationGet } from './configuration.js';
10
+ import { definitionGet } from './definition.js';
11
+
12
+ export async function uninstallCommandDefine({program}) {
13
+ program
14
+ .command('uninstall [modules...]')
15
+ .summary('uninstall a list of modules')
16
+ .description('Uninstall a list of modules separated by space.')
17
+ .option('-r, --dotpi-root <path>', 'dotpi root path, to initialise environment')
18
+ .option('-p, --prefix <path>', 'install modules in this directory')
19
+ .option('-v, --verbose [full]', 'print verbose output [full]')
20
+ .action((modules, options, command) => uninstall(modules, { ...options, command }));
21
+ ;
22
+ return program;
23
+ }
24
+
25
+ async function uninstallScriptRun(module, {
26
+ verbose = 'short',
27
+ } = {}) {
28
+ try {
29
+
30
+ const cwd = module;
31
+ const output = await $({
32
+ cwd,
33
+ })`npm --prefix ${cwd}
34
+ run --json
35
+ `;
36
+ const uninstallScript = JSON.parse(output.stdout).preuninstall;
37
+
38
+ if (uninstallScript) {
39
+ // npm does not automatically run preuninstall script
40
+
41
+ if(verbose !== 'none') {
42
+ echo.info(`Running uninstall script for ${module}`);
43
+ }
44
+ await $({
45
+ cwd,
46
+ env: { FORCE_COLOR: 'true' }, // do not remove colors
47
+ verbose: (verbose === 'full' ? 'full' : 'none'),
48
+ })`npm --prefix ${cwd}
49
+ run preuninstall
50
+ `;
51
+ }
52
+
53
+ return output;
54
+ } catch (error) {
55
+ echo.error(`Failed to run uninstall script for ${module}: ${error.message}`);
56
+ throw error;
57
+ }
58
+ }
59
+
60
+ export async function uninstall(modules = [], {
61
+ dotpiRoot,
62
+ prefix,
63
+ verbose = 'short',
64
+ } = {}) {
65
+ if (typeof modules === 'string') {
66
+ modules = [modules];
67
+ }
68
+
69
+ switch (verbose) {
70
+ case '0':
71
+ case 'false':
72
+ case false:
73
+ verbose = 'none';
74
+ break;
75
+
76
+ case '1':
77
+ case 'true':
78
+ case true:
79
+ verbose = 'short';
80
+ break;
81
+
82
+ case '2':
83
+ verbose = 'full';
84
+ break;
85
+ }
86
+
87
+ let dotpiModulesDestination;
88
+ let dotpiModulesConfiguration;
89
+ try {
90
+ ({
91
+ modulesPath: dotpiModulesDestination,
92
+ modulesConfiguration: dotpiModulesConfiguration,
93
+ } = await dotpiConfigurationGet({ dotpiRoot, prefix }));
94
+ } catch (error) {
95
+ echo.error(`Failed to get dotpi configuration: ${error.message}`);
96
+ process.exit(1);
97
+ }
98
+
99
+ // no parallelisation to uninstall modules
100
+ let moduleToUninstall;
101
+ for (const module of modules) {
102
+ try {
103
+ const moduleRegistered = dotpiModulesConfiguration.moduleSource[module];
104
+ if (moduleRegistered) {
105
+ if(verbose !== 'none') {
106
+ echo.info(`Module '${module}' is registered as '${moduleRegistered}'`);
107
+ }
108
+ moduleToUninstall = moduleRegistered;
109
+ } else {
110
+ moduleToUninstall = module;
111
+ }
112
+
113
+ let output;
114
+ let cwd;
115
+
116
+ if(verbose === 'full') {
117
+ console.log(`Getting '${moduleToUninstall}' definition`);
118
+ }
119
+ const moduleDefinition = await definitionGet(moduleToUninstall);
120
+ const { name: moduleName } = moduleDefinition;
121
+
122
+ // uninstall actually installed module
123
+ moduleToUninstall = moduleName;
124
+
125
+ if(verbose !== 'none') {
126
+ echo.info(`Uninstalling module '${moduleToUninstall}' in '${dotpiModulesDestination}'`);
127
+ }
128
+
129
+ cwd = path.resolve(dotpiModulesDestination, 'node_modules', moduleName);
130
+
131
+ // throw error if module is not installed, caught to continue with next module
132
+ await fs.access(cwd);
133
+
134
+ // First, uninstall dependencies manually,
135
+ // as npm doest not execute {pre,post}uninstall scripts since version 7
136
+
137
+ const dependencies = await globby(
138
+ // globby needs a posix path
139
+ `${path.posix.resolve(cwd)}/**/node_modules/*`
140
+ );
141
+ for(const dependency of dependencies) {
142
+ try {
143
+ await uninstallScriptRun(dependency, { verbose });
144
+ } catch (error) {
145
+ // continue with other dependencies
146
+ }
147
+ }
148
+
149
+ output = await uninstallScriptRun(cwd, { verbose });
150
+
151
+ if(verbose !== 'none') {
152
+ echo.info(`Uninstalling ${moduleToUninstall}`);
153
+ }
154
+
155
+ cwd = dotpiModulesDestination;
156
+ output = await $({
157
+ cwd,
158
+ env: { FORCE_COLOR: 'true' }, // do not remove colors
159
+ verbose: (verbose === 'full' ? 'full' : 'none'),
160
+ })`
161
+ npm --prefix ${cwd}
162
+ uninstall
163
+ --save
164
+ --
165
+ ${moduleName}
166
+ `;
167
+
168
+ } catch (error) {
169
+ if (error.code === 'ENOENT') {
170
+ echo.warning(`Module ${moduleToUninstall} is not installed`);
171
+ continue;
172
+ }
173
+
174
+ // give up for other errors
175
+ echo.error(`Failed to uninstall ${moduleToUninstall}: ${error.message}`);
176
+ process.exit(1);
177
+ }
178
+
179
+ } // for (const module of modules)
180
+ }
@@ -66,4 +66,20 @@ dotpi_apt_install_default=(
66
66
  # user-defined, use +=(package1 package2) to add packages to list
67
67
  dotpi_apt_install=()
68
68
 
69
+ # system default
70
+ dotpi_module_uninstall_default=()
71
+
72
+ # user-defined, use +=(package1 package2) to add packages to list
73
+ dotpi_module_uninstall=()
74
+
75
+ # system default
76
+ dotpi_module_install_default=(
77
+ # '@dotpi/module' is already installed to bootstrap
78
+ # '@dotpi/manager'
79
+ '@dotpi/avahi_monitor'
80
+ )
81
+
82
+ # user-defined, use +=(package1 package2) to add packages to list
83
+ dotpi_module_install=()
84
+
69
85
  dotpi_node_version='lts'
File without changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "moduleSource": {
3
+
4
+ "_example_git": "git+https://github.com/ircam-ismm/dotpi-led#feat-dotpi-module",
5
+ "_example_local": "file:///opt/dotpi/dist/@dotpi/avhi_monitor",
6
+ "_see_npm_doc": "https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies"
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "dotpi_root_installed_packages",
3
+ "description": "Packages installed in ${DOTPI_ROOT}/lib",
4
+ "dependencies": {
5
+ }
6
+ }
@@ -1,10 +1,11 @@
1
- #!/usr/bin/node
1
+ #!/usr/bin/env node
2
2
 
3
3
  // @TODO: use a proper pipewire lua script that automatically runs
4
4
  // whenever the default audio output is restored
5
5
 
6
- const util = require('node:util');
7
- const exec = util.promisify(require('node:child_process').exec);
6
+ import util from 'node:util';
7
+ import child_process from 'node:child_process';
8
+ const exec = util.promisify(child_process.exec);
8
9
 
9
10
  let pipewireData = null;
10
11
  async function pipewireRelink() {
@@ -102,11 +103,11 @@ async function pipewireRelink() {
102
103
 
103
104
  for(let p = 0; p < playbackNodes.length; ++p) {
104
105
  for(let o = 0; o < outputNodes.length; ++o) {
105
- playbackIndex = playbackNodes[p].id;
106
- outputIndex = outputNodes[o].id;
106
+ const playbackIndex = playbackNodes[p].id;
107
+ const outputIndex = outputNodes[o].id;
107
108
  const commandString = `pw-link ${playbackIndex} ${outputIndex}`;
108
109
  try {
109
- console.log(commandString);
110
+ // console.log(commandString);
110
111
  const {stdout, stderr} = await exec(commandString);
111
112
  // console.log('pw-link stdout:', stdout);
112
113
  if(stderr) {
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@dotpi/audio_bluetooth",
3
+ "description": "Monitor audio bluetooth keep it powered on and to dynamically relink playback nodes to output nodes",
4
+ "version": "1.0.0",
5
+ "type": "module"
6
+ }
@@ -36,6 +36,18 @@ dotpi_audio_device_supported=(
36
36
  'ue megaboom 3'
37
37
  )
38
38
 
39
+ dotpi_audio_device_is_analog() {
40
+ audio_device="${1:-$dotpi_audio_device}"
41
+ case "$audio_device" in
42
+ 'headphones')
43
+ return 0
44
+ ;;
45
+ *)
46
+ return 1
47
+ ;;
48
+ esac
49
+ }
50
+
39
51
  _dotpi_audio_device_get_options() {
40
52
 
41
53
  _echo_empty_option_error() {
@@ -284,24 +296,6 @@ dotpi_audio_device_select() (
284
296
  --value \""${model_value}"\"
285
297
  )
286
298
 
287
- _dotpi_audio_device_jackd_set_configuration() (
288
- model="$1"
289
- (cd "${DOTPI_ROOT}/share/jackd" && ln -s -f "dotpi_jackd_${model}.bash" 'dotpi_jackd.bash') || {
290
- dotpi_echo_error "Unable to change jackd configuration to ${model}"
291
- return 1
292
- }
293
-
294
- # we can change audio device in a temporary file-system, too
295
- if dotpi_system_is_raspberry_pi ; then
296
- dotpi_echo_warning "Restart jackd service"
297
- service='jackd'
298
- systemctl is-active "$service" > /dev/null 2>&1 \
299
- && systemctl restart "$service" || {
300
- dotpi_echo_warning "systemctl unable to restart service ${service}"
301
- }
302
- fi
303
- )
304
-
305
299
  _dotpi_audio_device_disable_all() (
306
300
  exception_family="$1"
307
301
 
@@ -338,14 +332,10 @@ _dotpi_audio_device_select_headphones() (
338
332
  # (setting at the end the the file fails)
339
333
  pattern="$(dotpi_configuration_get_pattern --prefix "# dtparam=audio")"
340
334
  perl -pe "s/${pattern}/"'dtparam=audio=on/' -i -- "$config_file"
341
-
342
- _dotpi_audio_device_jackd_set_configuration "headphones"
343
335
  )
344
336
 
345
337
  _dotpi_audio_device_select_bluetooth() (
346
338
  _dotpi_audio_device_disable_all bluetooth
347
-
348
- _dotpi_audio_device_jackd_set_configuration "bluetooth"
349
339
  )
350
340
 
351
341
  _dotpi_audio_device_select_raspberry_pi() (
@@ -360,8 +350,6 @@ _dotpi_audio_device_select_raspberry_pi() (
360
350
  dtoverlay=${dtoverlay}
361
351
 
362
352
  EOF
363
-
364
- _dotpi_audio_device_jackd_set_configuration "hifiberry"
365
353
  )
366
354
 
367
355
 
@@ -377,8 +365,6 @@ _dotpi_audio_device_select_hifiberry() (
377
365
  dtoverlay=${dtoverlay}
378
366
 
379
367
  EOF
380
-
381
- _dotpi_audio_device_jackd_set_configuration "hifiberry"
382
368
  )
383
369
 
384
370
  _dotpi_audio_device_disable_headphones() (
@@ -93,8 +93,8 @@ _dotpi_configuration_get_options() {
93
93
  }
94
94
 
95
95
  dotpi_configuration_escape_string() (
96
- # escape / \ $
97
- echo "$(echo "$1" | perl -pe 's#([/\\\$])#\\${1}#g')"
96
+ # escape all for regexp
97
+ echo -n "$1" | perl -ne 'print quotemeta($_)'
98
98
  )
99
99
 
100
100
  dotpi_configuration_get_pattern() (
@@ -44,8 +44,10 @@ dotpi_service_install() (
44
44
  ln -s -f "$(dotpi readlink_follow "${service_file}")" "${service_destination}"
45
45
 
46
46
  if (( user_service )); then
47
+ regular_user_name="$(dotpi_regular_user_get_name)"
48
+
47
49
  # drop sudo, with a proper session, including XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS
48
- command_prefix=(systemctl --machine="${SUDO_USER}@")
50
+ command_prefix=(systemctl --machine="${regular_user_name}@")
49
51
  else
50
52
  command_prefix=(systemctl)
51
53
  fi
@@ -99,8 +101,10 @@ dotpi_service_uninstall() (
99
101
  rm -f "${service_destination}/${service_name}"
100
102
 
101
103
  if (( user_service )); then
104
+ regular_user_name="$(dotpi_regular_user_get_name)"
105
+
102
106
  # drop sudo, with a proper session, including XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS
103
- command_prefix=(systemctl --machine="${SUDO_USER}@")
107
+ command_prefix=(systemctl --machine="${regular_user_name}@")
104
108
  else
105
109
  command_prefix=(systemctl)
106
110
  fi
@@ -1,5 +1,16 @@
1
1
  #!/bin/bash
2
2
 
3
+ dotpi_root_get() (
4
+ dotpi_root="${DOTPI_ROOT}"
5
+
6
+ if [[ -z "$dotpi_root" ]] ; then
7
+ local_file="$(dotpi_readlink_follow "${BASH_SOURCE[0]}")"
8
+ dotpi_root="$(dirname -- "$(dirname -- "$local_file")")"
9
+ fi
10
+
11
+ echo "$dotpi_root"
12
+ )
13
+
3
14
  # echo 'raspberry' or 'other'
4
15
  dotpi_system_is_raspberry_pi() (
5
16
  model='other'
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+
3
+ dotpi_regular_user_get_id() (
4
+ regular_user_id="${SUDO_UID:-1000}"
5
+ if (( regular_user_id == 0 )) ; then
6
+ regular_user_id=1000
7
+ fi
8
+
9
+ echo "$regular_user_id"
10
+ )
11
+
12
+ dotpi_regular_user_get_name() (
13
+ regular_user_id="$(dotpi_regular_user_get_id)"
14
+ regular_user_name="$(getent passwd "$regular_user_id" | cut -d: -f1)"
15
+ echo "$regular_user_name"
16
+ )
17
+
18
+ dotpi_regular_user_get_gid() (
19
+ regular_user_id="$(dotpi_regular_user_get_id)"
20
+ regular_user_name="$(getent passwd "$regular_user_id" | cut -d: -f3)"
21
+ echo "$regular_user_name"
22
+ )
23
+
24
+ dotpi_regular_user_get_home() (
25
+ regular_user_id="$(dotpi_regular_user_get_id)"
26
+ regular_user_home="$(getent passwd "$regular_user_id" | cut -d: -f6)"
27
+ echo "$regular_user_home"
28
+ )
@@ -2,13 +2,13 @@
2
2
 
3
3
  #### default functions
4
4
 
5
- for file in "${DOTPI_ROOT}/share/dotpi_functions/"* ; do
5
+ while IFS= read -r -d '' source_file ; do
6
6
  # continue on error
7
- source "$file" || true
8
- done
7
+ source "$source_file" || true
8
+ done < <( find "${DOTPI_ROOT}/share/dotpi_functions" -name '*.bash' -type f -print0 )
9
9
 
10
- #### dotpi-manager
11
10
 
11
+ # @TODO remove after migration to dotpi modules
12
12
  # continue on error
13
13
  dotpi_source_if_available "${DOTPI_ROOT}/share/dotpi-manager/dotpi-manager.bash" || true
14
14
  dotpi_source_if_available "${DOTPI_ROOT}/share/dotpi-led/dotpi-led.bash" || true
@@ -17,5 +17,11 @@ export PATH="${PATH}:${DOTPI_ROOT}/usr/bin"
17
17
  export PATH="${PATH}:${DOTPI_ROOT}/bin"
18
18
 
19
19
  source "${DOTPI_ROOT}/share/dotpi_functions.bash"
20
-
21
20
  source "${DOTPI_ROOT}/share/dotpi_environment.bash"
21
+
22
+ #### installed modules
23
+
24
+ while IFS= read -r -d '' source_file ; do
25
+ # continue on error
26
+ source "$source_file" || true
27
+ done < <( find "${DOTPI_ROOT}/etc/dotpi_init.d" -name '*.bash' -type f -print0 )
@@ -1,10 +1,11 @@
1
- #!/usr/bin/node
1
+ #!/usr/bin/env node
2
2
 
3
3
  // @TODO: use a proper pipewire lua script that automatically runs
4
4
  // whenever the default audio output is restored
5
5
 
6
- const util = require('node:util');
7
- const exec = util.promisify(require('node:child_process').exec);
6
+ import util from 'node:util';
7
+ import child_process from 'node:child_process';
8
+ const exec = util.promisify(child_process.exec);
8
9
 
9
10
  let pipewireData = null;
10
11
  async function pipewireRelink() {
@@ -31,7 +32,7 @@ async function pipewireRelink() {
31
32
  });
32
33
 
33
34
  if (playbackNodes.length === 0) {
34
- console.warn('pipewireRelink: no playback node');
35
+ // console.warn('pipewireRelink: no playback node');
35
36
  // no error
36
37
  process.exit(0);
37
38
  }
@@ -55,8 +56,8 @@ async function pipewireRelink() {
55
56
 
56
57
  for(let p = 0; p < playbackNodes.length; ++p) {
57
58
  for(let o = 0; o < outputNodes.length; ++o) {
58
- playbackIndex = playbackNodes[p].id;
59
- outputIndex = outputNodes[o].id;
59
+ const playbackIndex = playbackNodes[p].id;
60
+ const outputIndex = outputNodes[o].id;
60
61
  const commandString = `pw-link ${playbackIndex} ${outputIndex}`;
61
62
  try {
62
63
  // console.log(commandString);
@@ -17,7 +17,7 @@ local_path="$(dirname -- "$local_file")"
17
17
  sudo dotpi service_install --user "${local_path}/systemd/dotpi_pipewire.service"
18
18
 
19
19
  source_path="${local_path}/bin"
20
- destination_path="${DOTPI_ROOT}/usr/bin"
20
+ destination_path="${DOTPI_ROOT}/bin"
21
21
  sudo mkdir -p -- "$destination_path"
22
22
  for executable in "${source_path}/"* ; do
23
23
  sudo ln -s -f -- "$executable" "${destination_path}/$(basename -- "$executable")"
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@dotpi/pipewire",
3
+ "description": "Monitor Pipewire to dynamically relink playback nodes to output nodes",
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "postinstall": "dotpi_install"
8
+ }
9
+ }
@@ -1,11 +1,7 @@
1
- # Provided by the jackd package.
2
- #
3
1
  # Changes to this file will be preserved.
4
2
  #
5
- # If you want to enable/disable realtime permissions, run
6
- #
7
- # dpkg-reconfigure -p high jackd2
3
+ # (Settings taken from jackd package)
8
4
 
9
5
  @audio - rtprio 95
10
6
  @audio - memlock unlimited
11
- #@audio - nice -19
7
+ # @audio - nice -19
@@ -0,0 +1,8 @@
1
+ # WIP: no tested with wireplumber >= 0.4.0
2
+
3
+ # do not start and stop bluez with login: always run
4
+ wireplumber.profiles = {
5
+ main = {
6
+ monitor.bluez.seat-monitoring = disabled
7
+ }
8
+ }
package/lerna.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "node_modules/lerna/schemas/lerna-schema.json",
3
+ "version": "independent"
4
+ }
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dotpi/tools",
3
- "version": "1.4.0",
3
+ "version": "2.3.3",
4
4
  "description": "Set of scripts for managing dotpi fleets of Raspberry Pi",
5
5
  "author": "Jean-Philippe Lambert",
6
6
  "contributors": [
7
7
  "Jean-Philippe Lambert",
8
8
  "Benjamin Matuszewski"
9
9
  ],
10
+ "workspaces": [
11
+ ".",
12
+ "dotpi_root/dist/@dotpi/*"
13
+ ],
10
14
  "type": "module",
11
15
  "bin": {
12
16
  "dotpi-tools": "./dotpi-tools.js"
@@ -27,9 +31,15 @@
27
31
  },
28
32
  "license": "BSD-3-Clause",
29
33
  "dependencies": {
34
+ "@dotpi/javascript": "^1.4.1",
35
+ "@dotpi/module": "^1.5.0",
30
36
  "chalk": "^5.3.0",
31
37
  "commander": "^12.1.0",
32
38
  "prompts": "^2.4.2",
33
39
  "template-literal": "^1.0.4"
34
- }
40
+ },
41
+ "devDependencies": {
42
+ "lerna": "^8.1.9"
43
+ },
44
+ "gitHead": "54fdb0336d77b1b361021aeefa9a50b2a5881ff1"
35
45
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "dotpiToolsVersion": "2.2.0"
3
+ }
@@ -0,0 +1,16 @@
1
+ # dotpi project - led-test
2
+
3
+ This directory contains the necessary configuration files to install a Raspberry Pi
4
+ that belongs to a given dotpi project.
5
+
6
+ ## Warning
7
+
8
+ This directory contains sensitive informations that SHOULD NOT be shared on a
9
+ public repository.
10
+
11
+ In particular, the following files are ignored by default:
12
+ - dotpi_secrets.bash
13
+ - ssh
14
+ - network
15
+
16
+ You should thus share these files with people you trust through secure means.
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ # @dotpi/tools version
4
+ dotpi_tools_version='2.2.0'
5
+
6
+ # Project name
7
+ dotpi_project_name='led-test'
8
+
9
+ # Define soundcard
10
+ dotpi_audio_device='headphones'
11
+
12
+ # Node.js version
13
+ dotpi_node_version='lts'
14
+
15
+ # User-defined dotpi modules to install
16
+ dotpi_module_install+=(
17
+ '@dotpi/manager'
18
+ '@dotpi/led'
19
+ )
20
+
21
+ # Misc
22
+ dotpi_timezone='Europe/Paris'
23
+ dotpi_wifi_country_code='FR'
24
+ dotpi_keymap='fr'
25
+
26
+ # If you want to have some packages to be automatically installed
27
+ # or removed by default, you can list them in the arrays below
28
+ dotpi_apt_install+=()
29
+ dotpi_apt_uninstall+=()
@@ -0,0 +1,3 @@
1
+ {
2
+ "dotpiToolsVersion": "2.2.0"
3
+ }
@@ -0,0 +1,16 @@
1
+ # dotpi project - qsddsqsd
2
+
3
+ This directory contains the necessary configuration files to install a Raspberry Pi
4
+ that belongs to a given dotpi project.
5
+
6
+ ## Warning
7
+
8
+ This directory contains sensitive informations that SHOULD NOT be shared on a
9
+ public repository.
10
+
11
+ In particular, the following files are ignored by default:
12
+ - dotpi_secrets.bash
13
+ - ssh
14
+ - network
15
+
16
+ You should thus share these files with people you trust through secure means.
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ # @dotpi/tools version
4
+ dotpi_tools_version='2.2.0'
5
+
6
+ # Project name
7
+ dotpi_project_name='qsddsqsd'
8
+
9
+ # Define soundcard
10
+ dotpi_audio_device='default'
11
+
12
+ # Node.js version
13
+ dotpi_node_version='lts'
14
+
15
+ # User-defined dotpi modules to install
16
+ dotpi_module_install+=(
17
+ '@dotpi/manager'
18
+ '@dotpi/led'
19
+ )
20
+
21
+ # Misc
22
+ dotpi_timezone='Europe/Paris'
23
+ dotpi_wifi_country_code='FR'
24
+ dotpi_keymap='fr'
25
+
26
+ # If you want to have some packages to be automatically installed
27
+ # or removed by default, you can list them in the arrays below
28
+ dotpi_apt_install+=()
29
+ dotpi_apt_uninstall+=()