-
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
3 changed files
with
175 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
name: build headless image | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: test build no-OVOS headless image | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
modify-rpi-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- | ||
name: Add OVOS to Raspberry Pi OS Bookworm | ||
uses: dtcooper/rpi-image-modifier@v1 | ||
id: create-image | ||
env: | ||
USER: 'ovos' | ||
PASSWORD: 'ovos' | ||
HOSTNAME: "raspOVOS" | ||
with: | ||
base-image-url: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz | ||
image-path: raspOVOS-NO-OVOS-bookworm-arm64-lite.img | ||
compress-with-xz: true | ||
cache: true | ||
mount-repository: true | ||
env-vars: USER,PASSWORD | ||
script-path: build_test.sh | ||
- | ||
name: Print outputs | ||
shell: bash | ||
run: | | ||
echo 'image-path: ${{ steps.create-image.outputs.image-path }}' | ||
echo 'image-size: ${{ steps.create-image.outputs.image-size }}' | ||
echo 'image-sha256sum: ${{ steps.create-image.outputs.image-sha256sum }}' | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: raspOVOS-NO-OVOS-bookworm-arm64-lite-${{ github.run_id }} | ||
release_name: raspOVOS-NO-OVOS-bookworm-arm64-lite-${{ github.run_id }} | ||
body: | | ||
testing base OS changes only | ||
draft: true | ||
prerelease: false | ||
- | ||
name: Upload to releases | ||
uses: xresloader/upload-to-github-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
file: ${{ steps.create-image.outputs.image-path }} | ||
release_id: ${{ steps.create_release.outputs.id }} | ||
draft: true | ||
overwrite: true | ||
prerelease: true | ||
verbose: true |
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/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 | ||
|
||
# if $USER is different from "pi" (the default) rename "pi" to "$USER" | ||
if [ "$USER" != "pi" ]; then | ||
# 1. Change the username in /etc/passwd | ||
echo "Renaming user in /etc/passwd..." | ||
sed -i "s/^pi:/^$USER:/g" "/etc/passwd" | ||
|
||
# 2. Change the group name in /etc/group | ||
echo "Renaming user in /etc/group..." | ||
sed -i "s/^pi:/^$USER:/g" "/etc/group" | ||
|
||
# 3. Rename the home directory from /home/pi to /home/newuser | ||
echo "Renaming home directory..." | ||
mv "/home/pi" "/home/$USER" | ||
|
||
# 4. Change ownership of the new home directory | ||
echo "Updating file ownership..." | ||
chown -R 1000:1000 "/home/$USER" # Replace 1000:1000 with the correct UID:GID if needed | ||
|
||
# 5. Change the password in /etc/shadow | ||
echo "Changing user password to $PASSWORD..." | ||
NEW_HASHED_PASSWORD=$(openssl passwd -6 "$PASSWORD") | ||
echo "hashed password: $NEW_HASHED_PASSWORD..." | ||
sed -i "s#^pi:.*#$USER:$NEW_HASHED_PASSWORD:18720:0:99999:7:::#g" "/etc/shadow" | ||
|
||
# 6. don't let raspbian force to change username on first boot | ||
echo "Disabling first boot user setup wizard..." | ||
rm /etc/systemd/system/multi-user.target.wants/userconfig.service | ||
ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected] | ||
echo "$USER:$NEW_HASHED_PASSWORD" > /boot/userconf.txt | ||
chmod 600 /boot/userconf.txt | ||
|
||
# 7. Add the new user to the sudo group | ||
echo "Adding $USER to the sudo group..." | ||
sed -i "/^sudo:/s/pi/$USER/" /etc/group | ||
|
||
echo "User has been renamed, added to sudo group, and password updated." | ||
fi | ||
|
||
echo "Changing system hostname to $HOSTNAME..." | ||
# Update /etc/hostname | ||
echo "$HOSTNAME" > /etc/hostname | ||
# Update /etc/hosts to reflect the new hostname | ||
sed -i "s/127.0.1.1.*$/127.0.1.1\t$HOSTNAME/" /etc/hosts | ||
|
||
echo "Enabling auto login for $USER user.." | ||
ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected] | ||
# Define the systemd service for autologin (adjust to your display manager if needed) | ||
SERVICE_FILE="/etc/systemd/system/[email protected]/autologin.conf" | ||
# Create the directory for the systemd override if it doesn't exist | ||
mkdir -p /etc/systemd/system/[email protected] | ||
# Create the autologin configuration file | ||
cat > "$SERVICE_FILE" <<EOF | ||
[Service] | ||
ExecStart= | ||
ExecStart=-/sbin/agetty --autologin $USER --noclear %I 38400 linux | ||
EOF | ||
|
||
# Set the system to boot into multi-user.target | ||
#rm -f /etc/systemd/system/default.target | ||
#ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target | ||
|
||
|
||
# Update package list and install necessary tools | ||
echo "Updating base system..." | ||
apt-get update | ||
apt-get install -y --no-install-recommends git unzip curl i2c-tools fbi swig libssl-dev portaudio19-dev libpulse-dev build-essential python3-dev python3-pip | ||
|
||
echo "Installing Pipewire..." | ||
bash /mounted-github-repo/setup_pipewire.sh | ||
|
||
echo "Tuning base system..." | ||
cp -v /mounted-github-repo/boot_config.txt /boot/firmware/config.txt | ||
bash /mounted-github-repo/setup_ramdisk.sh | ||
bash /mounted-github-repo/setup_zram.sh | ||
bash /mounted-github-repo/setup_cpugovernor.sh | ||
bash /mounted-github-repo/setup_wlan0power.sh | ||
bash /mounted-github-repo/setup_fstab.sh | ||
bash /mounted-github-repo/setup_sysctl.sh | ||
bash /mounted-github-repo/setup_udev.sh | ||
bash /mounted-github-repo/setup_kernel_modules.sh | ||
bash /mounted-github-repo/setup_nmanager.sh | ||
|
||
# splashscreen | ||
echo "Creating OVOS splashscreen..." | ||
mkdir -p /opt/ovos | ||
cp -v /mounted-github-repo/splashscreen.png /opt/ovos/splashscreen.png | ||
cp -v /mounted-github-repo/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 "Ensuring permissions for $USER user..." | ||
# Replace 1000:1000 with the correct UID:GID if needed | ||
chown -R 1000:1000 /home/$USER | ||
|
||
# Enable lingering for the user | ||
echo "Enabling lingering for $USER user ..." | ||
# Enable lingering by creating the directory | ||
mkdir -p /var/lib/systemd/linger | ||
|
||
# Create an empty file with the user's name | ||
touch /var/lib/systemd/linger/$USER | ||
|
||
# Ensure correct permissions | ||
chown root:root /var/lib/systemd/linger/$USER | ||
chmod 644 /var/lib/systemd/linger/$USER | ||
|
||
echo "Cleaning up apt packages..." | ||
apt-get --purge autoremove -y && apt-get clean |