#!/bin/bash
set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

JOB_NAME=route-registrar

RUN_DIR=/var/vcap/sys/run/cf-mysql-broker
LOG_DIR=/var/vcap/sys/log/cf-mysql-broker

PIDFILE=$RUN_DIR/route-registrar.pid
CONFIG_FILE=/var/vcap/jobs/proxy/config/route-registrar.yml

source /var/vcap/packages/cf-mysql-common/utils.sh

export HOME=/var/vcap

case $1 in

start)

  mkdir -p $RUN_DIR
  mkdir -p $LOG_DIR

  pid_guard $PIDFILE $JOB_NAME

  /var/vcap/packages/cf-mysql-route-registrar/bin/route-registrar \
  -pidfile=$PIDFILE \
  -configPath=$CONFIG_FILE \
  >>$LOG_DIR/route-registrar.stdout.log 2>>$LOG_DIR/route-registrar.stderr.log&
;;

stop)
  kill_and_wait $PIDFILE
;;

*)
echo "Usage: route_registrar_ctl {start|stop}" ;;

esac
exit 0

#!/bin/bash
set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

JOB_NAME=route-registrar

RUN_DIR=/var/vcap/sys/run/cf-mysql-broker
LOG_DIR=/var/vcap/sys/log/cf-mysql-broker

PIDFILE=$RUN_DIR/route-registrar.pid
CONFIG_FILE=/var/vcap/jobs/proxy/config/route-registrar.yml

source /var/vcap/packages/cf-mysql-common/utils.sh

case $1 in

start)

  mkdir -p $RUN_DIR
  chown -R vcap:vcap $RUN_DIR
  mkdir -p $LOG_DIR
  chown -R vcap:vcap $LOG_DIR

  pid_guard $PIDFILE $JOB_NAME

  su vcap -c "/var/vcap/packages/cf-mysql-route-registrar/bin/route-registrar \
  -pidfile=$PIDFILE \
  -configPath=$CONFIG_FILE \
  >>$LOG_DIR/route-registrar.stdout.log \
  2>>$LOG_DIR/route-registrar.stderr.log &"
;;

stop)
  kill_and_wait $PIDFILE
;;

*)
echo "Usage: route_registrar_ctl {start|stop}" ;;

esac
exit 0

Make route-registrar run as vcap
Make route-registrar run as vcap

- We removed the export of HOME as it did not appear to be necessary

[#115623381]

Signed-off-by: Andrew Crump <bad96bc28586e95c5d7da81c13d926ea5028b22f@pivotal.io>
