#! /bin/sh
#
# /etc/init.d/wicd
#
# chkconfig: - 98 02
# description: Wicd is a wireless and wired network manager for Linux.

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

# This script was created by Paulo Roma

RETVAL=0
prog="wicd"
WICD_BIN=/usr/sbin/$prog
WICD_LOCKFILE=/var/lock/subsys/wicd
WICD_PIDFILE=/var/run/wicd.pid

start () {
       if [ ! -f $WICD_LOCKFILE ]; then
          echo -n "Starting wicd services: "
          daemon $WICD_BIN
          RETVAL=$?
          [ $RETVAL -eq 0 ] && touch $WICD_LOCKFILE
          echo
          return $RETVAL
       fi
}
       
stop () {
       echo -n "Shutting down wicd services: "
       killproc -p $WICD_PIDFILE $WICD_BIN
       RETVAL=$?
       [ $RETVAL -eq 0 ] && rm -f $WICD_LOCKFILE
       echo
       return $RETVAL
}

restart() {
        stop
        start
}

case "$1" in
        start)
            start   
        ;;
        stop)
            stop
        ;;
        status)
            status -p $WICD_PIDFILE wicd
            RETVAL=$?
        ;;
        restart | reload)
            restart
        ;;
        condrestart)
            [ -e $WICD_LOCKFILE ] && restart
            RETVAL=$?
        ;;
        *)
            echo $"Usage: $0 {start|stop|status|reload|condrestart|restart}"
            RETVAL=1
        ;;
esac

exit $RETVAL
