install script

This commit is contained in:
randogoth 2025-11-22 14:02:33 +02:00
parent 4e8e8c4ca6
commit 9ab6d60c16
2 changed files with 54 additions and 37 deletions

46
install.sh Normal file
View file

@ -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."

View file

@ -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/<theme>/<file>.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/<theme>/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/<theme>/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
```