@dotpi/tools 1.0.1 → 1.4.0
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/PIPEWIRE.md +280 -0
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +149 -0
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +177 -0
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +425 -0
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +620 -0
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +82 -0
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +100 -0
- package/dotpi_root/bin/.editorbackup/dotpi~ +61 -0
- package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +252 -0
- package/dotpi_root/bin/dotpi_prepare_system +14 -3
- package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +49 -0
- package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +33 -0
- package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +4 -0
- package/dotpi_root/share/.editorbackup/coucou~ +1 -0
- package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +9 -0
- package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +11 -0
- package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +420 -0
- package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +358 -0
- package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +18 -0
- package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +15 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +24 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +80 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +26 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +30 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +21 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +256 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +287 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +7 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +428 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +194 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +26 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +287 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +12 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +158 -0
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +152 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +68 -10
- package/dotpi_root/share/dotpi_init.bash +3 -0
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +85 -0
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +24 -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/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +20 -0
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +17 -0
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +20 -0
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +16 -0
- package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +5 -0
- package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +15 -0
- package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +5 -0
- package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +23 -0
- package/dotpi_root/share/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +1 -0
- package/package.json +1 -1
- 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/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.bak/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +33 -0
- package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/dev.bak/dotpi_environment_instance.bash +1 -0
- package/projects/old/dev.bak/dotpi_environment_project.bash +46 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +24 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +24 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +24 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +22 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +23 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +23 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +23 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +24 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +24 -0
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +23 -0
- package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +24 -0
- package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +24 -0
- package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +24 -0
- package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +22 -0
- package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +23 -0
- package/projects/old/dev.bak/network/AccueilCie.nmconnection +24 -0
- package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +23 -0
- package/projects/old/dev.bak/network/DOTPI.nmconnection +23 -0
- package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +25 -0
- package/projects/old/dev.bak/network/onze.nmconnection +24 -0
- package/projects/old/dev.bak/network/welcome.nmconnection +23 -0
- package/projects/old/dev.bak/network/wifi-access-point.nmconnection +23 -0
- package/projects/old/dev.bak/network/wifi-internet.nmconnection +24 -0
- package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +24 -0
- package/projects/old/dev.bak/network/wifi-local.nmconnection +22 -0
- package/projects/old/dev.bak/network/wifi-welcome.nmconnection +24 -0
- package/projects/old/dev.bak/wpa_supplicant.conf +43 -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/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example-complete.bak/configuration/dotpi_project.bash +21 -0
- package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +14 -0
- package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +14 -0
- package/src/create-project.js +3 -3
- package/src/templates/dotpi_project.bash +1 -1
- package/src/templates/gitignore +4 -0
|
@@ -0,0 +1,425 @@
|
|
|
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 "####################################################"
|