#!/bin/bash

RUN_DIR=/var/vcap/sys/run/pinger
LOG_DIR=/var/vcap/sys/log/pinger
PIDFILE=${RUN_DIR}/pid

case $1 in

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

    echo $$ > $PIDFILE

    exec /var/vcap/packages/ping-app/bin/pinger \
    --listenPort <%= p('port') %> \
    --interval <%= p('ping_interval') %> \
    <% pinger_addresses = link('pinger').instances.map(&:address) %>
    <% (pinger_addresses - spec.address).each do |address| %>
    --address <%= address %>
    <% end %>

    ;;

  stop)
    kill -9 `cat $PIDFILE`
    rm -f $PIDFILE

    ;;

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

esac

#!/bin/bash

RUN_DIR=/var/vcap/sys/run/pinger
LOG_DIR=/var/vcap/sys/log/pinger
PIDFILE=${RUN_DIR}/pid

case $1 in

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

    echo $$ > $PIDFILE

    exec /var/vcap/packages/ping-app/bin/pinger \
    --listenPort <%= p('port') %> \
    --interval <%= p('ping_interval') %> \
    <% pinger_addresses = link('pinger').instances.map(&:address) -%>
    <% (pinger_addresses - [spec.address]).each do |address| -%>
    --address <%= address %>:<%= p('port') %> \
    <% end -%>

    ;;

  stop)
    kill -9 `cat $PIDFILE`
    rm -f $PIDFILE

    ;;

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

esac

Use trimming to avoid newlines in startup script
Use trimming to avoid newlines in startup script
