Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > e37f5f7855c5d4ec3828a9e5a212c8d8 > files > 1

uml-utilities-20070815-6mdv2010.0.i586.rpm

#! /bin/sh
#
# umlswitch       A software switch to interconnect uml virtual system
#
# chkconfig: 345 11 89
# description: Uml_switch create a virtual network allowing to connect \
#              User Mode Linux virtual system together and to the real \
#              system by using a tun device
# processname: uml_switch
#
### BEGIN INIT INFO
# Provides: $umlswitch
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: UML switch
# Description: Uml_switch create a virtual network allowing to connect \
#              User Mode Linux virtual system together and to the real \
#              system by using a tun device
### END INIT INFO

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

# Get network configuration
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

# Set defaults and load configuration
NAME=umlswitch
LOCKFILE=/var/lock/subsys/${NAME}
[ -f /etc/sysconfig/${NAME} ] && . /etc/sysconfig/${NAME}

function check_network() {
    route -n | grep -q ^0\.0\.0\.0
}

function start() {
    res=0
    if [ ! -f $LOCKFILE ]; then
	num=0
	gprintf "Starting %s:" "$NAME"
	daemon "uml_switch ${TAP:+-tap $TAP} ${SOCKET:+-unix $SOCKET} ${OPTIONS} < /dev/null > /dev/null &"
	res=$?
	echo
	[ $res -eq 0 ] && touch $LOCKFILE
    fi
    return $res
}

function stop() {
    gprintf "Stopping %s:" "$NAME"
    killproc uml_switch
    res=$?
    echo
    [ $res -eq 0 ] && rm -f $LOCKFILE
    return $res
}

# See how we were called.
case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status uml_switch
	;;
    restart|reload)
	stop
	start
	;;
    *)
	gprintf "Usage: %s {start|stop|status|restart|reload}\n" "$0"
	exit 1
	;;
esac

exit $?