diff --git a/etc/greenboot/green.d/00_grub_fallback.sh b/etc/greenboot/green.d/01_ostree_grub2_fallback.sh similarity index 83% rename from etc/greenboot/green.d/00_grub_fallback.sh rename to etc/greenboot/green.d/01_ostree_grub2_fallback.sh index 3505856..c6f67b5 100644 --- a/etc/greenboot/green.d/00_grub_fallback.sh +++ b/etc/greenboot/green.d/01_ostree_grub2_fallback.sh @@ -5,4 +5,3 @@ set -euo pipefail if grub2-editenv list | grep -q "^boot_counter=-1$"; then rpm-ostree rollback fi -grub2-editenv - set boot_success=1 diff --git a/etc/greenboot/green.d/02_grub2_boot_success.sh b/etc/greenboot/green.d/02_grub2_boot_success.sh new file mode 100644 index 0000000..8c21406 --- /dev/null +++ b/etc/greenboot/green.d/02_grub2_boot_success.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -euo pipefail + +grub2-editenv - set boot_success=1 diff --git a/etc/greenboot/green.d/01_greenboot_motd.sh b/etc/greenboot/green.d/50_greenboot_motd.sh similarity index 100% rename from etc/greenboot/green.d/01_greenboot_motd.sh rename to etc/greenboot/green.d/50_greenboot_motd.sh diff --git a/etc/greenboot/red.d/01_redboot_motd.sh b/etc/greenboot/red.d/50_redboot_motd.sh similarity index 100% rename from etc/greenboot/red.d/01_redboot_motd.sh rename to etc/greenboot/red.d/50_redboot_motd.sh diff --git a/greenboot.spec b/greenboot.spec index cf7ce15..f0ce4f9 100644 --- a/greenboot.spec +++ b/greenboot.spec @@ -4,7 +4,7 @@ %global build_timestamp %(date +"%Y%m%d%H%M%%S") Name: greenboot -Version: 0.3 +Version: 0.4 Release: 1%{?dist} Summary: Generic Health Check Framework for systemd License: LGPLv2+ @@ -20,23 +20,35 @@ Requires: systemd %{summary}. %package motd -Summary: MotD updater for greenboot +Summary: Message of the Day updater for greenboot +Requires: greenboot Requires: pam >= 1.3.1 %description motd -Message of the Day updater for greenboot +%{summary}. + +%package ostree-grub2 +Summary: greenboot scripts for OSTree-based systems using the Grub2 bootloader +Requires: greenboot +Requires: greenboot-grub2 +Requires: greenboot-reboot -%package ostree -Summary: OSTree specific scripts for greenboot +%description ostree-grub2 +%{summary}. -%description ostree -OSTree specific scripts for greenboot +%package grub2 +Summary: Grub2 specific scripts for greenboot +Requires: greenboot + +%description grub2 +%{summary}. %package reboot Summary: Reboot on red status for greenboot +Requires: greenboot %description reboot -Reboot on red status for greenboot +%{summary}. %prep %setup -n %{github_project}-%{version} @@ -49,23 +61,19 @@ install -Dpm 0644 usr/lib/systemd/system/greenboot.target %{buildroot}%{_unitdir install -Dpm 0644 usr/lib/systemd/system/greenboot-healthcheck.service %{buildroot}%{_unitdir}/greenboot-healthcheck.service install -Dpm 0644 usr/lib/systemd/system/greenboot.service %{buildroot}%{_unitdir}/greenboot.service install -Dpm 0644 usr/lib/systemd/system/redboot.service %{buildroot}%{_unitdir}/redboot.service +mkdir -p %{buildroot}/run/%{name} +mkdir -p %{buildroot}%{_sysconfdir}/motd.d mkdir -p %{buildroot}%{_sysconfdir}/%{name}/check/required.d -install -Dpm 0755 etc/greenboot/check/required.d/00_required_scripts_start.sh %{buildroot}%{_sysconfdir}/%{name}/check/required.d/00_required_scripts_start.sh mkdir %{buildroot}%{_sysconfdir}/%{name}/check/wanted.d -install -Dpm 0755 etc/greenboot/check/wanted.d/00_wanted_scripts_start.sh %{buildroot}%{_sysconfdir}/%{name}/check/wanted.d/00_wanted_scripts_start.sh mkdir %{buildroot}%{_sysconfdir}/%{name}/green.d -install -Dpm 0755 etc/greenboot/green.d/00_grub_fallback.sh %{buildroot}%{_sysconfdir}/%{name}/green.d/00_grub_fallback.sh -install -Dpm 0755 etc/greenboot/green.d/00_greenboot_notification.sh %{buildroot}%{_sysconfdir}/%{name}/green.d/00_greenboot_notification.sh -install -Dpm 0755 etc/greenboot/green.d/01_greenboot_motd.sh %{buildroot}%{_sysconfdir}/%{name}/green.d/01_greenboot_motd.sh mkdir %{buildroot}%{_sysconfdir}/%{name}/red.d -install -Dpm 0755 etc/greenboot/red.d/00_redboot_notification.sh %{buildroot}%{_sysconfdir}/%{name}/red.d/00_redboot_notification.sh -install -Dpm 0755 etc/greenboot/red.d/01_redboot_motd.sh %{buildroot}%{_sysconfdir}/%{name}/red.d/01_redboot_motd.sh -install -Dpm 0755 etc/greenboot/red.d/99_reboot.sh %{buildroot}%{_sysconfdir}/%{name}/red.d/99_reboot.sh -install -Dpm 0644 etc/greenboot/motd/greenboot.motd %{buildroot}%{_sysconfdir}/%{name}/motd/greenboot.motd -install -Dpm 0644 etc/greenboot/motd/redboot.motd %{buildroot}%{_sysconfdir}/%{name}/motd/redboot.motd -mkdir -p %{buildroot}/run/greenboot -mkdir -p %{buildroot}%{_sysconfdir}/motd.d -ln -snf /run/greenboot/motd %{buildroot}%{_sysconfdir}/motd.d/greenboot +mkdir %{buildroot}%{_sysconfdir}/%{name}/motd +install -Dpm 0755 etc/greenboot/check/required.d/* %{buildroot}%{_sysconfdir}/%{name}/check/required.d +install -Dpm 0755 etc/greenboot/check/wanted.d/* %{buildroot}%{_sysconfdir}/%{name}/check/wanted.d +install -Dpm 0755 etc/greenboot/green.d/* %{buildroot}%{_sysconfdir}/%{name}/green.d +install -Dpm 0755 etc/greenboot/red.d/* %{buildroot}%{_sysconfdir}/%{name}/red.d +install -Dpm 0644 etc/greenboot/motd/* %{buildroot}%{_sysconfdir}/%{name}/motd +ln -snf /run/greenboot/motd %{buildroot}%{_sysconfdir}/motd.d/%{name} %post %systemd_post greenboot.target @@ -107,15 +115,17 @@ ln -snf /run/greenboot/motd %{buildroot}%{_sysconfdir}/motd.d/greenboot %{_sysconfdir}/%{name}/red.d/00_redboot_notification.sh %files motd -%{_sysconfdir}/%{name}/motd/greenboot.motd -%{_sysconfdir}/%{name}/motd/redboot.motd -%{_sysconfdir}/%{name}/green.d/01_greenboot_motd.sh -%{_sysconfdir}/%{name}/red.d/01_redboot_motd.sh -%dir /run/greenboot -%config %{_sysconfdir}/motd.d/greenboot - -%files ostree -%{_sysconfdir}/%{name}/green.d/00_grub_fallback.sh +%dir /run/%{name} +%config %{_sysconfdir}/motd.d/%{name} +%{_sysconfdir}/%{name}/motd/ +%{_sysconfdir}/%{name}/green.d/50_greenboot_motd.sh +%{_sysconfdir}/%{name}/red.d/50_redboot_motd.sh + +%files ostree-grub2 +%{_sysconfdir}/%{name}/green.d/01_ostree_grub2_fallback.sh + +%files grub2 +%{_sysconfdir}/%{name}/green.d/02_grub2_boot_success.sh %files reboot %{_sysconfdir}/%{name}/red.d/99_reboot.sh diff --git a/tests/Vagrantfile b/tests/Vagrantfile index d72f7d4..2a56fc8 100644 --- a/tests/Vagrantfile +++ b/tests/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", inline: <<-SHELL curl https://copr.fedorainfracloud.org/coprs/lorbus/greenboot/repo/fedora-28/lorbus-greenboot-fedora-28.repo --output /etc/yum.repos.d/_copr_lorbus-greenboot.repo - rpm-ostree install greenboot greenboot-motd + rpm-ostree install greenboot greenboot-motd greenboot-ostree-grub2 rpm-ostree ex livefs # Uncomment the following line to test red boot status behaviour # mv /home/vagrant/sync/10_failing_check.sh /etc/greenboot/check/required.d/10_failing_check.sh diff --git a/tests/run_ostree_upgrade.sh b/tests/run_ostree_upgrade.sh index 5b7aa00..896d514 100644 --- a/tests/run_ostree_upgrade.sh +++ b/tests/run_ostree_upgrade.sh @@ -3,5 +3,5 @@ set -euo pipefail rpm-ostree upgrade grub2-editenv - set boot_success=0 -grub2-editenv - set boot_counter=2 +grub2-editenv - set boot_counter=3 reboot