Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > 7d2aaf6a46e4ba3ac5a358d5095afc1a > files > 1

gvrpcd-1.3-3.fc12.x86_64.rpm

#!/bin/sh
#
# gvrpcd A program for announcing VLANs using GVRP
#
# chkconfig:   2345 11 89 
# description: gvrpcd implements end-node GVRP functionality as a user-space \
#              daemon.
#

 
### BEGIN INIT INFO
# Provides: gvrpcd
# Required-Start: network
# Required-Stop: network
# Should-Start: 
# Should-Stop: 
# Default-Start: 
# Default-Stop: 
# Short-Description: A program for announcing VLANs using GVRP
# Description: gvrpcd implements end-node GVRP functionality as a user-space \
#              daemon
### END INIT INFO

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

exec="/usr/sbin/gvrpcd"
prog="gvrpcd"
lockfilebase=/var/lock/subsys/gvrpcd
config=/proc/net/vlan/config

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

# See if any interfaces were passed to the init script.
if [ "$#" -gt 1 ]; then
       originalopts="$@"
       shift
       interfaces="$@"
       set $originalopts
fi

start() {
    # Wrapper to start all interfaces
    [ -x $exec ] || exit 5
    [ -z $interfaces ] && exit 5
    [ -f $config ] || exit 6
    retval=0
    for interface in $interfaces
    do
        start_if $interface
        subretval=$?
        [ $subretval -ne 0 ] && retval=$subretval
    done
    return $retval
}

start_if() {
    # Starts one interface
    ifname=$1
    ifprog=${prog}-${ifname}
    lockfile=${lockfilebase}-${ifname}
    pidfile=/var/run/${ifprog}.pid
    echo -n $"Starting ${ifprog}: "
    daemon $exec -d -i $ifname -p $pidfile $gvrpcd_options
    # if not running, start it up here, usually something like "daemon $exec"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    # Wrapper to stop all interfaces
    retval=0
    for interface in $interfaces
    do
        stop_if $interface
        subretval=$?
        [ $subretval -ne 0 ] && retval=$subretval
    done
    return $retval
}

stop_if() {
    # Stops one interface
    ifname=$1
    ifprog=${prog}-${ifname}
    lockfile=${lockfilebase}-${ifname}
    pidfile=/var/run/$ifprog.pid
    echo -n $"Stopping ${ifprog}: "
    killproc -p $pidfile $ifprog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

rh_status() {
    # Status wrapper for all interfaces 
    retval=0
    for interface in $interfaces
    do
        rh_status_if $interface
        subretval=$?
        [ $subretval -ne 0 ] && retval=$subretval
    done
    return $retval
}
rh_status_if() {
    # run checks to determine if the service is running or use generic status
    ifname=$1
    ifprog=${prog}-${ifname}
    pidfile=/var/run/${prog}-${ifname}.pid
    status -p $pidfile $ifprog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0
{start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?