aboutsummaryrefslogtreecommitdiffstats
path: root/roles/dnf_automatic/files
diff options
context:
space:
mode:
Diffstat (limited to 'roles/dnf_automatic/files')
-rw-r--r--roles/dnf_automatic/files/etc/dnf/automatic.conf12
-rw-r--r--roles/dnf_automatic/files/usr/local/sbin/dnf-auto-restart30
2 files changed, 42 insertions, 0 deletions
diff --git a/roles/dnf_automatic/files/etc/dnf/automatic.conf b/roles/dnf_automatic/files/etc/dnf/automatic.conf
new file mode 100644
index 0000000..926207f
--- /dev/null
+++ b/roles/dnf_automatic/files/etc/dnf/automatic.conf
@@ -0,0 +1,12 @@
+[commands]
+upgrade_type = default
+random_sleep = 0
+network_online_timeout = 60
+download_updates = yes
+apply_updates = yes
+
+[emitters]
+emit_via = stdio
+
+[base]
+debuglevel = 1
diff --git a/roles/dnf_automatic/files/usr/local/sbin/dnf-auto-restart b/roles/dnf_automatic/files/usr/local/sbin/dnf-auto-restart
new file mode 100644
index 0000000..76cc2d4
--- /dev/null
+++ b/roles/dnf_automatic/files/usr/local/sbin/dnf-auto-restart
@@ -0,0 +1,30 @@
+#!/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 [ "$(systemctl show "$service" -P RefuseManualStop)" = 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