#!/bin/sh
printf "Content-Type: application/json\n\n"

while start-stop-daemon -K -q -x "/home/hubclient/bin/hub"
do 
	usleep 100000
done

start-stop-daemon -S -q -b -x "/home/hubclient/bin/hub" -- -r
#restart hubclientdaemon
#start-stop-daemon doesn't recognize shell scripts with -x option, so kill it
# with killall before strat it with start-stop-daemon
killall hub_daemon_starter.sh
start-stop-daemon -K -q -x "/home/hubclient/bin/hubclientdaemon"
start-stop-daemon -S -q -b -x "/home/hubclient/bin/hub_daemon_starter.sh"
printf "{}"
