2013-03-16 17:54:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Get normal user name
|
|
|
|
LOCAL_USER=`users | sed -e 's/root *//' | cut -d' ' -f 1`
|
|
|
|
PIDFILE=/var/run/qubes/dom0-update-notification.pid
|
|
|
|
NOTIFY_ICON=/usr/share/qubes/icons/dom0-update-avail.svg
|
|
|
|
UPDATES_STAT_FILE=/var/lib/qubes/updates/dom0-updates-available
|
2014-04-11 05:04:57 +00:00
|
|
|
UPDATES_DISABLE_FLAG=/var/lib/qubes/updates/disable-updates
|
|
|
|
|
|
|
|
if [ -f "$UPDATES_DISABLE_FLAG" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-03-16 17:54:00 +00:00
|
|
|
|
|
|
|
# Do not allow multiple instances
|
|
|
|
[ -r $PIDFILE ] && kill -0 `cat $PIDFILE` && exit 0
|
|
|
|
# Teoretically the race can happen here, but this tool will be run once a few
|
|
|
|
# hours, so no real problem
|
|
|
|
echo $$ > $PIDFILE
|
|
|
|
trap "rm $PIDFILE" EXIT
|
|
|
|
|
|
|
|
# If no updates available - exit here
|
|
|
|
qubes-dom0-update --check-only >/dev/null && exit
|
|
|
|
RETCODE=$?
|
|
|
|
|
|
|
|
if [ "$RETCODE" -ne 100 ]; then
|
|
|
|
echo "ERROR: Error checking for updates" >&2
|
|
|
|
exit $RETCODE
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$LOCAL_USER" ]; then
|
|
|
|
echo "ERROR: no user logged in, cannot nofity about updates" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Touch stat file for qubes-manager
|
|
|
|
touch $UPDATES_STAT_FILE
|
|
|
|
|
|
|
|
# Notify about updates using system tray
|
2013-11-04 00:28:36 +00:00
|
|
|
su -c 'DISPLAY=:0 zenity --notification --window-icon=$NOTIFY_ICON --text="Qubes dom0 updates available."' $LOCAL_USER
|
2013-03-16 17:54:00 +00:00
|
|
|
|
2013-11-04 00:28:36 +00:00
|
|
|
su -c 'DISPLAY=:0 zenity --question --title="Qubes Dom0 updates" \
|
|
|
|
--text="There are updates for dom0 available, do you want to download them now?"' $LOCAL_USER || exit 0
|
2013-03-16 17:54:00 +00:00
|
|
|
|
|
|
|
su -c "DISPLAY=:0 qubes-dom0-update --gui" $LOCAL_USER
|
|
|
|
|
|
|
|
# Check if user installed updates
|
|
|
|
yum -q check-updates && rm $UPDATES_STAT_FILE
|