VirtualBox/VirtualBox-initscript

80 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

#! /bin/sh
#
# virtualbox: Starts the VirtualBox kernel module
#
# chkconfig: 35 30 60
# description: VirtualBox Linux kernel module
#
### BEGIN INIT INFO
# Provides: vboxdrv
# Required-Start: $syslog
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: VirtualBox Linux kernel module
# Should-Start: dkms
### END INIT INFO
. /etc/sysconfig/rc
. $rc_functions
NAME=virtualbox
LOCKFILE=/var/lock/subsys/$NAME
MODULE=vboxdrv
MODULE2=vboxnetflt
running() {
/sbin/lsmod | grep -q $MODULE[^_-]
}
case "$1" in
start)
# Check if it is already running
if ! running; then
echo -n $"Starting"" $NAME: "
/sbin/modprobe $MODULE
/sbin/modprobe $MODULE2
[ -e /proc/bus/usb/devices ] || mount -t usbfs usbfs /proc/bus/usb -o devgid=30,devmode=664
evaluate_retval
[ $? -eq 0 ] && touch $LOCKFILE
else
echo "$NAME "$"daemon is already running"
fi
echo
;;
stop)
echo -n $"Stopping"" $NAME: "
killall -q VBoxSVC VBoxXPCOMIPCD
if running; then
/sbin/modprobe -r $MODULE2
/sbin/modprobe -r $MODULE
evaluate_retval
[ $? -eq 0 ] && rm -f $LOCKFILE
else
echo "$NAME "$"daemon is already stopped"
fi
echo
;;
restart)
$0 stop
$0 start
;;
status)
if running; then
STATUS="loaded"
else
STATUS="not loaded"
fi
echo "$NAME kernel module is $STATUS."
;;
condrestart)
[ -e "$DAEMONLOCK" ] && $0 restart || :
;;
*)
echo $"Usage: ""/etc/init.d/$NAME {start|stop|restart|condrestart|status}"
exit 1
;;
esac
: