From 790d78b4f01bb8ec98cb6ea5a4a0b9f0bfcccf80 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: May 08 2024 18:02:00 +0000 Subject: [PATCH 1/2] Switch the branding fixup service to use sd-notify --- diff --git a/asahi-branding-fixup.service b/asahi-branding-fixup.service index 6c63b86..b054188 100644 --- a/asahi-branding-fixup.service +++ b/asahi-branding-fixup.service @@ -6,9 +6,8 @@ After=network-online.target Wants=network-online.target [Service] -Type=oneshot +Type=notify TimeoutSec=0 -RemainAfterExit=yes ExecStartPre=/usr/libexec/fedora-asahi-remix-scripts/check-network-online.sh ExecStart=/usr/libexec/fedora-asahi-remix-scripts/fixup-branding-packages.sh RestartSec=1h diff --git a/fedora-asahi-remix-scripts.spec b/fedora-asahi-remix-scripts.spec index 8ca0eab..856ba95 100644 --- a/fedora-asahi-remix-scripts.spec +++ b/fedora-asahi-remix-scripts.spec @@ -1,5 +1,5 @@ Name: fedora-asahi-remix-scripts -Version: 20240506 +Version: 20240508 Release: 1%{?dist} Summary: Fedora Asahi Remix utility scripts @@ -59,6 +59,9 @@ systemctl enable asahi-branding-fixup.service %{_libexecdir}/%{name}/ %changelog +* Wed May 08 2024 Neal Gompa - 20240508-1 +- Switch the branding fixup service to use sd-notify + * Mon May 06 2024 Neal Gompa - 20240506-1 - Check network status and restart fixup service until it works diff --git a/fixup-branding-packages.sh b/fixup-branding-packages.sh index 83e2b5c..3b82188 100644 --- a/fixup-branding-packages.sh +++ b/fixup-branding-packages.sh @@ -6,6 +6,8 @@ set -eu -o pipefail # Test if the basic identity is not used if ! rpm --quiet --query fedora-asahi-remix-release-identity-basic; then systemctl disable asahi-branding-fixup.service + # Tell systemd we're done + echo "READY=1" | systemd-notify exit 0 fi @@ -13,6 +15,8 @@ fi CONNECTION_STATUS="$(curl -s http://fedoraproject.org/static/hotspot.txt)" if [ "${CONNECTION_STATUS}" != "OK" ]; then echo "No internet connectivity, exiting..." + # Tell systemd we're done + echo "READY=1" | systemd-notify exit 0 fi @@ -21,20 +25,29 @@ fi if rpm --quiet --query fedora-asahi-remix-release-kde; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-kde systemctl disable asahi-branding-fixup.service + # Tell systemd we're done + echo "READY=1" | systemd-notify exit 0 fi if rpm --quiet --query fedora-asahi-remix-release-workstation; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-workstation systemctl disable asahi-branding-fixup.service + # Tell systemd we're done + echo "READY=1" | systemd-notify exit 0 fi if rpm --quiet --query fedora-asahi-remix-release-server; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-server systemctl disable asahi-branding-fixup.service + # Tell systemd we're done + echo "READY=1" | systemd-notify exit 0 fi +# Tell systemd we're done +echo "READY=1" | systemd-notify systemctl disable asahi-branding-fixup.service + exit 0 From 7afe36d0178c8190cb71efc539f0688725edf88b Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Jun 22 2024 05:34:39 +0000 Subject: [PATCH 2/2] Switch the branding fixup service to timer-based run --- diff --git a/asahi-branding-fixup.service b/asahi-branding-fixup.service index b054188..3899278 100644 --- a/asahi-branding-fixup.service +++ b/asahi-branding-fixup.service @@ -6,12 +6,8 @@ After=network-online.target Wants=network-online.target [Service] -Type=notify +Type=oneshot TimeoutSec=0 +RemainAfterExit=yes ExecStartPre=/usr/libexec/fedora-asahi-remix-scripts/check-network-online.sh ExecStart=/usr/libexec/fedora-asahi-remix-scripts/fixup-branding-packages.sh -RestartSec=1h -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/asahi-branding-fixup.timer b/asahi-branding-fixup.timer new file mode 100644 index 0000000..73249b0 --- /dev/null +++ b/asahi-branding-fixup.timer @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MIT + +[Unit] +Description=Fix Fedora Asahi branding packages +After=network-online.target +Wants=network-online.target +Requires=asahi-branding-fixup.service + +[Timer] +OnBootSec=10min +OnUnitActiveSec=1h + +[Install] +WantedBy=timers.target diff --git a/fedora-asahi-remix-scripts.spec b/fedora-asahi-remix-scripts.spec index 856ba95..f40c8f7 100644 --- a/fedora-asahi-remix-scripts.spec +++ b/fedora-asahi-remix-scripts.spec @@ -1,5 +1,5 @@ Name: fedora-asahi-remix-scripts -Version: 20240508 +Version: 20240622 Release: 1%{?dist} Summary: Fedora Asahi Remix utility scripts @@ -27,6 +27,7 @@ Utility scripts for the Fedora Asahi Remix. install -Dpm0644 -t %{buildroot}%{_unitdir} asahi-extras-firstboot.service install -Dpm0644 -t %{buildroot}%{_unitdir} asahi-setup-swap-firstboot.service install -Dpm0644 -t %{buildroot}%{_unitdir} asahi-branding-fixup.service +install -Dpm0644 -t %{buildroot}%{_unitdir} asahi-branding-fixup.timer install -Dpm0755 -t %{buildroot}%{_libexecdir}/%{name} install-extras.sh install -Dpm0755 -t %{buildroot}%{_libexecdir}/%{name} setup-swap.sh install -Dpm0755 -t %{buildroot}%{_libexecdir}/%{name} fixup-branding-packages.sh @@ -35,30 +36,34 @@ install -Dpm0755 -t %{buildroot}%{_libexecdir}/%{name} check-network-online.sh %post %systemd_post asahi-extras-firstboot.service %systemd_post asahi-setup-swap-firstboot.service -%systemd_post asahi-branding-fixup.service +%systemd_post asahi-branding-fixup.timer %if 0%{?fedora} && 0%{?fedora} < 42 # Special case just to deal with broken branding issues -systemctl enable asahi-branding-fixup.service +systemctl enable asahi-branding-fixup.timer %endif %preun %systemd_preun asahi-extras-firstboot.service %systemd_preun asahi-setup-swap-firstboot.service -%systemd_preun asahi-branding-fixup.service +%systemd_preun asahi-branding-fixup.timer %postun %systemd_postun asahi-extras-firstboot.service %systemd_postun asahi-setup-swap-firstboot.service -%systemd_postun asahi-branding-fixup.service +%systemd_postun asahi-branding-fixup.timer %files %license LICENSE %{_unitdir}/asahi-extras-firstboot.service %{_unitdir}/asahi-setup-swap-firstboot.service %{_unitdir}/asahi-branding-fixup.service +%{_unitdir}/asahi-branding-fixup.timer %{_libexecdir}/%{name}/ %changelog +* Sat Jun 22 2024 Neal Gompa - 20240622-1 +- Switch the branding fixup service to timer-based run + * Wed May 08 2024 Neal Gompa - 20240508-1 - Switch the branding fixup service to use sd-notify diff --git a/fixup-branding-packages.sh b/fixup-branding-packages.sh index 3b82188..dfb6b73 100644 --- a/fixup-branding-packages.sh +++ b/fixup-branding-packages.sh @@ -5,9 +5,7 @@ set -eu -o pipefail # Test if the basic identity is not used if ! rpm --quiet --query fedora-asahi-remix-release-identity-basic; then - systemctl disable asahi-branding-fixup.service - # Tell systemd we're done - echo "READY=1" | systemd-notify + systemctl disable asahi-branding-fixup.timer exit 0 fi @@ -15,8 +13,6 @@ fi CONNECTION_STATUS="$(curl -s http://fedoraproject.org/static/hotspot.txt)" if [ "${CONNECTION_STATUS}" != "OK" ]; then echo "No internet connectivity, exiting..." - # Tell systemd we're done - echo "READY=1" | systemd-notify exit 0 fi @@ -24,30 +20,23 @@ fi if rpm --quiet --query fedora-asahi-remix-release-kde; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-kde - systemctl disable asahi-branding-fixup.service - # Tell systemd we're done - echo "READY=1" | systemd-notify + systemctl disable asahi-branding-fixup.timer exit 0 fi if rpm --quiet --query fedora-asahi-remix-release-workstation; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-workstation - systemctl disable asahi-branding-fixup.service - # Tell systemd we're done - echo "READY=1" | systemd-notify + systemctl disable asahi-branding-fixup.timer exit 0 fi if rpm --quiet --query fedora-asahi-remix-release-server; then dnf --assumeyes install --allowerasing fedora-asahi-remix-release-identity-server - systemctl disable asahi-branding-fixup.service - # Tell systemd we're done - echo "READY=1" | systemd-notify + systemctl disable asahi-branding-fixup.timer exit 0 fi -# Tell systemd we're done -echo "READY=1" | systemd-notify -systemctl disable asahi-branding-fixup.service +# Stop future runs of the service +systemctl disable asahi-branding-fixup.timer exit 0