#!/bin/sh

# chkconfig: - 90 25
# description: Gadu-Gadu relaying agent (proxy) daemon

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

RETVAL=0

start() {
    echo -n $"Starting ggrelay: "
    daemon --check ggrelay xargs ggrelay -d \
		< /etc/ggrelay/ggrelay.conf
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ggrelay
}

stop() {
    echo -n $"Stopping ggrelay: "
    killproc ggrelay
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/ggrelay
    fi
}

# See how we were called.
case "$1" in
    start)
		start
		;;
    stop)
		stop
		;;
    status)
        status ggrelay
		RETVAL=$?
        ;;
    restart)
		stop
		start
		;;
    condrestart)
		if [ -f /var/lock/subsys/ggrelay ]; then
			stop
			start
		fi
		;;
    *)
		echo $"Usage: $0 {start|stop|status|restart|condrestart}"
		;;
esac
exit $RETVAL
