File ushare.rc.suse of Package ushare

#!/bin/sh

### BEGIN INIT INFO
# Provides:          ushare
# Required-Start:    $local_fs $remote_fs $syslog $network
# Should-Start:
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: uShare UPnP Media Server
# Description:       uShare UPnP (TM) A/V & DLNA Media Server
#                    You should edit configuration in /etc/ushare.conf file
#                    See http://ushare.geexbox.org for details
### END INIT INFO

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
USHARE_BIN=/usr/bin/ushare
USHARE_CONF=/etc/ushare.conf
USHARE_OPTIONS='--daemon'

# Check for existence of daemon executable
if [ ! -x "$USHARE_BIN" ] ; then
    echo "$USHARE_BIN not installed"
    if [ "$1" = "stop" ] ; then
        exit 0
    else
        exit 5
    fi
fi

# Check for existence of needed config file and read it
if [ ! -r "$USHARE_CONF" ] ; then
    echo "$USHARE_CONF not existing"
    if [ "$1" = "stop" ] ; then
        exit 0
    else
        exit 6;
    fi;
fi

# Read config
. $USHARE_CONF

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
        echo -n "Starting uShare "

        if [ -n "$USHARE_DIR" ] ; then
            ## Start daemon with startproc(8). If this fails
            ## the return value is set appropriately by startproc.
            if [ -n "$USHARE_LOCALE" ] ; then
                export LANG="$USHARE_LOCALE" LC_ALL="$USHARE_LOCALE"
            fi
            /sbin/startproc $USHARE_BIN $USHARE_OPTIONS
        else
            echo -n ": Empty USHARE_DIR "
            rc_failed 6 # program is not configured
        fi

        # Remember status and be verbose
        rc_status -v
        ;;

    stop)
        echo -n "Shutting down uShare "
        ## Stop daemon with killproc(8) and if this fails
        ## killproc sets the return value according to LSB.
        /sbin/killproc -TERM $USHARE_BIN

        # Remember status and be verbose
        rc_status -v
        ;;

    try-restart|condrestart)
        ## Do a restart only if the service was active before.
        ## Note: try-restart is now part of LSB (as of 1.9).
        ## RH has a similar command named condrestart.
        if test "$1" = "condrestart"; then
        echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if test $? = 0; then
            $0 restart
        else
            rc_reset    # Not running is not a failure.
        fi
        # Remember status and be quiet
        rc_status
        ;;

    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start

        # Remember status and be quiet
        rc_status
        ;;

    force-reload)
        echo -n "Reload service uShare "
        /sbin/killproc -HUP $USHARE_BIN
        rc_status -v
        ;;

    reload)
        echo -n "Reload service uShare "
        /sbin/killproc -HUP $USHARE_BIN
        rc_status -v

        ;;

    status)
        echo -n "Checking for service uShare "
        /sbin/checkproc $USHARE_BIN

        rc_status -v
        ;;

    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
        exit 1
        ;;
esac

rc_exit
openSUSE Build Service is sponsored by