@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,428 +0,0 @@
1
- #!/bin/bash
2
-
3
- _dotpi_configuration_get_options() {
4
-
5
- _echo_empty_option_error() {
6
- dotpi_echo_error "$1 requires a non-empty option argument."
7
- }
8
-
9
- # From http://mywiki.wooledge.org/BashFAQ/035
10
-
11
- while true ; do
12
- case $1 in
13
-
14
- -h|-\?|--help)
15
- _dotpi_usage # Display a usage synopsis.
16
- return 0
17
- ;;
18
-
19
- -f|--file) # Takes an option argument; ensure it has been specified.
20
- if [ -z "$2" ] ; then
21
- _dotpi_usage
22
- _echo_empty_option_error "$1"
23
- return 1
24
- else
25
- file="$2"
26
- shift
27
- fi
28
- ;;
29
-
30
- -k|--key)
31
- if [ -z "$2" ] ; then
32
- _dotpi_usage
33
- _echo_empty_option_error "$1"
34
- return 1
35
- else
36
- key="$2"
37
- shift
38
- fi
39
- ;;
40
-
41
- -p|--prefix)
42
- if [ -z "$2" ] ; then
43
- _dotpi_usage
44
- _echo_empty_option_error "$1"
45
- return 1
46
- else
47
- prefix="$2"
48
- shift
49
- fi
50
- ;;
51
-
52
- -N|--prepend-line-if-new)
53
- if [ -z "$2" ] ; then
54
- _dotpi_usage
55
- _echo_empty_option_error "$1"
56
- return 1
57
- else
58
- prepend_line_if_new="$2"
59
- shift
60
- fi
61
- ;;
62
-
63
- -v|--value)
64
- if [ -z "$2" ] ; then
65
- _dotpi_usage
66
- _echo_empty_option_error "$1"
67
- return 1
68
- else
69
- value="$2"
70
- shift
71
- fi
72
- ;;
73
-
74
- --) # End of all options.
75
- shift
76
- break
77
- ;;
78
-
79
- -?*) # Unknown
80
- _dotpi_usage
81
- dotpi_echo_error "Unknown option: $1"
82
- return 1
83
- ;;
84
-
85
- *) # Default case: No more options, so break out of the loop.
86
- break
87
-
88
- esac
89
-
90
- shift
91
- done
92
-
93
- }
94
-
95
- dotpi_configuration_escape_string() (
96
- # escape ' " / \ $
97
- echo "$(echo "$1" | perl -pe 's#(['\''"/\\\$])#\\${1}#g')"
98
- )
99
-
100
- dotpi_configuration_get_pattern() (
101
- # sub-shell to keep everything local (functions and variables)
102
-
103
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
104
- _dotpi_usage() {
105
- echo "Usage: ${_dotpi_command} --key <key>"
106
- echo "Usage: ${_dotpi_command} --prefix <prefix>"
107
- }
108
-
109
- # Initialize all the option variables.
110
- # This ensures we are not contaminated by variables from the environment.
111
- key=
112
- if ! _dotpi_configuration_get_options "${@}" ; then
113
- return $?
114
- fi
115
-
116
- if [ -z "$key" ] && [ -z "$prefix" ] ; then
117
- _dotpi_usage
118
- dotpi_echo_error "key or prefix is required"
119
- return 1
120
- fi
121
-
122
-
123
- if [ -n "$key" ] ; then
124
- # [<leading>] <key> <assignment> <value> [ <values>] [<trailing>]
125
-
126
- # start of line, and spaces
127
- # invert for no comment, no non-spaces
128
- _dotpi_configuration_pattern_leading='(^[^#\S]*)'
129
-
130
- # escape
131
- key_escaped="$(dotpi_configuration_escape_string "$key")"
132
- # group and disable pattern metacharacters
133
- _dotpi_configuration_pattern_key="(${key_escaped})"
134
-
135
- # = with surrounding spaces
136
- _dotpi_configuration_pattern_assignment='(\s*=\s*)'
137
-
138
- # value is a repetition of non-space characters
139
- # invert for no comment, no space
140
- _dotpi_configuration_pattern_value='([^#\s]+)'
141
-
142
- # optional value containing spaces (terminated with a non-space)
143
- _dotpi_configuration_pattern_value_with_spaces='((\s+[^#\s]+)*)'
144
-
145
- # trailing spaces and trailing comments until the end of line
146
- # (including the end of line)
147
- _dotpi_configuration_pattern_trailing='(\s*#?.*$)'
148
-
149
- echo "\
150
- $_dotpi_configuration_pattern_leading\
151
- $_dotpi_configuration_pattern_key\
152
- $_dotpi_configuration_pattern_assignment\
153
- $_dotpi_configuration_pattern_value\
154
- $_dotpi_configuration_pattern_value_with_spaces\
155
- $_dotpi_configuration_pattern_trailing\
156
- "
157
- elif [ -n "$prefix" ] ; then
158
- # [<leading>] <prefix> [<trailing>]
159
-
160
- # start of line, and spaces
161
- # invert for no comment, no non-spaces
162
- _dotpi_configuration_pattern_leading='(^[^#\S]*)'
163
-
164
- # escape
165
- prefix_escaped="$(dotpi_configuration_escape_string "$prefix")"
166
- # group and disable pattern metacharacters
167
- _dotpi_configuration_pattern_prefix="(${prefix_escaped})"
168
-
169
- # anything until the end of line
170
- # (including the end of line)
171
- _dotpi_configuration_pattern_trailing='(.*$)'
172
-
173
- echo "\
174
- $_dotpi_configuration_pattern_leading\
175
- $_dotpi_configuration_pattern_prefix\
176
- $_dotpi_configuration_pattern_trailing\
177
- "
178
-
179
- fi
180
-
181
- return 0
182
- )
183
-
184
- dotpi_configuration_comment() (
185
- # sub-shell to keep everything local (functions and variables)
186
-
187
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
188
- _dotpi_usage() {
189
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
190
- }
191
-
192
- # Initialize all the option variables.
193
- # This ensures we are not contaminated by variables from the environment.
194
- file=
195
- key=
196
- if ! _dotpi_configuration_get_options "${@}" ; then
197
- return $?
198
- fi
199
-
200
- if [ -z "$key" ] ; then
201
- _dotpi_usage
202
- dotpi_echo_error "missing key option"
203
- return 1
204
- fi
205
-
206
- perl_options=()
207
- if [ -n "$file" ] ; then
208
- perl_options+=( '-i' "$file" )
209
- fi
210
-
211
- pattern="$(dotpi_configuration_get_pattern --key "$key")"
212
- # keep leading spaces, and trailing (including end of line)
213
- perl -pe "s/${pattern}/"'${1}# ${2}${3}${4}${5}${7}/' "${perl_options[@]}"
214
- return $?
215
- )
216
-
217
- dotpi_configuration_write() (
218
- # sub-shell to keep everything local (functions and variables)
219
-
220
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
221
- _dotpi_usage() {
222
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key> --value <value>"
223
- }
224
-
225
- # Initialize all the option variables.
226
- # This ensures we are not contaminated by variables from the environment.
227
- file=
228
- key=
229
- value=
230
- prepend_line_if_new=
231
- if ! _dotpi_configuration_get_options "${@}" ; then
232
- return $?
233
- fi
234
-
235
- if [ -z "$key" ] ; then
236
- _dotpi_usage
237
- dotpi_echo_error "missing key option"
238
- return 1
239
- fi
240
-
241
- if [ -z "$value" ] ; then
242
- _dotpi_usage
243
- dotpi_echo_error "missing value option"
244
- return 1
245
- fi
246
-
247
- if [ -n "$file" ] ; then
248
- if ! [ -r "$file" ] ; then
249
- touch "$file"
250
- fi
251
- else
252
- input_file='/dev/stdin'
253
- output_file='/dev/stdout'
254
- fi
255
-
256
- pattern="$(dotpi_configuration_get_pattern --key "$key")"
257
- value_escaped="$(dotpi_configuration_escape_string "$value")"
258
- # trailing includes the end of line
259
- perl_command=('perl' '-pe' "s/${pattern}/"'${1}${2}${3}'"${value_escaped}"'${7}/')
260
-
261
- find_command=('dotpi_configuration_find' '--key' "$key")
262
-
263
- if [ -n "$file" ] ; then
264
- "${perl_command[@]}" -i "$file"
265
- found=$( "${find_command[@]}" --file "$file" )
266
- output_file="$file"
267
- else
268
- # duplicate stdout
269
- "${perl_command[@]}" 3>&1 ; found=$( "${find_command[@]}" <3 )
270
- fi
271
-
272
- if (( found == 0 )) ; then
273
- if [ -n "$prepend_line_if_new" ] ; then
274
- echo "$prepend_line_if_new" >> "$output_file"
275
- fi
276
- echo "${key}=${value_escaped}" >> "$output_file"
277
- fi
278
-
279
-
280
- return $?
281
- )
282
-
283
- dotpi_configuration_read() (
284
- # sub-shell to keep everything local (functions and variables)
285
-
286
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
287
- _dotpi_usage() {
288
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
289
- }
290
-
291
- # Initialize all the option variables.
292
- # This ensures we are not contaminated by variables from the environment.
293
- file=
294
- key=
295
- if ! _dotpi_configuration_get_options "${@}" ; then
296
- return $?
297
- fi
298
-
299
- if [ -z "$key" ] ; then
300
- _dotpi_usage
301
- dotpi_echo_error "missing key option"
302
- return 1
303
- fi
304
-
305
- perl_options=()
306
- if [ -n "$file" ] ; then
307
- if ! [ -r "$file" ] ; then
308
- dotpi_echo_error "${file} is not readable"
309
- return 1 # false
310
- fi
311
-
312
- perl_options+=( "$file" )
313
- fi
314
-
315
- pattern="$(dotpi_configuration_get_pattern --key "$key")"
316
-
317
- values=()
318
- # split values with new line, keep spaces
319
- while IFS= read -r line ; do
320
- values+="$line"
321
- done < <(perl -ne 'if (m/'"$pattern"'/) { print "${4}${5}\n" }' "${perl_options[@]}" )
322
-
323
- if (( ${#values} == 0 )) ; then
324
- return 1 # false
325
- else
326
- # last instance
327
- echo "${values[@]: -1}"
328
- return 0 # true
329
- fi
330
- )
331
-
332
- dotpi_configuration_find() (
333
- # sub-shell to keep everything local (functions and variables)
334
-
335
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
336
- _dotpi_usage() {
337
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
338
- }
339
-
340
- # Initialize all the option variables.
341
- # This ensures we are not contaminated by variables from the environment.
342
- file=
343
- key=
344
- if ! _dotpi_configuration_get_options "${@}" ; then
345
- return $?
346
- fi
347
-
348
- if [ -z "$key" ] ; then
349
- _dotpi_usage
350
- dotpi_echo_error "missing key option"
351
- return 1
352
- fi
353
-
354
- read_options=()
355
- if [ -n "$file" ] ; then
356
- read_options+=( '--file' "$file" )
357
- fi
358
-
359
- dotpi_configuration_read --key "$key" "${read_options[@]}" > /dev/null
360
- return_value=$?
361
- # 0 is true
362
- echo $(( !return_value ))
363
- return $return_value
364
- )
365
-
366
- dotpi_configuration_delete() (
367
- # sub-shell to keep everything local (functions and variables)
368
-
369
- _dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
370
- _dotpi_usage() {
371
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
372
- }
373
-
374
- # Initialize all the option variables.
375
- # This ensures we are not contaminated by variables from the environment.
376
- file=
377
- key=
378
- if ! _dotpi_configuration_get_options "${@}" ; then
379
- return $?
380
- fi
381
-
382
- if [ -z "$key" ] ; then
383
- _dotpi_usage
384
- dotpi_echo_error "missing key option"
385
- return 1
386
- fi
387
-
388
- perl_options=()
389
-
390
- if [ -n "$file" ] ; then
391
- if ! [ -r "$file" ] ; then
392
- dotpi_echo_error "${file} is not readable"
393
- return 1 # false
394
- fi
395
-
396
- perl_options+=( '-i' "$file" )
397
- fi
398
-
399
- pattern="$(dotpi_configuration_get_pattern --key "$key")"
400
-
401
- perl -ne 'if (! m/'"${pattern}"'/) { print "$_" }' "${perl_options[@]}"
402
-
403
- return $?
404
- )
405
-
406
- dotpi_configuration_replace_region() {
407
- command_name="${FUNCNAME[0]}"
408
- if (( ${#} < 3 )) ; then
409
- echo "Usage: ${command_name} <start_string> <end_string> <substitution> [<file>]"
410
- dotpi_echo_error "${command_name} needs at least 3 arguments"
411
- return 1
412
- fi
413
-
414
-
415
- local start="$(dotpi_configuration_escape_string "$1")"
416
- local end="$(dotpi_configuration_escape_string "$2")"
417
- local substitution="$(dotpi_configuration_escape_string "$3")"
418
- local file="$4"
419
-
420
- local perl_options=()
421
- if [ -n "$file" ] ; then
422
- perl_options+=( '-i' "$file" )
423
- fi
424
-
425
- perl -p0e 's/'"$start"'.*?'"$end"'/'"$substitution"'/smg' "${perl_options[@]}"
426
-
427
- return $?
428
- }
@@ -1,194 +0,0 @@
1
- _dotpi_connection_get_options() {
2
-
3
- _echo_empty_option_error() {
4
- dotpi_echo_error "$1 requires a non-empty option argument."
5
- }
6
-
7
- # From http://mywiki.wooledge.org/BashFAQ/035
8
-
9
- while true ; do
10
- case $1 in
11
-
12
- -h|-\?|--help)
13
- _dotpi_usage # Display a usage synopsis.
14
- return 0
15
- ;;
16
-
17
- -f|--file) # Takes an option argument; ensure it has been specified.
18
- if [ -z "$2" ] ; then
19
- _dotpi_usage
20
- _echo_empty_option_error "$1"
21
- return 1
22
- else
23
- file="$2"
24
- shift
25
- fi
26
- ;;
27
-
28
- -k|--key)
29
- if [ -z "$2" ] ; then
30
- _dotpi_usage
31
- _echo_empty_option_error "$1"
32
- return 1
33
- else
34
- key="$2"
35
- shift
36
- fi
37
- ;;
38
-
39
- -v|--value)
40
- if [ -z "$2" ] ; then
41
- _dotpi_usage
42
- _echo_empty_option_error "$1"
43
- return 1
44
- else
45
- value="$2"
46
- shift
47
- fi
48
- ;;
49
-
50
- --) # End of all options.
51
- shift
52
- break
53
- ;;
54
-
55
- -?*) # Unknown
56
- _dotpi_usage
57
- dotpi_echo_error "Unknown option: $1"
58
- return 1
59
- ;;
60
-
61
- *) # Default case: No more options, so break out of the loop.
62
- break
63
-
64
- esac
65
-
66
- shift
67
- done
68
-
69
- }
70
-
71
- dotpi_connection_write() (
72
- # sub-shell to keep everything local (functions and variables)
73
-
74
- _dotpi_command="$(basename "${FUNCNAME[0]:-"$0"}")"
75
- _dotpi_usage() {
76
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key> --value <value>"
77
- }
78
-
79
- # Initialize all the option variables.
80
- # This ensures we are not contaminated by variables from the environment.
81
- file=
82
- key=
83
- value=
84
- prepend_line_if_new=
85
- if ! _dotpi_connection_get_options "${@}" ; then
86
- return $?
87
- fi
88
-
89
- if [ -z "$key" ] ; then
90
- _dotpi_usage
91
- dotpi_echo_error "missing key option"
92
- return 1
93
- fi
94
-
95
- if [ -z "$value" ] ; then
96
- _dotpi_usage
97
- dotpi_echo_error "missing value option"
98
- return 1
99
- fi
100
-
101
- if [ -z "$file" ] ; then
102
- dotpi_echo_error "missing file option"
103
- return 1
104
- fi
105
-
106
- git config --file "$file" "$key" "$value"
107
-
108
- return $?
109
- )
110
-
111
- dotpi_connection_read() (
112
- # sub-shell to keep everything local (functions and variables)
113
-
114
- _dotpi_command="$(basename "${FUNCNAME[0]:-"$0"}")"
115
- _dotpi_usage() {
116
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
117
- }
118
-
119
- # Initialize all the option variables.
120
- # This ensures we are not contaminated by variables from the environment.
121
- file=
122
- key=
123
- value=
124
- prepend_line_if_new=
125
- if ! _dotpi_connection_get_options "${@}" ; then
126
- return $?
127
- fi
128
-
129
- if [ -z "$key" ] ; then
130
- _dotpi_usage
131
- dotpi_echo_error "missing key option"
132
- return 1
133
- fi
134
-
135
- if [ -z "$file" ] ; then
136
- _dotpi_usage
137
- dotpi_echo_error "missing file option"
138
- return 1
139
- fi
140
-
141
- if ! [ -r "$file" ] ; then
142
- _dotpi_usage
143
- dotpi_echo_error "file ${file} is not readable"
144
- return 1
145
- fi
146
-
147
- # use printf to unquote strings
148
- value="$(git config --file "$file" "$key")"
149
- printf "$value\n"
150
-
151
- return $?
152
- )
153
-
154
- dotpi_connection_delete() (
155
- # sub-shell to keep everything local (functions and variables)
156
-
157
- _dotpi_command="$(basename "${FUNCNAME[0]:-"$0"}")"
158
- _dotpi_usage() {
159
- echo "Usage: ${_dotpi_command} [--file <file>] --key <key>"
160
- }
161
-
162
- # Initialize all the option variables.
163
- # This ensures we are not contaminated by variables from the environment.
164
- file=
165
- key=
166
- value=
167
- prepend_line_if_new=
168
- if ! _dotpi_connection_get_options "${@}" ; then
169
- return $?
170
- fi
171
-
172
- if [ -z "$key" ] ; then
173
- _dotpi_usage
174
- dotpi_echo_error "missing key option"
175
- return 1
176
- fi
177
-
178
- if [ -z "$file" ] ; then
179
- _dotpi_usage
180
- dotpi_echo_error "missing value option"
181
- return 1
182
- fi
183
-
184
- if ! [ -r "$file" ] ; then
185
- _dotpi_usage
186
- dotpi_echo_error "file ${file} is not readable"
187
- return 1
188
- fi
189
-
190
- git config --file "$file" --unset "$key"
191
-
192
- return $?
193
- )
194
-
@@ -1,26 +0,0 @@
1
- #!/bin/bash
2
-
3
- dotpi_daemon_install() {
4
- # $1 - path to the `.service` file
5
- service_file="$1"
6
- service_name=$(basename -- "${service_file}")
7
-
8
- ln -s "$(dotpi readlink_follow "${service_file}")" /etc/systemd/system/
9
-
10
- systemctl enable "${service_name}"
11
- systemctl daemon-reload
12
- systemctl start "${service_name}"
13
- }
14
-
15
- dotpi_daemon_uninstall() {
16
- service_name="$1"
17
-
18
- systemctl stop "${service_name}"
19
- systemctl disable "${service_name}"
20
- systemctl daemon-reload
21
- }
22
-
23
- dotpi_daemon_restart() {
24
- service_name="$1"
25
- systemctl restart "${service_name}"
26
- }