Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-updates > by-pkgid > 27941d4975f59195d79b12ef8def8f19 > files > 2

cdemu-daemon-1.2.0-2.1mdv2010.1.i586.rpm

#!/bin/sh
#
# chkconfig: 345 60 00
### BEGIN INIT INFO
# Provides: cdemud
# Required-Start: messagebus
# Required-Stop: messagebus
# Should-Start: dkms
# Default-Start: 3 4 5
# Short-Description: CDEmu daemon
# Description: Userspace daemon part of the userspace-cdemu suite.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

DAEMON_NAME=cdemud
DAEMON_PROCESS=cdemud
DAEMON_BINARY=cdemud
LOCK_FILE=/var/lock/subsys/$DAEMON_NAME
RETVAL=0

OPTIONS=
NUM_DEVICES=
AUDIO=
AUDIO_DEVICE=
BUS=
[ -f /etc/sysconfig/$DAEMON_NAME ] && . /etc/sysconfig/$DAEMON_NAME

start() {
    [ -f $LOCK_FILE ] && return

    if ! /sbin/modprobe vhba; then
        gprintf "You need to install the vhba kernel module.\n"
        RETVAL=1
        return
    fi

    gprintf "Starting %s: " "$DAEMON_NAME"
    [ -n "$NUM_DEVICES" ] && OPTIONS="$OPTIONS -n $NUM_DEVICES"
    [ -n "$BUS" ] && OPTIONS="$OPTIONS -b $BUS"
    [ -n "$AUDIO" ] && OPTIONS="$OPTIONS -a $AUDIO"
    [ -n "$AUDIO_DEVICE" ] && OPTIONS="$OPTIONS -o $AUDIO_DEVICE"
    # redirected to null, otherwise outputs "Daemon returned 0."
    daemon $DAEMON_BINARY -d $OPTIONS 2>/dev/null
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $LOCK_FILE
}

stop() {
    gprintf "Shutting down %s: " "$DAEMON_NAME"
    killproc $DAEMON_PROCESS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $DAEMON_PROCESS
	RETVAL=$?
        ;;
    reload)
        stop
        start
        ;;
    restart)
        stop
        start
        ;;
    condrestart)
        if [ -f $LOCK_FILE ]; then
            stop
            start
        fi
        ;;
    *)
        gprintf "Usage: %s {start|stop|restart|reload|condrestart|status}\n" "$0"
        RETVAL=1
esac

exit $RETVAL