-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_raspOVOS.sh
239 lines (191 loc) · 12 KB
/
build_raspOVOS.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
# Exit on error
# If something goes wrong just stop.
# it allows the user to see issues at once rather than having
# scroll back and figure out what went wrong.
set -e
# Retrieve the GID of the 'ovos' group
GROUP_FILE="/etc/group"
TGID=$(awk -F: -v group="ovos" '$1 == group {print $3}' "$GROUP_FILE")
# Check if GID was successfully retrieved
if [[ -z "$TGID" ]]; then
echo "Error: Failed to retrieve GID for group 'ovos'. Exiting..."
exit 1
fi
echo "The GID for 'ovos' is: $TGID"
# Parse the UID directly from /etc/passwd
PASSWD_FILE="/etc/passwd"
TUID=$(awk -F: -v user="$USER" '$1 == user {print $3}' "$PASSWD_FILE")
# Check if UID was successfully retrieved
if [[ -z "$TUID" ]]; then
echo "Error: Failed to retrieve UID for user '$USER'. Exiting..."
exit 1
fi
echo "The UID for '$USER' is: $TUID"
# Update package list and install necessary tools
echo "Installing system packages..."
apt-get install -y --no-install-recommends mpv libssl-dev libfann-dev portaudio19-dev libpulse-dev
# splashscreen
echo "Creating OVOS splashscreen..."
mkdir -p /opt/ovos
cp -v /mounted-github-repo/services/splashscreen.png /opt/ovos/splashscreen.png
cp -v /mounted-github-repo/services/splashscreen.service /etc/systemd/system/splashscreen.service
chmod 644 /etc/systemd/system/splashscreen.service
ln -s /etc/systemd/system/splashscreen.service /etc/systemd/system/multi-user.target.wants/splashscreen.service
echo "Creating OVOS login ASCII art..."
cp -v /mounted-github-repo/tuning/etc_issue /etc/issue
echo "Creating default OVOS XDG paths..."
mkdir -p /home/$USER/.config/mycroft
mkdir -p /home/$USER/.local/share/OpenVoiceOS
mkdir -p /home/$USER/.local/share/mycroft
mkdir -p /home/$USER/.cache/mycroft/
mkdir -p /home/$USER/.cache/ovos_gui/
mkdir -p /home/$USER/.local/state/mycroft
mkdir -p /etc/mycroft
mkdir -p /etc/OpenVoiceOS
echo "Ensuring log file permissions for ovos group..."
chown -R $TUID:$TGID /home/$USER/.local/state/mycroft
chmod -R 2775 /home/$USER/.local/state/mycroft
# add bashrc and company
echo "Creating aliases and cli login screen..."
cp -v /mounted-github-repo/tuning/.bashrc /home/$USER/.bashrc
cp -v /mounted-github-repo/tuning/.bash_aliases /home/$USER/.bash_aliases
cp -v /mounted-github-repo/tuning/.logo.sh /home/$USER/.logo.sh
cp -v /mounted-github-repo/tuning/.cli_login.sh /home/$USER/.cli_login.sh
echo "Creating system level mycroft.conf..."
cp -v /mounted-github-repo/mycroft.conf /etc/mycroft/mycroft.conf
# copy default skill settings.json
echo "Configuring default skill settings.json..."
mkdir -p /home/$USER/.config/mycroft/skills
cp -rv /mounted-github-repo/settings/* /home/$USER/.config/mycroft/skills/
# setup ovos-i2csound
echo "Installing ovos-i2csound..."
apt-get install -y --no-install-recommends i2c-tools
git clone https://github.com/OpenVoiceOS/ovos-i2csound /tmp/ovos-i2csound
cp /tmp/ovos-i2csound/i2c.conf /etc/modules-load.d/i2c.conf
cp /tmp/ovos-i2csound/bcm2835-alsa.conf /etc/modules-load.d/bcm2835-alsa.conf
cp /tmp/ovos-i2csound/i2csound.service /etc/systemd/system/i2csound.service
cp /tmp/ovos-i2csound/ovos-i2csound /usr/libexec/ovos-i2csound
cp /tmp/ovos-i2csound/99-i2c.rules /usr/lib/udev/rules.d/99-i2c.rules
chmod 644 /etc/systemd/system/i2csound.service
chmod +x /usr/libexec/ovos-i2csound
ln -s /etc/systemd/system/i2csound.service /etc/systemd/system/multi-user.target.wants/i2csound.service
echo "Installing raspovos-audio-setup..."
apt-get install -y --no-install-recommends pulseaudio-utils
git clone https://github.com/OpenVoiceOS/raspovos-audio-setup /tmp/raspovos-audio-setup
cp "/tmp/raspovos-audio-setup/autoconfigure_soundcard.service" "/etc/systemd/system/autoconfigure_soundcard.service"
cp "/tmp/raspovos-audio-setup/combine_sinks.service" "/etc/systemd/system/combine_sinks.service"
cp "/tmp/raspovos-audio-setup/ovos-audio-setup" "/usr/local/bin/ovos-audio-setup"
cp "/tmp/raspovos-audio-setup/update-audio-sinks" "/usr/libexec/update-audio-sinks"
cp "/tmp/raspovos-audio-setup/soundcard_autoconfigure" "/usr/libexec/soundcard_autoconfigure"
cp "/tmp/raspovos-audio-setup/usb-autovolume" "/usr/libexec/usb-autovolume"
chmod +x "/usr/local/bin/ovos-audio-setup"
chmod +x "/usr/libexec/update-audio-sinks"
chmod +x "/usr/libexec/soundcard_autoconfigure"
chmod +x "/usr/libexec/usb-autovolume"
ln -s /etc/systemd/system/autoconfigure_soundcard.service /etc/systemd/system/multi-user.target.wants/autoconfigure_soundcard.service
echo "Installing admin phal..."
pip install sdnotify ovos-bus-client ovos-phal ovos-PHAL-plugin-system -c $CONSTRAINTS --break-system-packages
cp -v /mounted-github-repo/services/ovos-admin-phal.service /etc/systemd/system/
cp -v /mounted-github-repo/services/ovos-systemd-admin-phal /usr/libexec/ovos-systemd-admin-phal
chmod 644 /etc/systemd/system/ovos-admin-phal.service
ln -s /etc/systemd/system/ovos-admin-phal.service /etc/systemd/system/multi-user.target.wants/ovos-admin-phal.service
echo "Adding ntp sync signal..."
# emit "system.clock.synced" to the bus
mkdir -p /etc/systemd/system/systemd-timesyncd.service.d/
cp -v /mounted-github-repo/services/ovos-clock-sync.service /etc/systemd/system/systemd-timesyncd.service.d/ovos-clock-sync.conf
cp -v /mounted-github-repo/services/ovos-clock-sync /usr/libexec/ovos-clock-sync
echo "Adding ssh enabled/disabled signals..."
mkdir -p /etc/systemd/system/ssh.service.d
cp -v /mounted-github-repo/services/ovos-ssh-signal.service /etc/systemd/system/ssh.service.d/ovos-ssh-change-signal.conf
cp -v /mounted-github-repo/services/ovos-ssh-disabled-signal /usr/libexec/ovos-ssh-disabled-signal
cp -v /mounted-github-repo/services/ovos-ssh-enabled-signal /usr/libexec/ovos-ssh-enabled-signal
echo "Adding messagebus signals..."
cp -v /mounted-github-repo/services/ovos-reboot-signal.service /etc/systemd/system/ovos-reboot-signal.service
cp -v /mounted-github-repo/services/ovos-shutdown-signal.service /etc/systemd/system/ovos-shutdown-signal.service
ln -s /etc/systemd/system/ovos-reboot-signal.service /etc/systemd/system/multi-user.target.wants/ovos-reboot-signal.service
ln -s /etc/systemd/system/ovos-shutdown-signal.service /etc/systemd/system/multi-user.target.wants/ovos-shutdown-signal.service
cp -v /mounted-github-repo/services/ovos-stop /usr/libexec/ovos-stop
cp -v /mounted-github-repo/services/ovos-restart-signal /usr/libexec/ovos-restart-signal
cp -v /mounted-github-repo/services/ovos-reboot-signal /usr/libexec/ovos-reboot-signal
cp -v /mounted-github-repo/services/ovos-shutdown-signal /usr/libexec/ovos-shutdown-signal
cp -v /mounted-github-repo/services/ovos-ocp-pause-signal /usr/libexec/ovos-ocp-pause-signal
cp -v /mounted-github-repo/services/ovos-ocp-play-signal /usr/libexec/ovos-ocp-play-signal
cp -v /mounted-github-repo/services/ovos-ocp-stop-signal /usr/libexec/ovos-ocp-stop-signal
chmod +x /usr/libexec/ovos-stop \
/usr/libexec/ovos-restart-signal \
/usr/libexec/ovos-reboot-signal \
/usr/libexec/ovos-shutdown-signal \
/usr/libexec/ovos-ocp-pause-signal \
/usr/libexec/ovos-ocp-play-signal \
/usr/libexec/ovos-ocp-stop-signal
echo "Installing OVOS Rust Messagebus..."
bash /mounted-github-repo/packages/setup_rustbus.sh
# Create virtual environment for ovos
echo "Creating virtual environment..."
mkdir -p /home/$USER/.venvs
python3 -m venv --system-site-packages /home/$USER/.venvs/ovos
# Activate the virtual environment
source /home/$USER/.venvs/ovos/bin/activate
uv pip install --no-progress wheel cython -c $CONSTRAINTS
echo "Installing ggwave..."
uv pip install --no-progress /mounted-github-repo/packages/ggwave-0.4.2-cp311-cp311-linux_aarch64.whl
# install OVOS in venv
echo "Installing OVOS..."
uv pip install --no-progress --pre ovos-docs-viewer ovos-utils[extras] ovos-dinkum-listener[extras,linux,onnx] tflite_runtime ovos-audio-transformer-plugin-ggwave ovos-phal ovos-audio[extras] ovos-gui ovos-core[lgpl,plugins] -c $CONSTRAINTS
echo "Installing skills..."
uv pip install --no-progress --pre ovos-core[skills-essential,skills-audio,skills-media,skills-internet,skills-extra]
echo "Installing PHAL plugins..."
uv pip install --no-progress --pre ovos-phal[extras,linux,mk1] ovos-PHAL-plugin-dotstar ovos-phal-plugin-camera
echo "Installing OVOS Spotify..."
uv pip install --no-progress --pre ovos-media-plugin-spotify ovos-skill-spotify
# some skills import from these libs and dont have them as dependencies
# just until that is fixed...
echo "Installing deprecated OVOS packages for compat..."
uv pip install --no-progress --pre ovos-lingua-franca ovos-backend-client -c $CONSTRAINTS
echo "Caching nltk resources..."
cp -rv /mounted-github-repo/packages/nltk_data /home/$USER/
# no balena for now, let's use ggwave instead
#echo "Installing Balena wifi plugin..."
#uv pip install --no-progress --pre ovos-PHAL-plugin-balena-wifi ovos-PHAL-plugin-wifi-setup -c $CONSTRAINTS
echo "Downloading default wake word model..."
# Download precise-lite model
wget https://github.com/OpenVoiceOS/precise-lite-models/raw/master/wakewords/en/hey_mycroft.tflite -P /home/$USER/.local/share/precise_lite/
echo "Setting up systemd..."
# copy system scripts over
cp -v /mounted-github-repo/services/ovos-systemd-skills /usr/libexec/ovos-systemd-skills
cp -v /mounted-github-repo/services/ovos-systemd-messagebus /usr/libexec/ovos-systemd-messagebus
cp -v /mounted-github-repo/services/ovos-systemd-audio /usr/libexec/ovos-systemd-audio
cp -v /mounted-github-repo/services/ovos-systemd-listener /usr/libexec/ovos-systemd-listener
cp -v /mounted-github-repo/services/ovos-systemd-phal /usr/libexec/ovos-systemd-phal
cp -v /mounted-github-repo/services/ovos-systemd-gui /usr/libexec/ovos-systemd-gui
cp -v /mounted-github-repo/services/ovos-librespot /usr/libexec/ovos-librespot
mkdir -p /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-skills.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-messagebus.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-audio.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-listener.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-phal.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-gui.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-ggwave.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-spotify.service /home/$USER/.config/systemd/user/
# Set permissions for services
chmod 644 /home/$USER/.config/systemd/user/*.service
chmod +x /usr/libexec/ovos-*
# Enable services manually by creating symbolic links
mkdir -p /home/$USER/.config/systemd/user/default.target.wants/
ln -s /home/$USER/.config/systemd/user/ovos.service /home/$USER/.config/systemd/user/default.target.wants/ovos.service
ln -s /home/$USER/.config/systemd/user/ovos-skills.service /home/$USER/.config/systemd/user/default.target.wants/ovos-skills.service
ln -s /home/$USER/.config/systemd/user/ovos-messagebus.service /home/$USER/.config/systemd/user/default.target.wants/ovos-messagebus.service
ln -s /home/$USER/.config/systemd/user/ovos-audio.service /home/$USER/.config/systemd/user/default.target.wants/ovos-audio.service
ln -s /home/$USER/.config/systemd/user/ovos-listener.service /home/$USER/.config/systemd/user/default.target.wants/ovos-listener.service
ln -s /home/$USER/.config/systemd/user/ovos-phal.service /home/$USER/.config/systemd/user/default.target.wants/ovos-phal.service
ln -s /home/$USER/.config/systemd/user/ovos-gui.service /home/$USER/.config/systemd/user/default.target.wants/ovos-gui.service
ln -s /home/$USER/.config/systemd/user/ovos-ggwave.service /home/$USER/.config/systemd/user/default.target.wants/ovos-ggwave.service
ln -s /home/$USER/.config/systemd/user/ovos-spotify.service /home/$USER/.config/systemd/user/default.target.wants/ovos-spotify.service
echo "Ensuring permissions for $USER user..."
# Replace 1000:1000 with the correct UID:GID if needed
chown -R $TUID:$TGID /home/$USER
echo "Cleaning up apt packages..."
apt-get --purge autoremove -y && apt-get clean