-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_raspOVOS.sh
157 lines (124 loc) · 7.03 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
#!/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
## Intended to run on top of the image generated by build_audio_base.sh
# Function to add a user to a specific group in /etc/group.
# If the group does not exist, it outputs an error message.
# If the user is not already a member of the group, it adds the user.
add_user_to_group() {
local user=$1
local group=$2
# Check if the group exists
if ! grep -q "^$group:" /etc/group; then
echo "Group $group doesn't exist"
return 1
fi
# Add the user to the group if not already a member
if ! grep -q "^$group:.*\b$user\b" /etc/group; then
echo "Adding $user to $group"
sed -i "/^$group:/s/$/,$user/" /etc/group
else
echo "$user is already in $group"
fi
}
# 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 of the current user 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"
echo "Installing system packages..."
apt-get install -y --no-install-recommends swig python3-dev python3-pip libssl-dev libfann-dev
#echo "Updating ovos-i2csound and raspovos-audio-setup"
#bash /mounted-github-repo/scripts/update.sh
# Copy raspOVOS overlay to the system.
echo "Copying raspOVOS overlay..."
cp -rv /mounted-github-repo/overlays/base_ovos/* /
# Ensure the correct permissions for binaries
chmod +x /usr/libexec/*
chmod +x /usr/local/bin/*
# Install dependencies for system OVOS and related tools.
echo "Installing uv and sdnotify..."
pip install sdnotify uv --break-system-packages
# Install admin phal package and its dependencies.
echo "Installing admin phal..."
pip install ovos-bus-client ovos-phal ovos-PHAL-plugin-system -c $CONSTRAINTS --break-system-packages
# Create and activate a virtual environment for OVOS.
echo "Creating virtual environment..."
mkdir -p /home/$USER/.venvs
python3 -m venv --system-site-packages /home/$USER/.venvs/ovos
source /home/$USER/.venvs/ovos/bin/activate
# Install additional Python dependencies within the virtual environment.
uv pip install --no-progress wheel cython -c $CONSTRAINTS
echo "Installing llama.cpp"
uv pip install --no-progress https://github.com/abetlen/llama-cpp-python/releases/download/v0.3.2/llama_cpp_python-0.3.2-cp311-cp311-linux_aarch64.whl
# Install ggwave in the virtual environment.
echo "Installing ggwave..."
# NOTE: update this wheel if python version changes
uv pip install --no-progress https://whl.smartgic.io/ggwave-0.4.2-cp311-cp311-linux_aarch64.whl
# Install OVOS dependencies in the virtual environment.
echo "Installing OVOS..."
uv pip install --no-progress --pre ovos-docs-viewer ovos-utils[extras] ovos-dinkum-listener ovos-phal ovos-audio ovos-gui ovos-core[lgpl,plugins] -c $CONSTRAINTS
echo "Installing STT/TTS plugins..."
uv pip install --no-progress --pre ovos-stt-plugin-fasterwhisper ovos-dinkum-listener[extras,linux,onnx] tflite_runtime ovos-audio-transformer-plugin-ggwave ovos-audio[extras] -c $CONSTRAINTS
echo "Downloading whisper tiny model (for lang detection)..."
python -c "from huggingface_hub import snapshot_download; repo_id = 'Systran/faster-whisper-tiny'; file_path = snapshot_download(repo_id=repo_id); print(f'Downloaded {repo_id}')"
# since script was run as root, we need to move downloaded files
mkdir -p /home/ovos/.cache/huggingface/hub/
mv /root/.cache/huggingface/hub/models--Systran--faster-whisper-tiny/ /home/ovos/.cache/huggingface/hub/models--Systran--faster-whisper-tiny/
# Install essential skills for OVOS.
echo "Installing skills..."
uv pip install --no-progress --pre -r ./mounted-github-repo/skills.list
# Install PHAL plugins for OVOS.
echo "Installing PHAL plugins..."
uv pip install --no-progress --pre ovos-phal[extras,linux,mk1] ovos-PHAL-plugin-dotstar ovos-phal-plugin-camera -c $CONSTRAINTS
# Install Spotify-related plugins for OVOS.
echo "Installing OVOS Spotify..."
uv pip install --no-progress --pre ovos-media-plugin-spotify -c $CONSTRAINTS
# Install deprecated OVOS packages for compatibility with older skills.
echo "Installing deprecated OVOS packages for compat..."
uv pip install --no-progress --pre ovos-lingua-franca ovos-backend-client -c $CONSTRAINTS
# Enable necessary system services.
echo "Enabling system services..."
chmod 644 /etc/systemd/system/ovos-admin-phal.service
chmod 644 /etc/systemd/system/splashscreen.service
ln -s /etc/systemd/system/ovos-admin-phal.service /etc/systemd/system/multi-user.target.wants/ovos-admin-phal.service
ln -s /etc/systemd/system/splashscreen.service /etc/systemd/system/multi-user.target.wants/splashscreen.service
# Enable user systemd services.
chmod 644 /home/$USER/.config/systemd/user/*.service
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 "Enabling messagebus signals..."
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
echo "Ensuring log file permissions for ovos group..."
mkdir -p /home/$USER/.local/state/mycroft
chown -R $TUID:$TGID /home/$USER/.local/state/mycroft
chmod -R 2775 /home/$USER/.local/state/mycroft
echo "Ensuring permissions for $USER user..."
chown -R $TUID:$TGID /home/$USER
echo "Cleaning up apt packages..."
apt-get --purge autoremove -y && apt-get clean