1

When PackageKit has updates fetched for installation and you use the Gnome GUI to shut down the machine, it is possible to set a checkbox to install updates before shut down. How can this be accomplished from command line without root? Example purpose: automating the execution of custom commands before shut down.

jimex
  • 31
  • 2

1 Answers1

1
# This will force fetching repository data and updates
pkcon get-updates
pkcon update --only-download

dbus-send --system --type=method_call --print-reply \
  --dest=org.freedesktop.PackageKit \
  /org/freedesktop/PackageKit \
  org.freedesktop.PackageKit.Offline.Trigger \
  string:power-off

if pkcon offline-get-prepared; then
  systemctl reboot
else
  systemctl poweroff
fi

If you remove the dbus-send command and replace the if block by systemctl reboot, the system will reboot instead.

jimex
  • 31
  • 2