Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(greenboot): Add simpler greenboot variant #2057

Merged
merged 13 commits into from
Jan 4, 2025
14 changes: 4 additions & 10 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
# Install new packages
RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
rpm-ostree install \
greenboot \
discover-overlay \
sunshine \
python3-pip \
Expand Down Expand Up @@ -828,15 +827,6 @@ RUN rm -f /etc/profile.d/toolbox.sh && \
systemctl --global enable systemd-tmpfiles-setup.service && \
systemctl --global disable sunshine.service && \
systemctl disable waydroid-container.service && \
systemctl enable greenboot-task-runner \
greenboot-healthcheck \
greenboot-status \
greenboot-loading-message \
greenboot-grub2-set-counter \
greenboot-grub2-set-success \
greenboot-rpm-ostree-grub2-check-fallback \
redboot-auto-reboot \
redboot-task-runner && \
curl -Lo /etc/dxvk-example.conf https://raw.githubusercontent.com/doitsujin/dxvk/master/dxvk.conf && \
curl -Lo /usr/bin/waydroid-choose-gpu https://raw.githubusercontent.com/KyleGospo/waydroid-scripts/main/waydroid-choose-gpu.sh && \
chmod +x /usr/bin/waydroid-choose-gpu && \
Expand Down Expand Up @@ -1009,7 +999,11 @@ RUN /usr/libexec/containerbuild/image-info && \
systemctl enable cec-onpoweroff.service && \
systemctl enable cec-onsleep.service && \
systemctl enable bazzite-tdpfix.service && \
systemctl enable bazzite-grub-boot-success.timer && \
systemctl enable bazzite-grub-boot-success.service && \
systemctl --global disable sdgyrodsu.service && \
systemctl --global disable grub-boot-success.timer && \
systemctl disable grub-boot-indeterminate.service && \
systemctl disable input-remapper.service && \
systemctl disable ublue-update.timer && \
systemctl disable jupiter-fan-control.service && \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# In the future this can do more complex checks to ensure the update is
# successful. For now, just assume the user will hold the button or
# something within 5 minutes if boot fails.

[Unit]
Description=Mark boot as successful and reset counter
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/bazzite-grub-boot-success

[Install]
WantedBy=hibernate.target hybrid-sleep.target suspend-then-hibernate.target halt.target reboot.target shutdown.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Mark update as successful after the system has been alive for 3 minutes.

[Timer]
OnStartupSec=3min

[Install]
WantedBy=timers.target
26 changes: 26 additions & 0 deletions system_files/deck/shared/usr/libexec/bazzite-grub-boot-success
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -eo pipefail

maxbootcount=2

if ! /usr/bin/grub2-editenv - set boot_success=1; then
exit 1
fi

if ! /usr/bin/grub2-editenv - set boot_indeterminate=0; then
exit 1
fi

if [ ! -f /usr/bin/bootc ] ||
[ "$(sudo /usr/bin/bootc status --json | jq ".status.rollback")" == "null" ]; then
if ! /usr/bin/grub2-editenv - unset boot_counter; then
exit 1
fi
echo "Marking boot as succeeded, setting boot_success=1 and unsetting boot_counter (missing rollback)"
else
if ! /usr/bin/grub2-editenv - set boot_counter="$maxbootcount"; then
exit 1
fi
echo "Marking boot as succeeded, setting boot_counter=$maxbootcount and boot_success=1"
fi
32 changes: 27 additions & 5 deletions system_files/desktop/shared/usr/libexec/bazzite-hardware-setup
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,24 @@ touch /etc/bazzite/fixups/snapper_cleanup

if [ ! -f /etc/bazzite/fixups/grub_fixup ]; then
# Grub settings
# Grub hidden timeout should be 2 if it does not exist
# So that when grub is hidden it exits quicker
if [ -z $(grep "GRUB_HIDDEN_TIMEOUT=" /etc/default/grub) ]; then
echo "Setting GRUB_HIDDEN_TIMEOUT=2"
echo "GRUB_HIDDEN_TIMEOUT=2" >> /etc/default/grub
# Set grub timeout to 3 seconds
if [ -z $(grep "GRUB_TIMEOUT=" /etc/default/grub) ]; then
echo "GRUB_TIMEOUT=3" >> /etc/default/grub
else
sed -i 's/GRUB_TIMEOUT=[0-9]*/GRUB_TIMEOUT=3/' /etc/default/grub
fi

# Nuke hidden timeout as it will cause issues if GRUB_TIMEOUT exists
if [ -n $(grep "GRUB_HIDDEN_TIMEOUT=" /etc/default/grub) ]; then
sed -i 's/GRUB_HIDDEN_TIMEOUT=[0-9]*//' /etc/default/grub
fi

# set timeout style to menu to show grub during countdown
# (unless GRUB_TIMEOUT=0)
if [ -z $(grep "GRUB_TIMEOUT_STYLE=" /etc/default/grub) ]; then
echo "GRUB_TIMEOUT_STYLE=menu" >> /etc/default/grub
else
sed -i 's/GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=menu/' /etc/default/grub
fi

# Autohide grub menu if boot is successful
Expand All @@ -359,6 +372,15 @@ if [ ! -f /etc/bazzite/fixups/grub_fixup ]; then
else
grub2-editenv - set menu_auto_hide=1
fi

# Update grub
if [ -d /sys/firmware/efi ]; then
echo "Updating EFI grub config"
grub2-mkconfig -o /etc/grub2-efi.cfg
else
echo "Updating BIOS grub config"
grub2-mkconfig -o /etc/grub2.cfg
fi
fi
touch /etc/bazzite/fixups/grub_fixup

Expand Down
14 changes: 2 additions & 12 deletions system_files/desktop/shared/usr/libexec/ublue-motd
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ if [[ -f "$TIP_FILE" ]]; then
THEME=$(gsettings get org.gnome.desktop.interface accent-color || echo "'purple'")
THEME=${THEME//\'/}
THEME=${MOTD_FORCE_THEME:-$THEME}

GREENBOOT=''
if [[ -f /run/motd.d/boot-status ]]; then
if grep -q "GREEN" /run/motd.d/boot-status && grep -q "SUCCESS" /run/motd.d/boot-status; then
GREENBOOT='Boot Status: Healthy 󰄳'
else
GREENBOOT=$(cat /run/motd.d/boot-status)
fi
fi
GREENBOOT_ESCAPED=$(escape "$GREENBOOT")

sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_BRANCH%/$IMAGE_BRANCH_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" -e "s/%GREENBOOT%/$GREENBOOT_ESCAPED/g" /usr/share/ublue-os/motd/bazzite.md | tr '~' '\n' | /usr/bin/glow -s /usr/share/ublue-os/motd/themes/$COLOR_SCHEME/$THEME.json -w 78 -

sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_BRANCH%/$IMAGE_BRANCH_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/bazzite.md | tr '~' '\n' | /usr/bin/glow -s /usr/share/ublue-os/motd/themes/$COLOR_SCHEME/$THEME.json -w 78 -
fi
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,18 @@ _install-system-flatpaks:
# Configure grub bootmenu visibility and fix duplicate entries
configure-grub ACTION="":
#!/usr/bin/bash
source /usr/lib/ujust/ujust.sh
sudo touch /etc/default/grub
GRUB_STATE="$(grep -P "^GRUB_TIMEOUT_STYLE=hidden" /etc/default/grub)"
OPTION={{ ACTION }}
if [ "$GRUB_STATE" == "GRUB_TIMEOUT_STYLE=hidden" ]; then
GRUB_STATE="${b}Hidden${n}"
else
GRUB_STATE="${b}Not Hidden${n}"
fi
if [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-grub <option>"
echo " <option>: Specify the quick option to skip the prompt"
echo " Use 'hide' to select Hide Grub"
echo " Use 'unhide' to select Unhide Grub"
echo " Use 'fix' to select Fix double ostree entry"
exit 0
elif [ "$OPTION" == "" ]; then
echo "${bold}Grub menu configuration${normal}"
echo "Grub menu is set to: $GRUB_STATE"
OPTION=$(Choose "Hide Grub" "Unhide Grub" "Fix double ostree entry")
fi
if [[ "${OPTION,,}" =~ ^hide ]]; then
grep -q '^GRUB_TIMEOUT=' /etc/default/grub || echo 'GRUB_TIMEOUT=0' | sudo tee -a /etc/default/grub 1>/dev/null
sudo sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub
echo 'GRUB_TIMEOUT_STYLE=hidden' | sudo tee -a /etc/default/grub 1>/dev/null
echo 'GRUB_HIDDEN_TIMEOUT=1' | sudo tee -a /etc/default/grub 1>/dev/null
if [ -d /sys/firmware/efi ]; then
sudo grub2-mkconfig -o /etc/grub2-efi.cfg
else
sudo grub2-mkconfig -o /etc/grub2.cfg
fi
elif [[ "${OPTION,,}" =~ ^unhide ]]; then
sudo sed -i '/GRUB_HIDDEN_TIMEOUT=1/d' /etc/default/grub
sudo sed -i '/GRUB_TIMEOUT_STYLE=hidden/d' /etc/default/grub
sudo sed -i 's/GRUB_TIMEOUT=0/GRUB_TIMEOUT=5/g' /etc/default/grub
if [ -d /sys/firmware/efi ]; then
sudo grub2-mkconfig -o /etc/grub2-efi.cfg
else
sudo grub2-mkconfig -o /etc/grub2.cfg
fi
elif [[ "${OPTION,,}" =~ ^fix ]]; then
sudo grub2-switch-to-blscfg
if [ -d /sys/firmware/efi ]; then
sudo grub2-mkconfig -o /etc/grub2-efi.cfg
else
sudo grub2-mkconfig -o /etc/grub2.cfg
fi
fi

echo "Editing grub is no longer recommended and this script has been removed"
echo
echo "Reason:"
echo "Grub is auto-hidden now on successful boots and reappears only if you"
echo "shutdown too early. You can still access it by holding shift. Deck"
echo "images will also automatically rollback after 2 failed boots, so grub"
echo "will need to be visible for you to see that."
echo
echo "You can edit /etc/default/grub to change settings manually, then:"
echo "grub2-mkconfig -o /etc/grub2-efi.cfg"


# Add user to "input" group required by certain controller drivers
add-user-to-input-group:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Welcome to Bazzite 󰊴
󱋩 `%IMAGE_NAME%:%IMAGE_BRANCH%`
󰟀 `%GREENBOOT%`

|  Command | Description |
| ------- | ----------- |
Expand Down