#!/bin/sh
#
# kannel	This script takes care of starting and stopping opensmppbox.
#
# chkconfig: - 98 02
# description:  Kannel Box that acts as SMPP Server
# config: /etc/kannel.conf
# config: /etc/kannel/opensmppbox.conf

# Use start-stop-kannel
prog="/usr/sbin/start-stop-kannel"
args="--start --background --chuid kannel:kannel --exec "
config="/etc/kannel/opensmppbox.conf"
lockfile=/var/lock/subsys/opensmppbox

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

# Source networking configuration.
. /etc/sysconfig/network

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

[ -f $config ] || exit 1

RETVAL=0

start() {
        # Start daemons.
        echo -n "Starting Open SMPP box: "
	daemon $prog $args /usr/sbin/opensmppbox $config
	RETVAL=$?
	echo
 	[ $RETVAL -eq 0 ] && touch $lockfile
	return $RETVAL
}

stop() {
        # Stop daemons.
	echo -n "Shutting Open SMPP box: "
        killproc /usr/sbin/opensmppbox
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $lockfile
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	RETVAL=$?
        ;;
  stop)
	stop
	RETVAL=$?
        ;;
  status)
	status /usr/sbin/opensmppbox
	RETVAL=$?
	;;
  restart)
	stop
	start
	RETVAL=$?
	;;  
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        RETVAL=1
esac

exit $RETVAL

