urouter.sh

Unix script for starting the Uniface Router.

urouter.sh

Description

The urouter.sh file is a shell script that starts the Uniface Router, and ensures that it is restarted in case of failure. By default, the Uniface Router is restarted every time it fails for an unknown reason, and the last three core dumps are stored.

You can edit this file to change how the Uniface Router recovers from crashes.

Contents

. uniface/common/adm/insunis # Set USYSxxx and urouter env. vars
LOG=./core                               # The logfile that is to be saved
NUM=0                                    # Init
MAXLOGS=3                                # Init

ASNFLAG='echo $* | grep [/-]asn='
if [ "$ASNFLAG" != "" ]; then
  ARGS="$*"
else
  ARGS="-asn=uniface/common/adm/urouter.asn $*"
fi

while :
do
  echo "Run: $urouter $ARGS"          # Print the Router Startup 
  $urouter $ARGS                      # Start the URouter + commandline 
  STATUS=$?                           # Status of an ended URouter
  echo "Status: $STATUS"              # Print status
  if [ "$STATUS" = 0 ]; then
   exit;                              # End of script if status = 0
  fi
  sleep 10                            # Wait 10 seconds
  NUM=`expr $NUM + 1`                 # Next number for stored LOG file
  if [ -f "$LOG"     ]; then
    mv $LOG $LOG.$NUM;                # Copy the LOG file if exist
  fi
  if [ "$NUM" -ge "$MAXLOGS" ]; then
    NUM=0;                            # Store the last 3 LOG files only 
  fi
done