diff options
author | Stonewall Jackson <stonewall@sacredheartsc.com> | 2023-02-04 01:23:43 -0500 |
---|---|---|
committer | Stonewall Jackson <stonewall@sacredheartsc.com> | 2023-02-04 01:52:13 -0500 |
commit | 0261e875679f1bf63c8d689da7fc7e014597885d (patch) | |
tree | 3f19cd74a0c1070944f75437f30b098d6ef2ffcb /roles/dnf_automatic/files | |
download | selfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.tar.gz selfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.zip |
initial commit
Diffstat (limited to 'roles/dnf_automatic/files')
-rw-r--r-- | roles/dnf_automatic/files/etc/dnf/automatic.conf | 12 | ||||
-rw-r--r-- | roles/dnf_automatic/files/usr/local/sbin/dnf-auto-restart | 30 |
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 |