Commit 78d9614b authored by nimrod's avatar nimrod
Browse files

Maintenance tasks of Debian servers.

- mnpw is now working (enough) so let's put it to use for all of the
  various Nagios-style checks.
- Add the monitoring plugins from monitoring-plugins.org/ for check_apt.
  Now I should get better alerts for pending updates. Regular updates
shuold be just a warning but security updates should be a critical
alert. Let's put it in production and see.
- Now with check_apt handling APT updates, write a small shell script
  for a Nagios-style check for firmware updates.
- And the last part of the updates, update flatpaks silently.
- Refactor of the general maintenance and btrfs-specific tasks.
- Tag the include_tasks tasks with always, so those tasks are always
  included so their tags are also evaluated.
- Remove the apt-transport-https package installation, it's a dummy
  package for apt since Debian Buster and Ubuntu Bionic.
parent f9903a11
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

apt-get update
apt-get dist-upgrade --download-only --yes
apt-get autoclean

roles/debian_server/files/daily

deleted100755 → 0
+0 −21
Original line number Diff line number Diff line
#!/bin/sh
set -eu

apt-get update
apt-get dist-upgrade --download-only --yes
apt-get autoclean

if command -v flatpak >/dev/null 2>&1
then
    flatpak --system update --appstream
    flatpak --system update --assumeyes
    flatpak --system uninstall --unused --assumeyes
fi

fwupdmgr --assume-yes get-updates

if  [ "$(apt list --upgradable 2>/dev/null | wc -l)" -gt '1' ] || \
    [ -n "$(fwupdmgr --assume-yes get-updates)" ]
then
    curl "https://notify.shore.co.il/send?message=$(hostname --short)%20has%20pending%20updates."
fi
+12 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

if ! which flatpak >/dev/null
then
    echo 'Flatpak not installed, exiting.'
    exit
fi

flatpak --system update --appstream
flatpak --system update --assumeyes
flatpak --system uninstall --unused --assumeyes
+15 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

# First to download an updated list silently.
fwupdmgr --assume-yes get-updates 1>/dev/null

# Now to check if there are pending updates.
if [ "$(fwupdmgr --assume-yes get-updates | wc -l)" -gt 1 ]
then
    echo 'Available firmware updates.'
    exit 2
else
    echo 'Firmware is up to date.'
    exit 0
fi
+0 −9
Original line number Diff line number Diff line
# vim: filetype=systemd
[Unit]
Description=Check if a restart is needed
ConditionACPower=true
After=network-online.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'needrestart -p || curl "https://notify.shore.co.il/send?message=$(hostname --short)%%20needs%%20to%%20be%%20restarted."'
Loading