@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
@@ -1,425 +0,0 @@
1
- #!/bin/bash
2
-
3
- set +e
4
-
5
- _dotpi_command="$(basename "$0")"
6
-
7
-
8
- dotpi_echo_error() {
9
- printf 'ERROR: %s\n' "$1" >&2
10
- }
11
-
12
- dotpi_echo_warning() {
13
- printf 'WARNING: %s\n' "$1" >&2
14
- }
15
-
16
- _dotpi_usage() {
17
- echo "Usage: ${_dotpi_command} --project <project_path>"
18
- }
19
-
20
- _echo_empty_option_error() {
21
- dotpi_echo_error "$1 requires a non-empty option argument."
22
- }
23
-
24
- while true ; do
25
- case $1 in
26
-
27
- -h|-\?|--help)
28
- _dotpi_usage # Display a usage synopsis.
29
- exit 0
30
- ;;
31
-
32
- -p|--project) # Takes an option argument; ensure it has been specified.
33
- if [ -z "$2" ] ; then
34
- _echo_empty_option_error "$1"
35
- _dotpi_usage
36
- exit 1
37
- else
38
- project="$2"
39
- shift
40
- fi
41
- ;;
42
-
43
- --) # End of all options.
44
- shift
45
- break
46
- ;;
47
-
48
- -?*) # Unknown
49
- dotpi_echo_error "Unknown option: $1"
50
- _dotpi_usage
51
- exit 1
52
- ;;
53
-
54
- *) # Default case: No more options, so break out of the loop.
55
- break
56
-
57
- esac
58
-
59
- shift
60
- done
61
-
62
- if [ -z ${project+x} ] ; then
63
- dotpi_echo_error "missing project option"
64
- _dotpi_usage
65
- exit 1
66
- fi
67
-
68
- project_path="$( (cd "$project" && pwd) 2> /dev/null || {
69
- dotpi_echo_error "unable to access project ${project}"
70
- } )"
71
- if [ -z "$project_path" ] ; then
72
- exit 1
73
- fi
74
-
75
- local_path="$( (cd "$(dirname "$0")" && pwd) 2> /dev/null || {
76
- dotpi_echo_error "unable to access local path $(dirname "$0")"
77
- } )"
78
- if [ -z "$local_path" ] ; then
79
- exit 1
80
- fi
81
-
82
- # script in "bin"
83
- DOTPI_ROOT="${local_path}/.."
84
-
85
- tmp_path="${project_path}/tmp"
86
- mkdir -p "$tmp_path"
87
-
88
- file_system_mirror="${tmp_path}/file-system"
89
- rm -rf "$file_system_mirror"
90
- mkdir -p "$file_system_mirror"
91
-
92
- echo "# file-system mirror: ${file_system_mirror}"
93
-
94
- tar_options=()
95
- while read pattern ; do
96
-
97
- # avoid empty pattern
98
- if [ -z "$pattern" ] ; then
99
- continue
100
- fi
101
-
102
- tar_options+=( '--exclude' "${pattern}" )
103
- done < "${DOTPI_ROOT}/etc/dotpi_tarignore"
104
-
105
- # regular files only
106
- if [[ "$(uname)" == "Darwin" ]] ; then
107
- tar_options+=( '--no-mac-metadata' )
108
- fi
109
- tar_options+=( '--no-xattrs' )
110
-
111
- source_path="$DOTPI_ROOT"
112
- destination_path="${file_system_mirror}/opt/dotpi"
113
- mkdir -p "$destination_path"
114
- (set -o pipefail ; \
115
- cd "$source_path" && tar c "${tar_options[@]}" '.' \
116
- | tar x -C "$destination_path") || {
117
- dotpi_echo_error "Error while copying defaults from ${source_path} to ${destination_path}"
118
- exit 1
119
- }
120
-
121
- source_path="$project_path"
122
- destination_path="${file_system_mirror}/opt/dotpi/etc"
123
- mkdir -p "$destination_path"
124
- source_file_path="${source_path}/dotpi_project.bash"
125
- destination_file_path="${destination_path}/dotpi_environment_project.bash"
126
- if [ -r "$source_file_path" ] ; then
127
- cp "$source_file_path" "$destination_file_path"
128
- fi
129
-
130
- ####################################################
131
- # mirror should be complete, now: switch to mirror #
132
- ####################################################
133
-
134
- DOTPI_ROOT="${file_system_mirror}/opt/dotpi"
135
- source "${DOTPI_ROOT}/share/dotpi_init.bash"
136
-
137
- ######## read extra files
138
-
139
- ### tmp for instance number
140
-
141
- # keep reference of file to increment at the end
142
- environment_tmp_file="${tmp_path}/dotpi_tmp.bash"
143
- dotpi_source_if_available "$environment_tmp_file"
144
- if [ -z "$dotpi_instance_number" ] ; then
145
- dotpi_instance_number=1
146
- fi
147
-
148
- echo '####################################################'
149
- echo ''
150
- echo "please type instance number, or type enter for ${dotpi_instance_number}"
151
-
152
- read user_instance_number
153
- if [ -n "$user_instance_number" ] ; then
154
- dotpi_instance_number="${user_instance_number}"
155
- fi
156
-
157
- echo ''
158
- echo '####################################################'
159
-
160
- if [ -z "$dotpi_hostname_prefix" ] ; then
161
- dotpi_echo_error "Bad dotpi_hostname_prefix: ${dotpi_hostname_prefix}"
162
- echo "Check ${project_path}/dotpi_project.bash"
163
- exit 1
164
- fi
165
-
166
- dotpi_instance_hostname="${dotpi_hostname_prefix}$(printf %03d ${dotpi_instance_number})"
167
- if (( $? != 0 )) ; then
168
- dotpi_echo_error "Bad dotpi_instance_number: ${dotpi_instance_number}"
169
- exit 1
170
- fi
171
- dotpi_echo_info "hostname is ${dotpi_instance_hostname}"
172
-
173
- destination_file="${DOTPI_ROOT}/etc/dotpi_environment_instance.bash"
174
- dotpi_configuration_write --file "$destination_file" --key 'dotpi_instance_number' --value "$dotpi_instance_number"
175
- dotpi_configuration_write --file "$destination_file" --key 'dotpi_instance_hostname' --value "$dotpi_instance_hostname"
176
-
177
-
178
- ### secrets for password
179
-
180
- source_file="${project_path}/secrets/dotpi_secrets.bash"
181
- destination_file="${DOTPI_ROOT}/etc/dotpi_environment_project.bash"
182
- if ! [ -r "$source_file" ] ; then
183
- dotpi_echo_error "unable to read secrets file ${source_file}"
184
- exit 1
185
- else
186
- source "$source_file"
187
-
188
- if [ -z "$dotpi_password" ] ; then
189
- dotpi_echo_warning "no password provided in ${source_file}, use default"
190
- else
191
- hash6="$(openssl passwd -6 "$dotpi_password")"
192
- dotpi_configuration_write --file "$destination_file" --key 'dotpi_password_hash6' --value "$hash6"
193
- fi
194
- fi
195
-
196
- ### secrets for ssh public keys
197
-
198
- source_path="${project_path}/secrets/ssh"
199
- destination_path="${DOTPI_ROOT}/etc/ssh"
200
- mkdir -p "$destination_path"
201
- if [ -d "$source_path" ] && [ -r "$source_path" ] ; then
202
- (set -o pipefail ; \
203
- cd "$source_path" && tar c "${tar_options[@]}" *.pub \
204
- | tar x -C "$destination_path") || {
205
- dotpi_echo_error "No public key found in ${source_path}"
206
- exit 1
207
- }
208
- fi
209
-
210
- ### secrets for NetworkManager connections from project
211
-
212
- source_path="${project_path}/secrets/network"
213
- destination_path="${DOTPI_ROOT}/etc/network"
214
- mkdir -p "$destination_path"
215
- if [ -d "$source_path" ] && [ -r "$source_path" ] ; then
216
- (set -o pipefail ; \
217
- cd "$source_path" && tar c "${tar_options[@]}" *.nmconnection \
218
- | tar x -C "$destination_path") || {
219
- dotpi_echo_error "No network connection found in ${source_path}"
220
- exit 1
221
- }
222
- fi
223
-
224
- # update connections in DOTPI_ROOT
225
-
226
- if ! $(wpa_passphrase test 12345678 > /dev/null 2>&1) ; then
227
- dotpi_echo_warning "wpa_passphrase is needed to salt passwords."
228
- else
229
-
230
- for file in "${destination_path}"/*.nmconnection ; do
231
- key='wifi-security.psk'
232
- psk="$(dotpi_connection_read --file "$file" --key "$key")"
233
-
234
- # not salted
235
- if (( ${#psk} < 64 )) ; then
236
- key='wifi.ssid'
237
- ssid="$(dotpi_connection_read --file "$file" --key "$key")"
238
- passphrase="$(wpa_passphrase "$ssid" "$psk" | dotpi_configuration_read --key 'psk' )"
239
- key='wifi-security.psk'
240
- dotpi_connection_write --file "$file" --key "$key" --value "$passphrase"
241
- fi
242
-
243
- done
244
- fi
245
-
246
-
247
- ######## SD card
248
-
249
- bootfs_name="bootfs"
250
-
251
- if [[ "$(uname)" != "Darwin" ]] ; then
252
- echo ""
253
- echo "############################################################"
254
- echo ""
255
- echo " This script is for MacOS (Darwin) only."
256
- echo " Please adapt it for you environment and send you feedback."
257
- echo ""
258
- echo "############################################################"
259
- echo ""
260
- exit 1
261
- fi
262
-
263
- bootfs_path="/Volumes/${bootfs_name}"
264
-
265
- # try to mount if unmounted (but not ejected)
266
- if [ -x $(which diskutil) ] ; then
267
- diskutil mount "$bootfs_name"
268
- fi
269
-
270
- if [ ! -d "$bootfs_path" ] ; then
271
- echo "############################################################"
272
- echo ""
273
- echo " Please mount SD card and try again."
274
- echo ""
275
- echo "############################################################"
276
- echo ""
277
- exit 1
278
- fi
279
-
280
-
281
- ######### config.txt
282
-
283
- config_filename='config.txt'
284
- config_file="${project}/${config_filename}"
285
- destination_path="${DOTPI_ROOT}/etc"
286
-
287
- mkdir -p "$destination_path"
288
-
289
- if [ -r "$config_file" ] ; then
290
- echo "using project config file ${config_file}"
291
- else
292
- config_file="${bootfs_path}/${config_filename}"
293
- echo "# copy config file from imager"
294
- fi
295
-
296
- cp "$config_file" "$destination_path"
297
-
298
- config_file="${destination_path}/${config_filename}"
299
-
300
- echo "# editing ${config_file}"
301
-
302
- # keep quotes here to keep quotes hereafter
303
- cat >> "${config_file}" << EOF
304
-
305
- ############
306
- # dotpi
307
- #
308
-
309
- [all]
310
-
311
- EOF
312
-
313
- if [[ "$dotpi_word_size" == "32" ]] ; then
314
- word_size="$(dotpi_file_word_size "${bootfs_path}/start.elf" )"
315
- if [[ "$word_size" == "32" ]] ; then
316
-
317
- file="$config_file"
318
- key="arm_64bits"
319
-
320
- # comment original value
321
- dotpi_configuration_comment --file "$file" --key "$key"
322
- dotpi_configuration_write \
323
- --file "$file" --key "$key" \
324
- --value "0" --prepend-line-if-new '# true 32bit system'
325
- fi
326
- fi
327
-
328
- ######### sound-card
329
-
330
- dotpi_soundcard_select --model "$dotpi_soundcard" --config "$config_file"
331
-
332
-
333
- # back-up imager config
334
-
335
- destination_filename="imager_${config_filename}"
336
-
337
- # install config.txt to /boot to be ready for first run
338
- cp "$config_file" "$bootfs_path"
339
-
340
- ######### configure first run
341
-
342
- echo "# set-up first run"
343
-
344
- source_file_path="${bootfs_path}/firstrun.sh"
345
- if [ -f "$source_file_path" ] ; then
346
- # back-up imager firstrun.sh
347
-
348
- destination_filename='imager_firstrun.sh'
349
-
350
- # keep a copy on bootfs
351
- destination_path="${bootfs_path}/dotpi"
352
- mkdir -p "$destination_path"
353
-
354
- if [ -r "${destination_path}/${destination_filename}" ] ; then
355
- dotpi_echo_warning "Keep existing imager first-run script: ${destination_path}/${destination_filename}"
356
- else
357
- cp "$source_file_path" "${destination_path}/${destination_filename}"
358
-
359
- destination_path="${DOTPI_ROOT}/etc"
360
- mkdir -p "$destination_path"
361
- cp "$source_file_path" "${destination_path}/${destination_filename}"
362
- fi
363
-
364
- fi
365
-
366
- # replace first run with custom, that will over-ride imager settings
367
- # run dotpi_firstrun.bash
368
- cat > "${bootfs_path}/firstrun.sh" << "EOF"
369
- #!/bin/bash
370
-
371
- set +e
372
-
373
- # since Raspberry Pi OS Bookworm
374
- local_path='/boot/firmware'
375
-
376
- if ! [ -d "$local_path" ] ; then
377
- # for Raspberry Pi OS Bullseye
378
- local_path='/boot'
379
- fi
380
-
381
- clean_up() {
382
- rm -f "${local_path}/firstrun.sh"
383
- sed -i 's| systemd.run.*||g' "${local_path}/cmdline.txt"
384
- }
385
-
386
- (cd / && tar xz -m --no-same-owner --no-same-permissions --no-overwrite-dir -f "${local_path}/dotpi/file_system.tgz")
387
-
388
- source_path="/opt/dotpi"
389
- cd "$source_path" || { clean_up ; exit 1; }
390
- "bin/dotpi_firstrun.bash"
391
-
392
- clean_up
393
-
394
- exit 0
395
-
396
- EOF
397
-
398
-
399
- ########## archive mirror to bootfs
400
-
401
- echo "# archive mirror"
402
-
403
- source_path="$file_system_mirror"
404
- destination_path="${bootfs_path}/dotpi"
405
- mkdir -p "$destination_path"
406
-
407
- # create archive for installing, later
408
- # this overcomes the limitiations of the FAT32 boot volume
409
- tar cz "${tar_options[@]}" -C "${source_path}" '.' > "${destination_path}/file_system.tgz"
410
-
411
- # try to mount if unmounted (but not ejected)
412
- if [ -x $(type -P diskutil) ] ; then
413
- diskutil umount "$bootfs_name" || :
414
- fi
415
-
416
- dotpi_echo_info "Mirror of file-system is here: ${file_system_mirror}"
417
-
418
- (( dotpi_instance_number++ ))
419
- dotpi_configuration_write --file "$environment_tmp_file" --key dotpi_instance_number --value "$dotpi_instance_number"
420
-
421
- echo "####################################################"
422
- echo ""
423
- echo " Please put SD card in Raspberry Pi and power on."
424
- echo ""
425
- echo "####################################################"