Sophie

Sophie

distrib > Mandriva > 2008.0 > x86_64 > media > main-backports-src > by-pkgid > 51fdad8cbf079a7084947eef044d5f84 > files > 12

virtualbox-1.5.6-1mdv2008.0.src.rpm

#! /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

MODULE=vboxdrv
DAEMON=virtualbox
PROGNAME=VBoxSVC

RETVAL=0

running() {
    /sbin/lsmod | grep -q $MODULE[^_-]
}

start() {
    # Check if it is already running
    if ! running; then
	gprintf "Starting %s daemon: " "$DAEMON"
	/sbin/modprobe $MODULE
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
	    touch /var/lock/subsys/$PROGNAME
	    success
	else
	    failure
	fi
    fi
    echo
    return $RETVAL
}

stop() {
    gprintf "Stopping %s daemon: " "$DAEMON"
    killall -q $PROGNAME
    if running; then
	/sbin/rmmod $MODULE
	RETVAL=$?
    fi
    if [ $RETVAL -eq 0 ]; then
	rm -f /var/lock/subsys/$PROGNAME
	success
    else
	failure
    fi
    echo
    return $RETVAL
}

restart() {
    stop
    start
}

status() {
    if running; then
	STATUS="loaded"
    else
	STATUS="not loaded"
    fi
    gprintf "%s kernel module is %s\n" $DAEMON $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`
	gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" "$INITNAME"
	exit 1
	;;
esac
exit $RETVAL