SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Fri Mar 29, 2024 14:50
SMSTools3 Community » Help and support Bottom

[answered] Duplication of an existing setup

  This topic is locked

Page:  1

Author Post
Member
Registered:
Aug 2009
Location: Belgium
Hi Keke,

My current setup is one GSM, an event handler, and several scripts reading and writing in 'incoming' and 'outgoing' directories.

Now, I want to add a second GSM, and run a completely separate copy of my application.

I thought it was just a matter of changing some paths in my scripts. Unfortunately 'incoming' and 'outgoing' are global options.

I've seen the 'queues' and 'provider' page, but it seems complicated (for me at least ;-) and it needs modifications in my code.

Instead of starting to learn how to use the queues, and change my code in production, I am considering a duplication of the whole service (daemon).

Thanks in advance for any advice, solution or pointer to documentation.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
You are right, in some cases different daemon makes more sense than single daemon handling multiple different applications.

What is needed to do, is:

- Get the latest script sms3 from this post. It has fixes as described, and now it also has a setting for configuration file, which is required when multiple daemons are running.

- Run the current smsd with the new unmodified script, and create a copy of script for the new application, like /etc/init.d/smsapp2. I think that it's better not to use any name which contains "smsd", because of pgrep etc.

- In smsapp2 script set at least the following settings:
PIDFILE="/var/run/smsapp2.pid"
INFOFILE="/var/run/smsapp2.working"
LOGFILE="/var/log/smsapp2.log"
CONFFILE="/etc/smsapp2.conf"
DAEMON=/usr/local/bin/smsapp2


- Create spool directories for smsapp2, like /var/spool/smsapp2/outgoing and so on.

- In the /etc/smsapp2.conf define all possible directories, at least (3.1.14):
outgoing = /var/spool/smsapp2/outgoing
incoming= /var/spool/smsapp2/incoming
checked = /var/spool/smsapp2/checked


- When using smsapp2 init script, infofile and pidfile are not needed to set in smsapp2.conf.

- Copy /usr/local/bin/smsd to /usr/local/bin/smsapp2, and start smsapp2 with it's own init script.

Member
Registered:
Aug 2009
Location: Belgium
Topic owner
What I did on my SUSE 11.2 :

create a hard link to /usr/sbin/smsd named smsd2

copy /etc/init.d/smsd to /etc/init.d/smsd2

change this script as follow :


No problem so far.

Thank you for your answer, it reassures me about my choice.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Can you show what kind of init.d script there is on SUSE? It seems that it's different than sms3, and different than one on Debian/Ubuntu. Just wondering what happens if daemon is going to be killed hardly...

Your choise smsd2 for the name might be okay, but what shows pgrep smsd when both daemons are running?

Member
Registered:
Aug 2009
Location: Belgium
Topic owner
As you guessed it, pgrep smsd lists 4 pids, 2 pids for each instance.

I have no problem because my init script doesn't use pgrep. It use "killproc".

Here it is
#!/bin/sh
# This script can be used to start/stop smsd
# as a daemon in Linux, Solaris, Cygwin, FreeBSD
# and MAC OS X Terminal window (Darwin).
# This script is to be used with smsd version >= 3.0.3.
#
# /etc/init.d/smsd
#   and its symbolic link
# /usr/sbin/rcsmsd
#
### BEGIN INIT INFO
# Provides:          smsd
# Required-Start:    $syslog $remote_fs
# Should-Start:      $time smtp
# Required-Stop:     $syslog $remote_fs
# Should-Stop: $time smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start/Stop smsd - a SMS Gateway software
# Description:       Start smsd to send and receive short
#       messages through GSM modems and mobile phones.
### END INIT INFO
DAEMON="/usr/sbin/smsd"
CONFFILE="/etc/sysconfig/smsd"

test -x $DAEMON || { echo "$DAEMON not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

test -r $CONFFILE || { echo "$CONFFILE not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 6; fi; }

# Read config
. $CONFFILE

# If an unpriviledged user is selected, make sure that next two
# files are writable by that user:
PIDFILE="/var/run/smsd/smsd.pid"
INFOFILE="/var/run/smsd/smsd.working"
# Logfile can also be defined in here:
#LOGFILE="/var/log/smsd/smsd.log"



# A program which turns power off for couple of seconds:
RESETMODEMS=/usr/sbin/smsd_resetmodems
NAME=smsd

# Shell functions sourced from /etc/rc.status:
. /etc/rc.status

# Reset status of this service
rc_reset

ARGS="-p${PIDFILE} -i${INFOFILE} -u${SMSD_USER} -g${SMSD_GROUP} ${SMSD_ARGS}"

case "$1" in
  start)
        echo -n "Starting SMS Daemon: "
        if checkproc $DAEMON ; then
                echo -n "already running"
                rc_failed 7
        else
                        if [ -f "${INFOFILE}" ]; then
                                rm "${INFOFILE}"
                        fi
                        if [ -f "${PIDFILE}" ]; then
                rm "${PIDFILE}"
                fi
                        # Delete lock files if they exist
                        find /var/spool/sms -name '*.LOCK' -exec rm \{\} \;
                        $DAEMON $ARGS
        fi
        rc_status -v
        ;;

  stop)
        echo -n "Shutting down SMS Daemon: "
        if checkproc $DAEMON ; then
                /sbin/killproc -p "$PIDFILE" -TERM $DAEMON
                if [ -e "$PIDFILE" ]; then
                        echo "Warning - SMS Daemon did not exit in a timely manner. Waiting..."
                        while [ -e "$PIDFILE" ] && [ $SMSD_MAXWAIT -qt 0 ] ; do
                                sleep 1
                                SMSD_MAXWAIT=$[SMSD_MAXWAIT-1]
                                echo -n '.'
                                [ $SMSD_MAXWAIT -eq 41 ] && echo
                        done
                fi
                if checkproc $DAEMON ; then
                        /sbin/killproc -p "$PIDFILE" -SIGKILL $DAEMON
                        echo -n "Warning: nagios killed"
                fi
        else
                echo -n " SMS Daemon not running"
                rc_failed 7
        fi
        # Remember status and be verbose
    rc_status -v
        ;;

  try-restart|condrestart)
    ## Do a restart only if the service was active before.
    ## Note: try-restart is now part of LSB (as of 1.9).
    ## RH has a similar command named condrestart.
    if test "$1" = "condrestart"; then
        echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
    fi
    $0 status
    if test $? = 0; then
        $0 restart
    else
        rc_reset    # Not running is not a failure.
    fi
    # Remember status and be quiet
    rc_status
    ;;

  restart|reload)
        $0 stop
        $0 start
    # Remember status and be quiet
    rc_status
        ;;

  status)
    echo -n "Checking for SMS Daemon "
    /sbin/checkproc $DAEMON
    rc_status -v
    ;;

  probe)
    test /etc/smsd.conf -nt "$PIDFILE" && echo reload
    ;;

  *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|reload|probe}"
        exit 1
    ;;
esac
rc_exit
 
'bash' Syntax Highlight powered by GeSHi


On Redhat and derivatives, killproc is a function defined in a bourne shell script that is included in each init.d script.

On Suse, it is a binary executable located in /sbin.

If you want me to send you the Redhat script (~600 lines) or the Suse killproc man page (~200 lines), tell me how.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thanks, I do not need that script, just wanted to be sure about how things are done. Everything looks good. It talks about nagios, and probe refers to /etc/smsd.conf, but those are not big issues.

Member
Registered:
Aug 2009
Location: Belgium
Topic owner
I got the RPM from a personal repository in the Suse factory. I suppose that the builder copied the nagios script and did not fully convert it to smstools.

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.