Skip to content

Instantly share code, notes, and snippets.

@MartinNowak
Last active May 15, 2024 10:30
Show Gist options
  • Save MartinNowak/928703623b1d0fbe57c06259255a288a to your computer and use it in GitHub Desktop.
Save MartinNowak/928703623b1d0fbe57c06259255a288a to your computer and use it in GitHub Desktop.
dnf-automatic restart hook
#!/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
@MartinNowak
Copy link
Author

MartinNowak commented May 15, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment