blob: 4273ef08c220370be9a1212740adb4790cf40791 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/bin/bash
set -Eeu -o pipefail
shopt -s lastpipe
if ! dnf needs-restarting --reboothint; then
shutdown --reboot '+5' 'Rebooting to apply package upgrades'
exit 0
fi
SERVICES=()
dnf needs-restarting --services | while read -r service; do
if [[ $service = user@* ]]; then
continue
elif [ "$service" = 'auditd.service' ]; then
service auditd restart
elif [ "$(systemctl show "$service" --property RefuseManualStop --value)" = yes ]; then
continue
else
SERVICES+=("$service")
fi
done
printf '\n'
if (( ${#SERVICES[@]} > 0 )); then
echo 'restarting the following units:'
printf ' * %s\n' "${SERVICES[@]}"
systemctl restart "${SERVICES[@]}"
else
echo 'All services are up to date.'
fi
|