- It runs in Ubuntu 10.04 Server i386
- Its based in one init script that I found in this list, poster said that runs
in RedHat9, I modified for Ubuntu
#!/bin/bash
#
# kannel init scrip for Kannel Gateway
# it handles bearerbox, smppgatewat and sqlbox for now.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
VERSION=`/usr/local/bin/gw-config --version`
KANNELPATH=/usr/local/sbin
KANNEL_CONF=/etc/kannel.conf
SMPPBOX_CONF=/etc/smppbox.conf
SQLBOX_CONF=/etc/sqlbox.conf
KANNEL_PID_DIR=/var/run/kannel
KANNEL_OPTIONS="--daemonize --parachute --user kannel --pid-file
/var/run/kannel"
ISRUNBEARERBOX=`ps -A | grep bearerbox | wc -l`
ISRUNSMPPBOX=`ps -A | grep smppbox | wc -l`
ISRUNSQLBOX=`ps -A | grep sqlbox | wc -l`
# Check that we are root ... so non-root users stop here
[ `id -u` = 0 ] || exit 1
# Various other checks
#[ ${NETWORKING} = "yes" ] || exit 0
[ -x $KANNELPATH/bearerbox ] || exit 0
[ -x $KANNELPATH/smppbox ] || exit 0
[ -x $KANNELPATH/smsbox ] || exit 0
[ -f $KANNEL_CONF ] || exit 0
[ -f $SMPPBOX_CONF ] || exit 0
[ -f $SQLBOX_CONF ] || exit 0
RETVAL=0; RETVAL1=0; RETVAL2=0; RETVAL3=0
prog="Kannel"
start() {
# Check that at least one group is defined for sms
# and/or wap to start the bearer. Then start boxes
# as needed.
# Also make sure that there are not another instances
# of programs running before start it up.
if [ -d "/var/run/kannel" ]; then
false
else
mkdir /var/run/kannel
fi
chown -R kannel:kannel /var/run/kannel
chown -R kannel:kannel /var/log/kannel
startgateway=`egrep -se '^[ \t]*group *= *core' $KANNEL_CONF`
startsms=`egrep -se '^[ \t]*group *= *smsbox' $KANNEL_CONF`
startsmpp=`egrep -se '^[ \t]*group *= *smppbox' $SMPPBOX_CONF`
startsql=`egrep -se '^[ \t]*group *= *sqlbox' $SQLBOX_CONF`
if [ -n "$startgateway$startsms" ] && [ $ISRUNBEARERBOX -eq 0 ]; then
echo -n "Starting Mobile Gateway bearerbox Service ($VERSION): "
$KANNELPATH/bearerbox $KANNEL_OPTIONS/bearerbox.pid $KANNEL_CONF
RETVAL1=$?
echo -n " [Done] ...with pid: "
cat /var/run/kannel/bearerbox.pid
sleep 3
else
exit 0
fi
if [ -n "$startsmpp" ] && [ $ISRUNSMPPBOX -eq 0 ]; then
echo -n "Starting Mobile Gateway sppbox Service ($VERSION): "
$KANNELPATH/smppbox $KANNEL_OPTIONS/smppbox.pid $SMPPBOX_CONF
RETVAL2=$?
echo -n " [Done] ...with pid: "
cat /var/run/kannel/smppbox.pid
sleep 3
fi
if [ -n "$startsql" ] && [ $ISRUNSQLBOX -eq 0 ]; then
echo -n "Starting Mobile Gateway sqlbox Service ($VERSION): "
$KANNELPATH/sqlbox $KANNEL_OPTIONS/sqlbox.pid $SQLBOX_CONF
RETVAL3=$?
echo -n " [Done] ...with pid: "
cat /var/run/kannel/sqlbox.pid
sleep 3
fi
let RETVAL=$REVAL1+$RETVAL2+$RETVAL3
if [ $RETVAL -eq 0 ]; then
sleep 2
touch /var/lock/kannel
chmod +x /var/lock/kannel
cat /var/run/kannel/*.pid > /var/run/kannel.pid
fi
return $RETVAL
}
stop() {
echo -n "Shutting down Mobile Gateway bearerbox $VERSION: "
killall bearerbox
RETVAL1=$?
echo
echo -n "Shutting down Mobile Gateway smppbox $VERSION: "
killall smppbox
RETVAL2=$?
echo
echo -n "Shutting down Mobile Gateway sqlbox $VERSION: "
killall sqlbox
RETVAL3=$?
echo
let RETVAL=$REVAL1+$RETVAL2+$RETVAL3
if [ $RETVAL -eq 0 ]; then
sleep 2
rm -f /var/lock/kannel
rm -f /var/run/kannel/*.pid
rm /var/run/kannel.pid
fi
return $RETVAL
}
# See how we were called.
case "$1" in
start)
# Start daemons.
start
;;
stop)
# Stop daemons
stop
;;
restart)
# Restart daemons
stop
sleep 1
start
;;
status)
if [ $ISRUNBEARERBOX -eq 0 ]; then
echo "Mobile Gateway bearerbox Service is not running..."
else
echo "Mobile Gateway bearerbox Service (pid `cat
/var/run/kannel/bearerbox.pid`) is running..."
fi
if [ $ISRUNSMPPBOX -eq 0 ]; then
echo "Mobile Gateway smppboxx Service is not running..."
else
echo "Mobile Gateway smppbox Servcice (pid `cat
/var/run/kannel/smppbox.pid`) is running..."
fi
if [ $ISRUNSQLBOX -eq 0 ]; then
echo "Mobile Gateway sqlbox Service is not running..."
else
echo "Mobile Gateway sqlbox Service (pid `cat
/var/run/kannel/sqlbox.pid`) is running..."
fi
exit $?
;;
*)
echo "Usage: named {start|stop|status|restart}"
RETVAL=1
esac
exit $RETVAL
Thanks,
Aldo Zavala