Hi all,

This is my start/stop script on FreeBSD 4.10-STABLE. Not the best that can
be obtained, but it works. I preferred to check the PID (ps aux) instead of
getting a return value from daemon or start-stop-daemon or using the -p
option. Anyway, I still keep the PIDs in /var/run.

Rodrigo Cremaschi
Terra Networks Argentina

============================================
#!/bin/sh

CONF=/usr/gw/smskannel.conf
bearerbox=/usr/local/sbin/bearerbox
smsbox=/usr/local/sbin/smsbox

[ -x $bearerbox ] || exit 0
[ -x $smsbox ] || exit 0
[ -f $CONF ] || exit 0

# See how we were called.
case "$1" in

  start)
        # Start daemons.
        echo -n "Starting bearer service (gateway kannel): "
        daemon -f $bearerbox $CONF
        sleep 1
        BEAR_PID=`ps aux | grep bearerbox |grep smskannel.conf | awk '{
print $2}'`
        if [ $BEAR_PID ]
        then
              echo PID = $BEAR_PID
              echo $BEAR_PID > /var/run/bearerbox.pid
        else
              echo "not started"
        fi
        sleep 1

        echo -n "Starting smsbox service (gateway kannel): "
        daemon -f $smsbox $CONF
        sleep 1
        SMS_PID=`ps aux | grep smsbox |grep smskannel.conf | awk '{ print
$2}'`
        if [ $SMS_PID ]
        then
              echo PID = $SMS_PID
              echo $SMS_PID > /var/run/smsbox.pid
        else
              echo "not started"
        fi
        ;;

  stop)
        # Stop daemons.
        echo -n "Shutting down smsbox (kannel): "
        SMS_PID=`ps aux | grep smsbox |grep smskannel.conf | awk '{ print
$2}'`
        if [ $SMS_PID ]
        then
                kill -TERM $SMS_PID
                RETVAL2=$?
                if [ $RETVAL2 -eq 0 ]
                        then echo "SMSBOX terminated properly."
                        else echo "SMSBOX not terminated."
                fi
                if [ -e /var/run/smsbox.pid ]
                then
                        rm -f /var/run/smsbox.pid
                fi
                sleep 1
        else echo "SMSBOX is not running."
        fi

        echo -n "Shutting down bearer (kannel): "
        BEAR_PID=`ps aux | grep bearerbox |grep smskannel.conf | awk '{
print $2}'`
        if [ $BEAR_PID ]
        then
                kill -TERM $BEAR_PID
                RETVAL1=$?
                if [ $RETVAL1 -eq 0 ]
                        then echo "BEARER terminated properly."
                        else echo "BEARER not terminated."
                fi
                if [ -e /var/run/bearerbox.pid ]
                then
                        rm -f /var/run/bearerbox.pid
                fi
                sleep 1
        else echo "BEARER is not running."
        fi
        ;;

  status)
        if [ -e /var/run/bearerbox.pid ]
        then
            STAT_SMS=`cat /var/run/bearerbox.pid`
            echo "bearer service is running. PID=$STAT_SMS"
        else
           echo "bearer service is not running."
        fi

        if [ -e /var/run/smsbox.pid ]
        then
           STAT_BEAR=`cat /var/run/smsbox.pid`
           echo "smsbox service is running. PID=$STAT_BEAR"
        else
           echo "smsbox service is not running."
        fi
        ;;

  restart)
        $0 stop
        sleep 1
        $0 start
        ;;
  *)
        echo "Usage: kannel {start|stop|status|restart}"
        exit 1
esac

exit 0
============================================

----- Original Message ----- 
From: "Dimitri Aivaliotis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 25, 2004 7:08 AM
Subject: Re: freebsd start script


> Hi Alex
>
> On Tue, 24 Aug 2004 22:33:53 +0200
> Alexander Malysh <[EMAIL PROTECTED]> wrote:
>
> > Hi again,
> >
> > glibc or your kannel compilation seems to be broken?
>
> oh, boy - doesn't sound good (but everything else seems to be working...)
>
> > sorry I don't have access to FreeBSD system, so you are alone here...
> > (option: ssh account on this machine in order to be able to trace this
> > problem... if so, please mail offlist.)
> >
>
> I'm working on this.  It may take a couple days...
>
> I've implemented a workaround in my start-script: I'm using the daemon
utility instead of the "-d" flag, and that seems to work well.
>
>
> - Dimitri
>
>
>
>
>
>
> -- 
> Dimitri Aivaliotis
> EveryWare AG
> Birmensdorferstrasse 125
> 8003 Zurich
>
> tel: +41 (1) 466 60 00
> fax: +41 (1) 466 60 10
>

Este mensaje se dirige exclusivamente a su destinatario y puede contener
informaci�n CONFIDENCIAL sometida a secreto profesional o cuya divulgaci�n
est� prohibida en virtud de la legislaci�n vigente. Si ha recibido este
mensaje por error, le rogamos que nos lo comunique inmediatamente por esta
misma v�a o por tel�fono (54.11 5776-5000) y proceda a su destrucci�n.
N�tese que el correo electr�nico v�a Internet no permite asegurar ni la
confidencialidad de los mensajes que se transmiten ni la correcta recepci�n
de los mismos. En caso de que el destinatario de este mensaje no
consintiera la utilizaci�n de correo electr�nico v�a Internet rogamos lo
ponga en nuestro conocimiento de manera inmediata.
       

Attachment: kannel
Description: Binary data

Reply via email to