#!/bin/bash

DEFAULT_PACE=1000
DEFAULT_PIPE=/tmp/cca
CCAD_CONF=/etc/ccad.conf
STATUS_URL='http://in/server-status?auto'
CURL=/usr/bin/curl
SED=/bin/sed
SLEEP=/bin/sleep


function get_value_from_config {
   CONF_VALUE=`grep -oE "$1[[:space:]]*=[[:space:]]*[^[:space:]]+" $CCAD_CONF |cut -d"=" -f 2|tr -d " "`
}

get_value_from_config "pace" 
PACE=${CONF_VALUE:-$DEFAULT_PACE}
PACE=$(( $PACE / 1000 ))

get_value_from_config "pipe" 
PIPE=${CONF_VALUE:-$DEFAULT_PIPE}
test -p $PIPE || exit 3

while true; do
   $CURL -s "$STATUS_URL" | $SED "s/^Total\ /Total_/g" > $PIPE
   sleep $PACE || exit 4
   echo "." > $PIPE
done

