Portable System Update on Shutdown

Another Update on Shutdown Solution?

While the other solutions on this blog (here and here) are probably more elegant they have dependencies on either the desktop (Gnome) or systemd. This solution should be portable across Linux distros and desktops.

The Solution

freedesktop.org define a specification for application launchers. These launchers will run on all compatible desktops (which means almost all Linux desktops).

The desktop launcher for update on shutdown can be created using the following command:

cat <<'EOF' | bash
echo "[Desktop Entry]
Name=Shutdown
Exec=gnome-terminal --command=\"sudo bash -c 'dnf -y upgrade; shutdown now'\"
Type=Application
Terminal=true" > ~/.local/share/applications/shutdown.desktop;
chmod u+x ~/.local/share/applications/shutdown.desktop;
ln -s ~/.local/share/applications/shutdown.desktop ~/Desktop/shutdown.desktop
EOF

This should give you a launcher on your desktop as well as in your normal application menu.

To make this work for your distribution you may need to change dnf -y upgrade to something else like apt-get update; apt-get -y upgrade; for Debian based distros.


Tags: security