#!/bin/bash

# Bash loop monitors requests and branches to options

cd /usr/local/observatory/control

echo "idle" > status

for (( ; ; ))
do
if [ -f ./on ]; then
  /usr/local/bin/cdk20n_on
  rm on
  echo "on" > status
fi

if [ -f ./off ]; then
  /usr/local/bin/cdk20n_off
  rm off
  echo "off" > status
fi

if [ -f ./queue ]; then
  /usr/local/bin/queue_run
  rm queue
  echo "queue" > status
fi


if [ -f ./remote ]; then
  /usr/local/bin/remote_run
  rm remote
  echo "remote" > status
fi

if [ -f ./halt ]; then
  rm halt
  echo "halt" > status
  break
fi

sleep 10

done

exit
