#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/syslog-configurator
PIDFILE=/var/vcap/sys/run/syslog-configurator.pid
declare -a LOG_DIRS=(
  "/var/vcap/sys/log/service-backup"
  "/var/vcap/sys/log/service-metrics"
)

source /var/vcap/packages/redis-common/utils.sh

case $1 in

  start)
    <% if_p("syslog_aggregator.address", "syslog_aggregator.port") do %>

      CONFIG_DIR=$JOB_DIR/config

      if [ ! -d $CONFIG_DIR ]
      then
        echo "$CONFIG_DIR not found"
        exit 1
      fi

      cp $CONFIG_DIR/syslog_forwarder.conf /etc/rsyslog.d/01-syslog_forwarder.conf

      for dir in "${LOG_DIRS[@]}"; do
        mkdir -p $dir
        if [ ! -f $dir/out.log ]; then
          touch $dir/out.log
        fi
      done

      /usr/sbin/service rsyslog restart

    <% end %>

    echo $$ > $PIDFILE

    while true; do sleep 10000; done

    ;;

  stop)
    kill_and_wait $PIDFILE 55
    ;;

  *)
    echo "Usage: syslog-configurator_ctl {start|stop}"
    ;;

esac

#!/bin/bash -e

JOB_DIR=/var/vcap/jobs/syslog-configurator
PIDFILE=/var/vcap/sys/run/syslog-configurator.pid
declare -a LOG_DIRS=(
  "/var/vcap/sys/log/service-backup"
  "/var/vcap/sys/log/service-metrics"
)

source /var/vcap/packages/redis-common/utils.sh

case $1 in

  start)
    <% if_p("syslog_aggregator.address", "syslog_aggregator.port") do %>

      CONFIG_DIR=$JOB_DIR/config

      if [ ! -d $CONFIG_DIR ]
      then
        echo "$CONFIG_DIR not found"
        exit 1
      fi

      cp $CONFIG_DIR/syslog_forwarder.conf /etc/rsyslog.d/05-syslog_forwarder.conf

      for dir in "${LOG_DIRS[@]}"; do
        mkdir -p $dir
        if [ ! -f $dir/out.log ]; then
          touch $dir/out.log
        fi
      done

      /usr/sbin/service rsyslog restart

    <% end %>

    echo $$ > $PIDFILE

    while true; do sleep 10000; done

    ;;

  stop)
    kill_and_wait $PIDFILE 55
    ;;

  *)
    echo "Usage: syslog-configurator_ctl {start|stop}"
    ;;

esac

Update syslog forwarder conf filename
Update syslog forwarder conf filename

[#117896407]

Signed-off-by: Henry Stanley <b0b1d04541cab6bb75fdc9ee8f1c2e7f813af8bc@pivotal.io>
