Skip to content

Commit

Permalink
Merge pull request echocat#164 from trovitsys/master
Browse files Browse the repository at this point in the history
Fix init script error for Redhat and fix some bash style
  • Loading branch information
dwerder committed Mar 20, 2015
2 parents f4b869d + d1da88f commit 3f7d193
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
18 changes: 9 additions & 9 deletions templates/etc/init.d/Debian/carbon-aggregator.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ STOP_COUNTER=12 # 12 times 5s -> 60 secs
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

case "${OPERATION}" in
Expand All @@ -35,16 +35,16 @@ case "${OPERATION}" in
for INSTANCE in ${INSTANCES}; do
${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop
sleep 3
CNT=$STOP_COUNTER
while [ `/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"` -eq 1 ]; do
CNT=${STOP_COUNTER}
while [ $(/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}") -eq 1 ]; do
echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop"
sleep 5
if [ $CNT -lt 1 ]; then
pid=`/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"`
test -n $pid && kill -9 $pid
if [ ${CNT} -lt 1 ]; then
pid=$(/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}")
test -n ${pid} && kill -9 ${pid}
break
fi
CNT=`expr ${CNT} - 1`
CNT=$(expr ${CNT} - 1)
done
done
;;
Expand All @@ -54,7 +54,7 @@ case "${OPERATION}" in
done
;;
restart)
$0 stop $INSTANCES && sleep 2 && $0 start $INSTANCES
$0 stop ${INSTANCES} && sleep 2 && $0 start ${INSTANCES}
;;
*)
echo "Usage: $0 {start|stop|restart|status} [instance instance ...]"
Expand Down
18 changes: 9 additions & 9 deletions templates/etc/init.d/Debian/carbon-cache.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ STOP_COUNTER=12 # 12 times 5s -> 60 secs
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

case "${OPERATION}" in
Expand All @@ -35,16 +35,16 @@ case "${OPERATION}" in
for INSTANCE in ${INSTANCES}; do
${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop
sleep 3
CNT=$STOP_COUNTER
while [ `/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"` -eq 1 ]; do
CNT=${STOP_COUNTER}
while [ $(/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}") -eq 1 ]; do
echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop"
sleep 5
if [ $CNT -lt 1 ]; then
pid=`/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"`
test -n $pid && kill -9 $pid
if [ ${CNT} -lt 1 ]; then
pid=$(/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}")
test -n ${pid} && kill -9 ${pid}
break
fi
CNT=`expr ${CNT} - 1`
CNT=$(expr ${CNT} - 1)
done
done
;;
Expand All @@ -54,7 +54,7 @@ case "${OPERATION}" in
done
;;
restart)
$0 stop $INSTANCES && sleep 2 && $0 start $INSTANCES
$0 stop ${INSTANCES} && sleep 2 && $0 start ${INSTANCES}
;;
*)
echo "Usage: $0 {start|stop|restart|status} [instance instance ...]"
Expand Down
19 changes: 9 additions & 10 deletions templates/etc/init.d/Debian/carbon-relay.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ STOP_COUNTER=12 # 12 times 5s -> 60 secs
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

case "${OPERATION}" in
Expand All @@ -35,17 +35,16 @@ case "${OPERATION}" in
for INSTANCE in ${INSTANCES}; do
${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop
sleep 3
CNT=$STOP_COUNTER
while [ `/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"` -eq 1 ]; do
CNT=${STOP_COUNTER}
while [ $(/usr/bin/pgrep -cf "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}") -eq 1 ]; do
echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop"
sleep 5
if [ $CNT -lt 1 ];
then
pid=`/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}"`
test -n $pid && kill -9 $pid
if [ ${CNT} -lt 1 ]; then
pid=$(/usr/bin/pgrep -f "carbon-${CARBON_DAEMON}.py --instance=${INSTANCE}")
test -n ${pid} && kill -9 ${pid}
break
fi
CNT=`expr ${CNT} - 1`
CNT=$(expr ${CNT} - 1)
done
done
;;
Expand All @@ -55,7 +54,7 @@ case "${OPERATION}" in
done
;;
restart)
$0 stop $INSTANCES && sleep 2 && $0 start $INSTANCES
$0 stop ${INSTANCES} && sleep 2 && $0 start ${INSTANCES}
;;
*)
echo "Usage: $0 {start|stop|restart|status} [instance instance ...]"
Expand Down
8 changes: 4 additions & 4 deletions templates/etc/init.d/RedHat/carbon-aggregator.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pidfile=""
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

start()
Expand All @@ -46,7 +46,7 @@ start()
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down Expand Up @@ -111,7 +111,7 @@ restart() {
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down
8 changes: 4 additions & 4 deletions templates/etc/init.d/RedHat/carbon-cache.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pidfile=""
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

start()
Expand All @@ -46,7 +46,7 @@ start()
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down Expand Up @@ -111,7 +111,7 @@ restart() {
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down
8 changes: 4 additions & 4 deletions templates/etc/init.d/RedHat/carbon-relay.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pidfile=""
OPERATION="$1"
if [ $# -gt 1 ]; then
shift
INSTANCES=$@
INSTANCES=$*
else
INSTANCES=`grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2`
INSTANCES=$(grep "^\[${CARBON_DAEMON}" ${GRAPHITE_DIR}/conf/carbon.conf | cut -d \[ -f 2 | cut -d \] -f 1 | cut -d : -f 2)
fi

start()
Expand All @@ -46,7 +46,7 @@ start()
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down Expand Up @@ -111,7 +111,7 @@ restart() {
retval=$?
pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid
echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..."
if [ rh_status_q ]; then
if rh_status_q; then
touch /var/lock/subsys/carbon-${CARBON_DAEMON}-${INSTANCE}
echo_success
echo
Expand Down

0 comments on commit 3f7d193

Please sign in to comment.