123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #! /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
- # Source function library.
- . /etc/init.d/functions
- prog="virtualbox"
- PROGNAME=VBoxSVC
- RETVAL=0
- running() {
- grep -q "^$1 " /proc/modules
- }
- start() {
- # Check if it is already running
- if ! running vboxdrv; then
- echo -n $"Starting $prog: "
- if ! modprobe vboxdrv > /dev/null 2>&1; then
- failure "Loading vboxdrv module:"
- return
- fi
- if ! modprobe vboxnetflt > /dev/null 2>&1; then
- failure "Loading vboxnetflt module:"
- return
- fi
- if ! modprobe vboxnetadp > /dev/null 2>&1; then
- failure "Loading vboxnetadp module:"
- return
- fi
- touch /var/lock/subsys/$PROGNAME
- success
- fi
- echo
- }
- stop() {
- echo -n "Stopping $prog: "
- if running vboxdrv; then
- if running vboxnetflt; then
- if ! rmmod vboxnetflt 2>/dev/null; then
- failure "Remove module vboxnetflt:"
- return
- fi
- fi
- if running vboxnetadp; then
- if ! rmmod vboxnetadp 2>/dev/null; then
- failure "Remove module vboxnetadp:"
- return
- fi
- fi
- if ! rmmod vboxdrv 2>/dev/null; then
- failure "Remove module vboxdrv:"
- return
- fi
- fi
- success
- echo
- }
- restart() {
- stop
- start
- }
- status() {
- echo -n $"$prog kernel module is "
- if running vboxdrv; then
- STATUS="loaded"
- else
- STATUS="not loaded"
- fi
- echo "$STATUS"
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- condrestart)
- if [ -f /var/lock/subsys/$PROGNAME ]; then
- restart
- fi
- ;;
- status)
- status
- ;;
- *)
- INITNAME=`basename $0`
- echo $"Usage: $0 {start|stop|restart|condrestart|status}"
- exit 1
- ;;
- esac
- exit $RETVAL
|