dom0/qvm-dom0-update: Check if running as root at the beginning

This commit is contained in:
Marek Marczykowski 2011-09-14 16:44:43 +02:00
parent 93832b29db
commit 3dd6d654ea

View File

@ -17,6 +17,12 @@ if [ "$1" = "--help" ]; then
exit
fi
ID=$(id -ur)
if [ $ID != 0 ] ; then
echo "This script should be run as root, use sudo."
exit
fi
# We should ensure the clocks in Dom0 and UpdateVM are in sync
# becuase otherwise yum might complain about future timestamps
qvm-sync-dom0-clock
@ -49,25 +55,11 @@ while [ $# -gt 0 ]; do
done
if [ "x$PKGS" != "x" ]; then
ID=$(id -ur)
if [ $ID != 0 ] ; then
echo "This script should be run as root, use sudo next time."
echo "Now you can manually run yum install (use sudo again)."
exit
fi
yum $OPTS install $PKGS
elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
# Above file exists only when at least one package was downloaded
yum check-update
if [ $? -eq 100 ]; then
ID=$(id -ur)
if [ $ID != 0 ] ; then
echo "This script should be run as root, use sudo next time."
echo "Now you can manually run yum update (use sudo again)."
exit
fi
yum $OPTS update
fi
else