Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
15,018

With the script below you will be able to use command :

  • "service saprouter start" to start saprouter on linux.
  • "
  • service saprouter stop" to stop saprouter on linux.
  • "service saprouter status
  • " to have status and pid of saprouter on linux.

/etc/init.d/saprouter

#!/bin/sh
#
### BEGIN INIT INFO
# Provides: saprouter
# Default-Start:
# Default-Stop:
# Should-Start:
# Required-Start: $network
# Required-Stop:
# Short-Description: Start and stop the SAP router relay server
# Description: saprouter provides relay server for SAP.
### END INIT INFO
#
# The fields below are left around for legacy tools (will remove later).
# chkconfig: - 65 35
# description: saprouter provides a relay for Dynamic Host Control Protocol.
# processname: saprouter
# # pidfile: /var/run/saprouter.pid

. /etc/rc.d/init.d/functions

RETVAL=0

basedir=/usr/saprouter
prog=saprouter
user=saprouter
exec="${basedir}/exe/${prog}"
lockfile="/var/lock/subsys/${prog}"
pidfile="/var/run/${prog}.pid"
logfile="${basedir}/LOG/${prog}.log"
tracefile="${basedir}/TRC/${prog}.trc"
config="${basedir}/ACL/${prog}.tab"

SAPROUTERARGS=" -r -R ${config} -G ${logfile} -T ${tracefile} -J 1048576 -Y 12 -C 1000 -W 9000000 "
export PATH=${PATH}:${basedir}/exe
if [ -z "${LD_LIBRARY_PATH}" ];
then
  export LD_LIBRARY_PATH=${basedir}/exe
else
  export LD_LIBRARY_PATH=${basedir}/exe:${LD_LIBRARY_PATH}
fi

configtest() {
    [ -x "${exec}" ] || exit 5
    [ -f "${config}" ] || exit 6
    [ -d "${logdir}" ] && exit 6
    [ -d "${tracedir}" ] && exit 6
    return 0
}

rh_status(){
    status "${exec}"
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

start() {
    [ `id -u` -eq 0 ] || exit 4
    configtest
    rh_status_q && return 0

    echo -n $"Starting $prog: "
    daemon --user "${user}" "${exec}" $SAPROUTERARGS 2>/dev/null >/dev/null &
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
    return $RETVAL
}

stop() {
    args_soft="-p"
    args_hard="-s"
    [ `id -u` -eq 0 ] || exit 4

    rh_status_q
    RETVAL=$?
    if [ $RETVAL -gt 0 ] ;
    then
        echo "Saprouter is already stop"
        return 0
    fi

    echo -n $"Shutting down softly $prog: "
    su - "${user}" -c "${exec} ${args_soft}"
    sleep 2
    rh_status_q
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ] ;
    then
        echo "Saprouter is still started. We will try a hard shutdown"
        su - "${user}" -c "${exec} ${args_hard}"
        sleep 2
        rh_status_q
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ] ;
        then
            echo "Saprouter is still started. We will try OS kill."
            killproc "${prog}"
            RETVAL=$?
            if [ $RETVAL -eq 0 ] ;
            then
                echo "Saprouter is still started. Soft, hard and OS killing failed!!!"
                return 2
            else
                echo "Saprouter is down with OS killing."
                RETVAL=0
            fi
        else
            echo "Saprouter is down with hard shutdown."
            RETVAL=0
        fi
    else
        echo "Saprouter is down"
        RETVAL=0
    fi

    [ $RETVAL -eq 0 ] && rm -f $lockfile
    return $RETVAL
}


usage() {
    echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
}


if [ $# -gt 1 ]; then
    exit 2
fi

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|force-reload)
        stop ; start
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        stop ; start
        ;;
    reload)
        usage
        # unimplemented feature
        exit 3
        ;;
    configtest)
        configtest
        ;;
    status)
        rh_status
        ;;
    *)
        usage
        exit 2
        ;;
esac

exit $?

usefull command :

to increase trace : saprouter -t -V 2

to see list on client saprouter -l :

Mon Aug 26 13:59:04 2013
SAP Network Interface Router, Version 40.4


Mon Aug 26 13:59:05 2013
peer SAProuter with NI version 40 ...
send info-request to running SAProuter ...

SAP Network Interface Router running on port 3299 (PID = 4838)
Started on: Mon Aug 26 11:58:00 2013


ID  CLIENT                         | PARTNER                        service
-----------------------------------+---------------------------------------
8   localhost                      | (no partner)
76  10.126.104.193                 | 10.134.235.67                  sapdp00
170 10.126.104.193                 | 10.134.235.67                  sapdp00
62  10.126.104.193                 | 10.134.235.79                  3281
130 sapserv3                       | 10.134.235.79                  3281
81  10.126.104.193                 | 10.126.115.14                  3200

Total no. of clients: 11
Working directory   : /usr/saprouter
Routtab             : /usr/saprouter/ACL/saprouter.tab

6 Comments
Labels in this area