Antworten auf Ihre häufigsten Fragen

Wie richte ich automatische Updates bei meinem AlmaLinux System ein

Verwendung von DNF-Automatic für die Automatisierung von Systemupdateinstallationen.

Das Programm dnf-automatic automatisiert die Installation von Systemupdates auf RPM basierten Betriebssystemen mit dem DNF Paketmanager, wie z.b. Fedora Linux oder Almalinux.

Automatisierte Installation:

Wenn Sie unseren Autoinstaller direkt herunterladen und eventuell anpassen möchten verwenden Sie bitte den folgenden Befehl:

wget www.hosteurope.de/fileadmin/faq/scripte/dnfautomaticalma.sh.zip && unzip dnfautomaticalma.sh.zip
sha256sum -c <<<"ff80214cf5d471bb62b8d0383a22022736569efee463f8b811a184c8edd58639 ./dnf_automatic_alma.sh"

Hier sollte als Rückmeldung der Wert
dnf_automatic_alma.sh: ok
zurück gegeben werden. Danach kann das Program mit den Befehlen

chmod +x ./dnf_weekly_automatic_alma.sh
bash ./dnf_weekly_automatic_alma.sh

In der Standardkonfiguration wird Ihr Server jeden Tag morgens zwischen 4 und 5 Uhr Nachts alle ausstehenden Updates installieren.

Manuelle Installation:

Für eine manuelle Installation loggen Sie sich bitte per SSH auf Ihrem Server ein und folgen Sie dem folgenden Tutorial:

Schritt 1 - Installation von DNF Automatic über den Paketmanager und erstellen des Konfigurationsverzeichnisses:

Installation von dnf-automatic und Erstellen des Konfigurationsverzeichnisses:

sudo dnf install -y dnf-automatic
sudo install -d -m 0755 /etc/dnf

Schritt 2 - Anlegen und Befüllen der Konfigurationsdateien für den Automatismus:

touch /etc/dnf/automatic-weekly.conf
chmod 0644 /etc/dnf/automatic-weekly.conf
nano /etc/dnf/automatic-weekly.conf

Inhalt der Datei:

[commands]
upgrade_type = default
download_updates = yes
apply_updates = yes

# 1 hour random sleep.
random_sleep = 0

# only reboot when required.
reboot = when-needed

# five minute warning before restart.
reboot_command = /usr/sbin/shutdown -r +5 "reboot after updates"

[base]
best = false

Schritt 3 - Installation des Hintergrunddienstes:

touch /etc/systemd/system/dnf-automatic-weekly.service
nano /etc/systemd/system/dnf-automatic-weekly.service

Inhalt der Datei:

[Unit]
Description=Weekly DNF updates w. conditional reboot
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
# ExecStart=/usr/local/cpanel/scripts/upcp
ExecStart=${DNF_AUTOMATIC} /etc/dnf/automatic-weekly.conf
TimeoutStartSec=infinity

Die Zeile „ExecStart=/usr/local/cpanel/scripts/upcp“ kann auf Systemen mit cpanel auskommentiert werden um außerdem cpanel Updates während des Updatevorgangs zu installieren. Dies passiert zusätzlich zu den bereits konfigurierten cpanel Updates. Bei nicht cPanel Systemen kann diese Zeile gelöscht werden.

Schritt 4 - Einrichtung der zeitlichen Steuerung:

Anlegen der Konfiguration:

touch /etc/systemd/system/dnf-automatic-weekly.timer
nano /etc/systemd/system/dnf-automatic-weekly.timer

Inhalt:

[Unit]
Description=Scheduled DNF-Updates

[Timer]
OnCalendar=*-*-* 04:00:00
RandomizedDelaySec=0
AccuracySec=1s

# Do not retry if scheduled date is skipped
Persistent=false

Unit=dnf-automatic-weekly.service

[Install]
WantedBy=timers.target

Hier können Sie einige Anpassungen vornehmen.

OnCalendar=DAY  *-*-* xx:yy:zz kann mit jedem englischen Tag (Mon Tue Wed Thu Fri Sat Sun) und jeder erdenklichen Zeit (XX Stunde, YY Minute, ZZ Sekunde) nach Ihrem ermessen befüllt werden, falls Sie dies genauer steuern möchten.

Schritt 5 - Cleanup:

Mit diesem Script können Sie eventuell vorher eingerichtete Timer deaktivieren, danach wird der neue Timer installiert:

for timer in dnf-automatic.timer dnf-automatic-install.timer dnf-automatic-download.timer dnf-automatic-notifyonly.timer; do
if systemctl cat "${timer}" >/dev/null 2>&1; then
systemctl disable --now "${timer}"
fi
done
systemctl daemon-reload && systemctl enable --now dnf-automatic-weekly.timer

Sie könnten die korrekte Installation durch ausführen des folgenden Befehls prüfen:

systemctl list-timers --all dnf-automatic-weekly.timer

Sie sind fertig!


Using DNF Automatic to automate system update installations.
The dnf-automatic program automates the installation of system updates on RPM-based operating systems that use the DNF package manager, such as Fedora Linux or AlmaLinux.

Automated installation:

If you would like to download our auto-installer directly and possibly customize it, please use the following command:

wget www.hosteurope.de/fileadmin/faq/scripte/dnfautomaticalma.sh.zip && unzip dnfautomaticalma.sh.zip
sha256sum -c <<<"ff80214cf5d471bb62b8d0383a22022736569efee463f8b811a184c8edd58639 ./dnf_weekly_automatic_alma.sh"

The expected response here is the value

dnf_weekly_automatic_alma.sh: ok

Afterwards, you can execute the script:

chmod +x ./dnf_weekly_automatic_alma.sh
bash ./dnf_weekly_automatic_alma.sh

This will install and configure DNF-automatic to run daily between 4 and 5 AM server time.

Manual installation:
For a manual installation, please log in to your server via SSH and follow the tutorial below:
DNF Automatic can be installed directly through your package manager.
To do so, simply log in to your server via SSH and follow the instructions below:

Step 1 – Installing DNF Automatic via the package manager and creating the configuration directory:

sudo dnf install -y dnf-automatic
sudo install -d -m 0755 /etc/dnf

Step 2 – Creating and populating the configuration files for the automation:

Schritt 2 - Anlegen und Befüllen der Konfigurationsdateien für den Automatismus:

Creation of file:

touch /etc/dnf/automatic-weekly.conf
chmod 0644 /etc/dnf/automatic-weekly.conf
nano /etc/dnf/automatic-weekly.conf

Content of file:

[commands]
upgrade_type = default
download_updates = yes
apply_updates = yes

# no random sleep.
random_sleep = 0

# only reboot when required.
reboot = when-needed

# five minute warning before restart,.
reboot_command = /usr/sbin/shutdown -r +5 "Neustart nach automatischen Systemupdates"

[base]
best = false

Step 3 – Installing the background service:

Creation of file:

touch /etc/systemd/system/dnf-automatic-weekly.service
nano /etc/systemd/system/dnf-automatic-weekly.service

Content of file:

[Unit]
Description=Weekly DNF updates w. conditional reboot
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
# ExecStart=/usr/local/cpanel/scripts/upcp
ExecStart=${DNF_AUTOMATIC} /etc/dnf/automatic-weekly.conf
TimeoutStartSec=infinity

Adjusting the configuration file:
On systems with cPanel, the line “ExecStart=/usr/local/cpanel/scripts/upcp” can be commented out in order to also install cPanel updates during the update process. This happens in addition to the cPanel updates that are already configured. On non-cPanel systems, this line can be deleted.

Step 4 – Setting up the scheduled timing:

Creation of file:

touch /etc/systemd/system/dnf-automatic-weekly.timer
nano /etc/systemd/system/dnf-automatic-weekly.timer

Content of file:

[Unit]
Description=Scheduled DNF-Updates

[Timer]
OnCalendar=*-*-* 04:00:00
RandomizedDelaySec=0
AccuracySec=1s

# Do not retry if scheduled date is skipped
Persistent=false

Unit=dnf-automatic-weekly.service

[Install]
WantedBy=timers.target

You can adjust the start time to your preferences.

OnCalendar=DAY  *-*-* xx:yy:zz can be replaced with any english day (Mon Tue Wed Thu Fri Sat Sun) and any time value (XX hour, YY minute, ZZ second) based on your own preferences, if you so wish.

Schritt 5 - Cleanup:

This script disables any eventual existing timers, and then sets up the new timer:

for timer in dnf-automatic.timer dnf-automatic-install.timer dnf-automatic-download.timer dnf-automatic-notifyonly.timer; do
if systemctl cat "${timer}" >/dev/null 2>&1; then
systemctl disable --now "${timer}"
fi
done
systemctl daemon-reload && systemctl enable --now dnf-automatic-weekly.timer

You can check if the timer has been set up properly using this command:

systemctl list-timers --all dnf-automatic-weekly.timer


Dateien:
updatescript