Sunday 5 August 2012

Kannel Start-Stop Daemon


Install kannel and configure with start-stop daemon
Step 1:
      Copy and extract the kannel in “/usr/local/” directory.
# cp gateway-1.4.1.tar.gz /usr/local
# tar -zxvf gateway-1.4.1.tar.gz
# mv gateway-1.4.1.tar.gz kannel

Step 2:
      Installing kannel with start-stop daemon.
# cd /usr/local/kannel/
# ./configure –enable-start-stop-daemon
# make
# make install

Step 3:
      Create start-stop daemon script in “/etc/init.d/” directory and set bearerbox, smsbox, start-stop-daemon and configuration path.
# vim /etc/init.d/kannel

#!/bin/sh
#
# gateway         This shell script takes care of starting and stopping
#                 the Kannel WAP gateway (bearer/wapbox)
#
# chkconfig: 2345 97 03
# description:  Start and stop the Kannel WAP gateway used to fetch \
#               some WML content from a Web server & compile it \
#               into WMLC mobile phone bytecode.
# probe: true
 
# Use start-stop-daemon
ver=1.4.1
BBOX=/usr/local/kannel/gw/bearerbox
SBOX=/usr/local/kannel/gw/smsbox
START="/usr/local/kannel/utils/start-stop-daemon --start --background --quiet --exec"
STOP="/usr/local/kannel/utils/start-stop-daemon --stop --quiet --oknodo --exec"
CONF=/usr/local/kannel/gw/smskannel.conf
LEVEL=-v\ 1

[ $# -eq 2 ] && ver=$2
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x $BBOX ] || exit 0

[ -x $SBOX ] || exit 0

[ -f $CONF ] || exit 0
 
RETVAL=0

# See how we were called.
case "$1" in
    start)
    # Start daemons.
            echo -n "Starting bearer service (gateway kannel $ver): "
            $START $BBOX -- $LEVEL $CONF
            RETVAL1=$?
            sleep 1 # Sleep for a while before we try to start smsbox
            echo
            echo -n "Starting smsbox service (gateway kannel $ver): "
            $START $SBOX -- $CONF
            RETVAL2=$?
            echo
            echo
            [ $RETVAL1 -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/gateway ||\
            RETVAL=1
            ;;
      stop)
            # Stop daemons.
            echo -n "Shutting down smsbox (kannel $ver): "
            $STOP $SBOX
            RETVAL2=$?
            echo
            echo -n "Shutting down bearerbox (kannel $ver): "
            $STOP $BBOX
            RETVAL1=$?
            echo
            [ $RETVAL1 -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/gateway
            echo ""
            ;;
      status)
            status bearerbox
            status smsbox
            exit $?
            ;;
      restart)
            $0 stop
            sleep 1
            $0 start
            ;;
      *)
            echo "Usage: named {start|stop|status|restart}"
            exit 1
esac
exit $RETVAL

      :wq

# chmod  +x /etc/init.d/kannel
# chkconfig - -list kannel
# chkconfig kannel on
# service kannel restart
# service kannel status

4 comments:

Boot to UEFI Mode or legacy BIOS mode

Boot to UEFI Mode or legacy BIOS mode Choose UEFI or legacy BIOS modes while installing Windows. After Windows is installed, if you nee...