@dotpi/tools 1.4.0 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +108 -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/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 +21 -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 +7 -1
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -1
- package/dotpi_root/share/dotpi_pipewire/package.json +9 -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/led-test/.dotpi +3 -0
- package/projects/led-test/README.md +16 -0
- package/projects/led-test/dotpi_project.bash +29 -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/PIPEWIRE.md +0 -280
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +0 -149
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +0 -177
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +0 -425
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +0 -620
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +0 -82
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +0 -100
- package/dotpi_root/bin/.editorbackup/dotpi~ +0 -61
- package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +0 -252
- package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +0 -49
- package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +0 -33
- package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +0 -4
- package/dotpi_root/share/.editorbackup/coucou~ +0 -1
- package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +0 -9
- package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +0 -11
- package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +0 -420
- package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +0 -358
- package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +0 -18
- package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +0 -15
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +0 -24
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +0 -80
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +0 -26
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +0 -30
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +0 -21
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +0 -256
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +0 -287
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +0 -7
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +0 -428
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +0 -194
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +0 -26
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +0 -287
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +0 -12
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +0 -158
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +0 -152
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +0 -20
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +0 -17
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +0 -20
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +0 -16
- package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +0 -5
- package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +0 -15
- package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +0 -5
- package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +0 -23
- 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/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +0 -1
- package/projects/old/dev.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +0 -33
- package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
- package/projects/old/dev.bak/dotpi_environment_instance.bash +0 -1
- package/projects/old/dev.bak/dotpi_environment_project.bash +0 -46
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +0 -22
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +0 -23
- package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +0 -22
- package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +0 -23
- package/projects/old/dev.bak/network/AccueilCie.nmconnection +0 -24
- package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +0 -23
- package/projects/old/dev.bak/network/DOTPI.nmconnection +0 -23
- package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +0 -25
- package/projects/old/dev.bak/network/onze.nmconnection +0 -24
- package/projects/old/dev.bak/network/welcome.nmconnection +0 -23
- package/projects/old/dev.bak/network/wifi-access-point.nmconnection +0 -23
- package/projects/old/dev.bak/network/wifi-internet.nmconnection +0 -24
- package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +0 -24
- package/projects/old/dev.bak/network/wifi-local.nmconnection +0 -22
- package/projects/old/dev.bak/network/wifi-welcome.nmconnection +0 -24
- package/projects/old/dev.bak/wpa_supplicant.conf +0 -43
- package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +0 -26
- package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +0 -21
- package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +0 -3
- package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
- package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +0 -21
- package/projects/old/example-complete.bak/configuration/dotpi_project.bash +0 -21
- package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +0 -14
- package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +0 -14
- /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 "####################################################"
|