From 9ab6d60c160d00669d9721cbdf6bae84c720d45b Mon Sep 17 00:00:00 2001 From: randogoth Date: Sat, 22 Nov 2025 14:02:33 +0200 Subject: [PATCH] install script --- install.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 45 ++++++++------------------------------------- 2 files changed, 54 insertions(+), 37 deletions(-) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e083a45 --- /dev/null +++ b/install.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Ensure we have root privileges before touching system paths. +if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then + exec sudo -E "$0" "$@" +fi + +script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" + +# Resolve the active GRUB theme's icons directory from user.cfg. +find_icons_dir() { + local theme_line theme_dir + theme_line="$(awk -F= '/set[[:space:]]+theme=/ {print $2; exit}' /boot/grub2/user.cfg 2>/dev/null | tr -d '"' || true)" + [[ -n "$theme_line" ]] || return 1 + theme_dir="${theme_line%/*}" + echo "${theme_dir}/icons" +} + +icons_dir="$(find_icons_dir || true)" + +# Abort if we cannot locate the theme icons directory. +if [[ -z "$icons_dir" || ! -d "$icons_dir" ]]; then + echo "Could not find GRUB theme icons directory. Ensure /boot/grub2/user.cfg contains a theme= entry." >&2 + exit 1 +fi + +# Drop the Bluefin icon into the active theme. +echo "Copying Bluefin icon to ${icons_dir}" +install -m 644 -D "${script_dir}/bluefin.png" "${icons_dir}/bluefin.png" + +# Install the helper that ensures grub_class bluefin exists. +echo "Installing helper script to /usr/local/sbin" +install -m 755 "${script_dir}/bls-add-bluefin.sh" /usr/local/sbin/bls-add-bluefin.sh + +# Add the rpm-ostree hook and reload systemd. +echo "Installing systemd drop-in for rpm-ostree hook" +install -m 644 -D "${script_dir}/bluefin-icons.conf" /etc/systemd/system/ostree-finalize-staged.service.d/bluefin-icons.conf +systemctl daemon-reload + +# Immediately apply the Bluefin class to existing BLS entries. +echo "Applying grub_class bluefin to existing BLS entries" +/usr/local/sbin/bls-add-bluefin.sh + +# Report completion. +echo "Done. New deployments will keep the Bluefin GRUB icon." diff --git a/readme.md b/readme.md index 6104bc9..71455b7 100644 --- a/readme.md +++ b/readme.md @@ -16,50 +16,21 @@ This setup borrows the icon for the Bluefin GRUB [theme created by Raindrac](htt ## Installation -If you don't have a GRUB theme installed, [check these out](https://www.gnome-look.org/browse?cat=109&ord=latest). I am currently using [this one](https://www.gnome-look.org/p/2227016). +If you don't have a GRUB theme installed, [check these out](https://www.gnome-look.org/browse?cat=109&ord=latest). I am currently using [this one](https://www.gnome-look.org/p/2227016). The installer expects `/boot/grub2/user.cfg` to contain a `set theme=/boot/grub2/themes//.txt` entry so it can locate the theme's `icons` folder. -### 1. Find the icons folder of your currently used GRUB theme +1) Run the installer from the repo root (it will sudo itself): ```bash -sudo awk -F= '/set theme=/ {f=$2; sub(/\/[^/]*$/, "", f); print f "/icons"}' /boot/grub2/user.cfg +./install.sh ``` -should print something like `"/boot/grub2/themes//icons` +What it does: +- Reads your active theme path from `/boot/grub2/user.cfg` and copies `bluefin.png` into its `icons/` directory. +- Installs `bls-add-bluefin.sh` to `/usr/local/sbin/` and the rpm-ostree drop-in to `/etc/systemd/system/ostree-finalize-staged.service.d/bluefin-icons.conf`. +- Reloads systemd and immediately applies `grub_class bluefin` to existing BLS entries so icons show up right away. -### 2. Copy bluefin icon to that folder +2) (Optional) Verify: ```bash -sudo cp bluefin.png /boot/grub2/themes//icons/ -``` - -### 3. Install helper script - -```bash -sudo cp bls-add-bluefin.sh /usr/local/sbin/ -sudo chmod 755 /usr/local/sbin/bls-add-bluefin.sh -``` - -### 4. Install rpm-ostree hook - -```bash -sudo mkdir -p /etc/systemd/system/ostree-finalize-staged.service.d -sudo cp bluefin-icons.conf /etc/systemd/system/ostree-finalize-staged.service.d/ -sudo systemctl daemon-reload -``` - -### 5. (Optional) Test helper script - -```bash -sudo /usr/local/sbin/bls-add-bluefin.sh grep -n '^grub_class' /boot/loader/entries/ostree*.conf - -# Expected Result - -/boot/loader/entries/ostree-1.conf - 2: grub_class bluefin - -/boot/loader/entries/ostree-2.conf - 2: grub_class bluefin - ``` -