Update switch_virt.sh

This commit is contained in:
David Tomaschik
2017-01-06 21:20:19 -08:00
parent d79dbd890f
commit dc9fbe1cd9

View File

@@ -1,13 +1,28 @@
#!/bin/sh
#!/bin/bash
if [ "$1" -eq "kvm" ] ; then
if [ $# -lt 1 ] ; then
echo "Usage: $0 <kvm|vbox>" >&2
exit 1
fi
if [ `whoami` != "root" ] ; then
if which sudo >/dev/null 2>&1 ; then
sudo $0 $*
exit
fi
echo "Sorry, this requires root." >&2
exit 1
fi
if [ "$1" == "kvm" ] ; then
/etc/init.d/virtualbox stop
modprobe kvm
modprobe kvm_intel
elif [ "$1" -eq "vbox" ] ; then
elif [ "$1" == "vbox" ] ; then
rmmod kvm_intel
rmmod kvm
/etc/init.d/virtualbox start
else
echo 'WTF?' >&2
exit 1
fi