-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
# scroll back and figure out what went wrong. | ||
set -e | ||
|
||
# if $USER is different from "pi" (the default) rename "pi" to "$USER" | ||
# Rename the default 'pi' user if the current user is not 'pi'. | ||
# Updates system configurations related to user, home directory, password, and group. | ||
if [ "$USER" != "pi" ]; then | ||
# 1. Change the username in /etc/passwd | ||
echo "Renaming user in /etc/passwd..." | ||
|
@@ -43,15 +44,20 @@ if [ "$USER" != "pi" ]; then | |
echo "User has been renamed, added to sudo group, and password updated." | ||
fi | ||
|
||
|
||
# Function to add user to group in /etc/group | ||
# 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 | ||
|
@@ -60,6 +66,7 @@ add_user_to_group() { | |
fi | ||
} | ||
|
||
# Add the current user to the 'ovos' group. | ||
echo "Adding $USER to the ovos group..." | ||
# Create the 'ovos' group if it doesn't exist | ||
if ! getent group ovos > /dev/null; then | ||
|
@@ -79,7 +86,7 @@ fi | |
|
||
echo "The GID for 'ovos' is: $TGID" | ||
|
||
# Parse the UID directly from /etc/passwd | ||
# 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") | ||
|
||
|
@@ -91,75 +98,81 @@ fi | |
|
||
echo "The UID for '$USER' is: $TUID" | ||
|
||
# Update package list and install necessary tools | ||
# Update package list and install necessary system tools. | ||
# Installs required packages and purges unnecessary ones. | ||
echo "Updating base system..." | ||
apt-get update | ||
apt-get install -y --no-install-recommends jq git unzip curl build-essential fake-hwclock userconf-pi swig python3-dev python3-pip fbi libasound2-dev mosh mpv libssl-dev libfann-dev portaudio19-dev libpulse-dev i2c-tools pulseaudio-utils dirmngr python3-libcamera python3-kms++ libcap-dev pipewire pipewire-alsa alsa-utils kdeconnect upmpdcli mpd systemd-zram-generator | ||
# what else can be removed to make the system even lighter? | ||
apt purge -y cups ppp | ||
|
||
# Copy raspOVOS overlay to the system. | ||
echo "Copying raspOVOS overlay..." | ||
sudo cp -rv /mounted-github-repo/overlays/base / | ||
# ensure permissions etc | ||
# Ensure the correct permissions for binaries | ||
sudo chmod +x /usr/libexec/ovos* | ||
sudo chmod +x /usr/local/bin/ovos* | ||
|
||
# Install dependencies for system OVOS and related tools. | ||
echo "Installing uv and sdnotify..." | ||
pip install sdnotify uv --break-system-packages | ||
|
||
# Modify /etc/fstab for performance optimization. | ||
echo "Tuning /etc/fstab..." | ||
bash /mounted-github-repo/scripts/setup_fstab.sh | ||
|
||
# Modify /boot/firmware/cmdline.txt to improve boot performance. | ||
echo "Tuning /boot/firmware/cmdline.txt" | ||
# make boot faster by printing less stuff and skipping file system checks | ||
grep -q "quiet fastboot" /boot/firmware/cmdline.txt || sed -i 's/$/ quiet fastboot/' /boot/firmware/cmdline.txt | ||
# support for mk1 | ||
sed -i 's/console=serial0,115200//g' /boot/firmware/cmdline.txt | ||
|
||
# Install admin phal package and its dependencies. | ||
echo "Installing admin phal..." | ||
pip install sdnotify ovos-bus-client ovos-phal ovos-PHAL-plugin-system -c $CONSTRAINTS --break-system-packages | ||
|
||
# Create virtual environment for ovos | ||
# 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 | ||
|
||
# Activate the virtual environment | ||
source /home/$USER/.venvs/ovos/bin/activate | ||
|
||
# Install additional Python dependencies within the virtual environment. | ||
uv pip install --no-progress wheel cython -c $CONSTRAINTS | ||
|
||
# Install ggwave in the virtual environment. | ||
echo "Installing ggwave..." | ||
uv pip install --no-progress https://whl.smartgic.io/ggwave-0.4.2-cp311-cp311-linux_aarch64.whl | ||
|
||
# install OVOS in venv | ||
# 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[extras,linux,onnx] tflite_runtime ovos-audio-transformer-plugin-ggwave ovos-phal ovos-audio[extras] ovos-gui ovos-core[lgpl,plugins] -c $CONSTRAINTS | ||
|
||
# Install essential skills for OVOS. | ||
echo "Installing skills..." | ||
uv pip install --no-progress --pre ovos-core[skills-essential,skills-audio,skills-media,skills-internet,skills-extra] | ||
|
||
# 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 | ||
|
||
# Install Spotify-related plugins for OVOS. | ||
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... | ||
# 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 | ||
|
||
# Configure user groups for audio management. | ||
echo "Configuring audio..." | ||
add_user_to_group $USER audio | ||
add_user_to_group $USER pipewire | ||
# Add user to rtkit group if it exists | ||
if getent group rtkit > /dev/null 2>&1; then | ||
add_user_to_group $USER rtkit | ||
fi | ||
|
||
# Enable necessary system services. | ||
echo "Enabling system services..." | ||
# Enable services manually by creating symbolic links | ||
chmod 644 /etc/systemd/system/kdeconnect.service | ||
chmod 644 /etc/systemd/system/ovos-admin-phal.service | ||
chmod 644 /etc/systemd/system/i2csound.service | ||
|
@@ -173,6 +186,7 @@ ln -s /etc/systemd/system/kdeconnect.service /etc/systemd/system/multi-user.targ | |
ln -s /usr/lib/systemd/system/mpd.service /etc/systemd/system/multi-user.target.wants/mpd.service | ||
ln -s /usr/lib/systemd/system/[email protected] /etc/systemd/system/multi-user.target.wants/[email protected] | ||
|
||
# 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 | ||
|