Simple script to reload exaBGP config

Simple script to reload exaBGP config

Recently started to look at exabgp as a tool to inject routes for a RTBH setup. Works nicely so far so made the following simple script to reload the config after changes so they take effect. This was made using exabgp 3.0.11 and Centos 6.

The config is reloaded via kill -SIGHUP (somepid) after it reads the PID from the file and checks its actually running.

#!/bin/bash
# This script should read the PID of exabgp from a file
# then check if that PID is running and reload it :)
#

PID_FILE=/var/run/exaBGP/exabgp_PID

if [ -f "${PID_FILE}" ]; then

  # The file exists so read the PID
  PID=`head -n 1 $PID_FILE`

  # Check is the process is actuall running
  if [ -n "`ps -p ${PID} | grep ${PID}`" ]; then

    echo exaBGP is already running [$PID].
        # It is so lets reload the config :)
        echo sending sighup to reload config...
        # Use below for exaBGP < 3.2 (Thanks to Roberto Saavedra for noting this) 
        # kill -SIGHUP $PID
        kill -SIGUSR1 $PID
        echo Reload complete
    exit
  else
    # Shouldnt really get here
    echo PID file exists but the PID is not running!
        exit
  fi
fi

# No PID file
echo No PID file found at $PID_FILE

As ever any comments or suggestions are welcome :)

m00nie