@dotpi/tools 1.3.3 → 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.
- package/.editorbackup/NOTES.md~ +974 -0
- package/.editorbackup/PIPEWIRE.md~ +42 -0
- package/.editorbackup/README.md~ +335 -0
- package/BACKUP-SANDO.command +61 -0
- package/BACKUP-SISIDO.command +61 -0
- package/NOTES.md +41 -1
- package/README.md +3 -13
- package/dotpi_root/bin/dotpi +1 -0
- package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
- package/dotpi_root/bin/dotpi_prepare_system +113 -68
- package/dotpi_root/bin/package.json +6 -0
- package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
- package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
- package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
- package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
- package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
- package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
- package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
- package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
- package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
- package/dotpi_root/dist/@dotpi/module/package.json +22 -0
- package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
- package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
- package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
- package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
- package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
- package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
- package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
- package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
- package/dotpi_root/etc/dotpi_modules.json +8 -0
- package/dotpi_root/lib/package.json +6 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
- package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
- package/dotpi_root/share/dotpi_functions.bash +4 -4
- package/dotpi_root/share/dotpi_init.bash +10 -1
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +86 -0
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +24 -0
- package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire.service +22 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire_command +29 -0
- package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
- package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
- package/lerna.json +4 -0
- package/package.json +12 -2
- package/projects/asterismes.tgz +0 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_001.bash~ +4 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_002.bash~ +3 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_project.bash~ +46 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_001.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_002.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_project.bash +48 -0
- package/projects/example-development/configuration/.editorbackup/dotpi_project.bash~ +59 -0
- package/projects/example-development/configuration/dotpi_instance_114.bash +4 -0
- package/projects/example-headphones/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_instance_012.bash~ +4 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-network/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/led-test/.dotpi +3 -0
- package/projects/led-test/README.md +16 -0
- package/projects/led-test/dotpi_project.bash +29 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bad/.editorbackup/dotpi_project.bash~ +33 -0
- package/projects/old/bad/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bad/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bad/dotpi_project.bash +20 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bluetooth/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bluetooth/dotpi_project.bash +29 -0
- package/projects/old/dev.zip +0 -0
- package/projects/old/example/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/example/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/example/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/example/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/example/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/configuration/dotpi_project.bash +21 -0
- package/projects/qsddsqsd/.dotpi +3 -0
- package/projects/qsddsqsd/README.md +16 -0
- package/projects/qsddsqsd/dotpi_project.bash +29 -0
- package/src/constants.js +4 -4
- package/src/create-project.js +124 -56
- package/src/templates/dotpi_project.bash +5 -7
- package/src/utils.js +2 -2
- package/test/create-project.test.js +0 -1
- package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
- package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
- package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
- package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
- package/dotpi_root/share/jackd/jackd.service +0 -22
- /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
|
@@ -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)" =~
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
#############
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
##############
|
|
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
|
|
168
|
-
# copy with prefix
|
|
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="
|
|
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,69 +231,60 @@ 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"
|
|
183
258
|
# do not exit
|
|
184
259
|
}
|
|
185
260
|
|
|
186
|
-
|
|
187
|
-
|
|
261
|
+
"${DOTPI_ROOT}/share/dotpi_pipewire/dotpi_install" || {
|
|
262
|
+
dotpi echo_error "error while installing dotpi_pipewire: ${?}"
|
|
263
|
+
# do not exit
|
|
264
|
+
}
|
|
188
265
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
sudo mkdir -p -- "$destination" || {
|
|
192
|
-
error_exit $? "dotpi-manager: mkdir ${destination}" $error_exit_code_dotpi_manager
|
|
193
|
-
}
|
|
194
|
-
cd -- "$destination" || {
|
|
195
|
-
error_exit $? "dotpi-manager: cd ${destination}" $error_exit_code_dotpi_manager
|
|
196
|
-
}
|
|
266
|
+
############## dotpi modules
|
|
267
|
+
error_exit_code_dotpi_modules=10
|
|
197
268
|
|
|
198
|
-
destination_runtime="${destination}/runtime"
|
|
199
|
-
sudo rm -rf -- "$destination_runtime" || {
|
|
200
|
-
error_exit $? "dotpi-manager: rm ${destination_runtime}" $error_exit_code_dotpi_manager
|
|
201
|
-
}
|
|
202
|
-
sudo git clone --depth=1 https://github.com/ircam-ismm/dotpi-manager.git "$destination_runtime" || {
|
|
203
|
-
error_exit $? "dotpi-manager: git clone" $error_exit_code_dotpi_manager
|
|
204
|
-
}
|
|
205
|
-
# bootstrap-install
|
|
206
|
-
sudo bash -c "\
|
|
207
|
-
source '${DOTPI_ROOT}/share/dotpi_init.bash' && \
|
|
208
|
-
source runtime/dotpi/dotpi-manager.bash && \
|
|
209
|
-
dotpi_manager_update \
|
|
210
|
-
" || {
|
|
211
|
-
error_exit $? "dotpi_manager_update" $error_exit_code_dotpi_manager
|
|
212
|
-
}
|
|
213
|
-
) fi
|
|
214
269
|
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
274
|
+
|
|
275
|
+
dotpi echo_info "Uninstall dotpi modules packages:" "${!dotpi_module_uninstall_modules[@]}"
|
|
276
|
+
sudo dotpi module uninstall "${!dotpi_module_uninstall_modules[@]}"
|
|
217
277
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
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
|
|
226
285
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
error_exit $? "dotpi-led: rm ${destination_runtime}" $error_exit_code_dotpi_led
|
|
230
|
-
}
|
|
231
|
-
sudo git clone --depth=1 https://github.com/ircam-ismm/dotpi-led.git "$destination_runtime" || {
|
|
232
|
-
error_exit $? "dotpi-led: git clone" $error_exit_code_dotpi_led
|
|
233
|
-
}
|
|
234
|
-
# bootstrap-install
|
|
235
|
-
sudo bash -c "\
|
|
236
|
-
source '${DOTPI_ROOT}/share/dotpi_init.bash' && \
|
|
237
|
-
source runtime/dotpi/dotpi-led.bash && \
|
|
238
|
-
dotpi_led_update \
|
|
239
|
-
" || {
|
|
240
|
-
error_exit $? "dotpi-led: dotpi_led_update" $error_exit_code_dotpi_led
|
|
241
|
-
}
|
|
242
|
-
) fi
|
|
286
|
+
dotpi echo_info "Install dotpi modules packages:" "${!dotpi_module_install_modules[@]}"
|
|
287
|
+
sudo dotpi module install "${!dotpi_module_install_modules[@]}"
|
|
243
288
|
|
|
244
289
|
############## finalisation
|
|
245
290
|
|
|
@@ -4,11 +4,7 @@ After=avahi-daemon.service
|
|
|
4
4
|
|
|
5
5
|
[Service]
|
|
6
6
|
Type=exec
|
|
7
|
-
|
|
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,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,49 @@
|
|
|
1
|
+
import { $ } from 'execa';
|
|
2
|
+
|
|
3
|
+
export async function install({
|
|
4
|
+
user = false,
|
|
5
|
+
file,
|
|
6
|
+
} = {}) {
|
|
7
|
+
if (process.getuid() !== 0) {
|
|
8
|
+
// even a user service must be installed by root
|
|
9
|
+
throw new Error('Only the root user can install a service');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const output = await $({
|
|
14
|
+
shell: '/bin/bash', // for dotpi environment
|
|
15
|
+
env: { FORCE_COLOR: 'true' }, // do not remove colors
|
|
16
|
+
all: true, // interleave stdout and stderr
|
|
17
|
+
})`dotpi service-install ${user ? '--user' : ''} ${file}`;
|
|
18
|
+
|
|
19
|
+
return output;
|
|
20
|
+
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function uninstall({
|
|
28
|
+
user = false,
|
|
29
|
+
name,
|
|
30
|
+
} = {}) {
|
|
31
|
+
if (process.getuid() !== 0) {
|
|
32
|
+
// even a user service must be installed by root
|
|
33
|
+
throw new Error('Only the root user can uninstall a service');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const output = await $({
|
|
38
|
+
shell: '/bin/bash', // for dotpi environment
|
|
39
|
+
env: { FORCE_COLOR: 'true' }, // do not remove colors
|
|
40
|
+
all: true, // interleave stdout and stderr
|
|
41
|
+
})`dotpi service-uninstall ${user ? '--user' : ''} ${name}`;
|
|
42
|
+
|
|
43
|
+
return output;
|
|
44
|
+
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import{ $ } from 'execa';
|
|
3
|
+
|
|
4
|
+
import { regularUserIdGet } from './user.js';
|
|
5
|
+
import { variableRead } from './bash.js';
|
|
6
|
+
|
|
7
|
+
export const dotpiRootDefault = '/opt/dotpi';
|
|
8
|
+
|
|
9
|
+
export async function dotpiRootGet() {
|
|
10
|
+
|
|
11
|
+
let dotpiRoot = process.env.DOTPI_ROOT;
|
|
12
|
+
if (!dotpiRoot) {
|
|
13
|
+
const uid = regularUserIdGet();
|
|
14
|
+
dotpiRoot = await variableRead({ uid, variable: 'DOTPI_ROOT' });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!dotpiRoot) {
|
|
18
|
+
try {
|
|
19
|
+
await fs.access(dotpiRootDefault);
|
|
20
|
+
dotpiRoot = dotpiRootDefault;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error(`DOTPI_ROOT not set and ${dotpiRootDefault} not found`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return dotpiRoot;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function isRaspberryPi() {
|
|
30
|
+
try {
|
|
31
|
+
const output = await $`dotpi system_is_raspberry_pi`;
|
|
32
|
+
return output.exitCode === 0;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|