qubes-dom0-updates.cron 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Get normal user name
  3. LOCAL_USER=`users | sed -e 's/root *//' | cut -d' ' -f 1`
  4. PIDFILE=/var/run/qubes/dom0-update-notification.pid
  5. NOTIFY_ICON=/usr/share/qubes/icons/dom0-update-avail.svg
  6. UPDATES_STAT_FILE=/var/lib/qubes/updates/dom0-updates-available
  7. # Do not allow multiple instances
  8. [ -r $PIDFILE ] && kill -0 `cat $PIDFILE` && exit 0
  9. # Teoretically the race can happen here, but this tool will be run once a few
  10. # hours, so no real problem
  11. echo $$ > $PIDFILE
  12. trap "rm $PIDFILE" EXIT
  13. # If no updates available - exit here
  14. qubes-dom0-update --check-only >/dev/null && exit
  15. RETCODE=$?
  16. if [ "$RETCODE" -ne 100 ]; then
  17. echo "ERROR: Error checking for updates" >&2
  18. exit $RETCODE
  19. fi
  20. if [ -z "$LOCAL_USER" ]; then
  21. echo "ERROR: no user logged in, cannot nofity about updates" >&2
  22. exit 1
  23. fi
  24. # Touch stat file for qubes-manager
  25. touch $UPDATES_STAT_FILE
  26. # Notify about updates using system tray
  27. zenity --notification --window-icon=$NOTIFY_ICON --text="Qubes dom0 updates available."
  28. zenity --question --title="Qubes Dom0 updates" \
  29. --text="There are updates for dom0 available, do you want to download them now?" || exit 0
  30. su -c "DISPLAY=:0 qubes-dom0-update --gui" $LOCAL_USER
  31. # Check if user installed updates
  32. yum -q check-updates && rm $UPDATES_STAT_FILE