-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
119 lines (97 loc) · 6.07 KB
/
build.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
#!/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"
# Copy raspOVOS overlay to the system.
echo "Copying HiveMind overlay..."
cp -rv /mounted-github-repo/overlays/* /
# Ensure the correct permissions for binaries
chmod +x /usr/libexec/*
chmod +x /usr/local/bin/*
# activate virtual environment for OVOS.
echo "Activating virtual environment..."
source /home/$USER/.venvs/ovos/bin/activate
echo "Installing hivemind"
uv pip install --no-progress --pre hivemind-core hivemind-audio-binary-protocol hivemind-http-protocol hivemind-redis-database hivemind-sqlite-database -c $CONSTRAINTS
uv pip install --no-progress git+https://github.com/JarbasHiveMind/HiveMind-matrix-bridge -c $CONSTRAINTS
uv pip install --no-progress git+https://github.com/JarbasHiveMind/HiveMind-deltachat-bridge -c $CONSTRAINTS
echo "Installing servers"
uv pip install --no-progress --pre ovos-tts-server ovos-translate-server ovos-stt-http-server ovos-persona-server -c $CONSTRAINTS
uv pip install --no-progress -U g4f[all]
echo "Installing OVOS plugins"
uv pip install --no-progress --pre ovos-google-translate-plugin ovos-tts-plugin-piper ovos-stt-plugin-fasterwhisper ovos-stt-plugin-chromium ovos-stt-plugin-citrinet ovos-stt-plugin-vosk ovos-tts-plugin-google-tx -c $CONSTRAINTS
echo "Installing solver plugins"
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
uv pip install --no-progress --pre ovos-solver-openai-persona-plugin ovos-solver-aiml-plugin ovos-solver-rivescript-plugin ovos-solver-gguf-plugin -c $CONSTRAINTS
# need to keep final img under 2GB
#echo "Downloading tiny llama model..."
#python -c "from huggingface_hub import hf_hub_download; repo_id = 'TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF'; hf_hub_download(repo_id=repo_id, filename='tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf')"
# 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--TheBloke--TinyLlama-1.1B-Chat-v1.0-GGUF/ /home/ovos/.cache/huggingface/hub/models--TheBloke--TinyLlama-1.1B-Chat-v1.0-GGUF/
# 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/hivemind-core.service /home/$USER/.config/systemd/user/default.target.wants/hivemind-core.service
ln -s /home/$USER/.config/systemd/user/ovos-piper.service /home/$USER/.config/systemd/user/default.target.wants/ovos-piper.service
ln -s /home/$USER/.config/systemd/user/ovos-google-tx.service /home/$USER/.config/systemd/user/default.target.wants/ovos-google-tx.service
ln -s /home/$USER/.config/systemd/user/ovos-chromium.service /home/$USER/.config/systemd/user/default.target.wants/ovos-chromium.service
ln -s /home/$USER/.config/systemd/user/ovos-aiml.service /home/$USER/.config/systemd/user/default.target.wants/ovos-aiml.service
ln -s /home/$USER/.config/systemd/user/ovos-ddg.service /home/$USER/.config/systemd/user/default.target.wants/ovos-ddg.service
ln -s /home/$USER/.config/systemd/user/ovos-rivescript.service /home/$USER/.config/systemd/user/default.target.wants/ovos-rivescript.service
ln -s /home/$USER/.config/systemd/user/ovos-wordnet.service /home/$USER/.config/systemd/user/default.target.wants/ovos-wordnet.service
ln -s /home/$USER/.config/systemd/user/ovos-wikipedia.service /home/$USER/.config/systemd/user/default.target.wants/ovos-wikipedia.service
ln -s /home/$USER/.config/systemd/user/ovos-wolfram-alpha.service /home/$USER/.config/systemd/user/default.target.wants/ovos-wolfram-alpha.service
ln -s /home/$USER/.config/systemd/user/g4f.service /home/$USER/.config/systemd/user/default.target.wants/g4f.service
#ln -s /home/$USER/.config/systemd/user/ovos-vosk.service /home/$USER/.config/systemd/user/default.target.wants/ovos-vosk.service
#ln -s /home/$USER/.config/systemd/user/ovos-citrinet.service /home/$USER/.config/systemd/user/default.target.wants/ovos-citrinet.service
#ln -s /home/$USER/.config/systemd/user/ovos-whisper.service /home/$USER/.config/systemd/user/default.target.wants/ovos-whisper.service
#ln -s /home/$USER/.config/systemd/user/ovos-tinyllama.service /home/$USER/.config/systemd/user/default.target.wants/ovos-tinyllama.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