Last active
May 15, 2024 10:30
-
-
Save MartinNowak/928703623b1d0fbe57c06259255a288a to your computer and use it in GitHub Desktop.
dnf-automatic restart hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ueEo pipefail | |
if ! dnf needs-restarting --reboothint; then | |
systemctl reboot --message='Rebooting after dnf-automatic updates' | |
fi | |
mapfile -t services < <(dnf needs-restarting --services) | |
if [[ "${#services[*]}" -ne 0 ]]; then | |
echo "Restarting ${services[*]}" | |
printf '%s\n' "${services[@]}" | xargs --no-run-if-empty --max-args=1 systemctl restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DNF needs-restarting Plugin