#!/bin/sh

# This script should open some GUI to install updates.
# If you are creating package for other distribution, feel free to replace it
# with distribution-specific script.

if [ -e /etc/redhat-release -a -x /usr/bin/dnf ]; then
    update_cmd='dnf update --best'
elif [ -e /etc/redhat-release -a -x /usr/bin/yum ]; then
    update_cmd='yum update'
elif [ -e /etc/debian_version ]; then
    update_cmd='apt-get update && apt-get -V dist-upgrade'
elif [ -e /etc/arch-release -a -x /usr/bin/powerpill ]; then
    update_cmd='powerpill -Suy'
elif [ -e /etc/arch-release ]; then
    update_cmd='pacman -Suy'
else
    update_cmd='echo Unsupported distribution, install updates manually; bash -i'
fi
xterm -title update -e su -l -c "$update_cmd; echo Done.; echo Press Enter to shutdown the template, or Ctrl-C to just close this window; read x && poweroff;"

# Notify dom0 about installed updates
su -c 'service qubes-update-check start'