#!/bin/bash

if [ -z "${DEVICE_ID}" ]; then
	echo "device id is null"
	exit -1
fi

ROOT_WORKSPACE=${WORKROOT}
STORAGE_PATH="/opt/.airship/storage/"
mkdir -p ${STORAGE_PATH}
${ROOT_WORKSPACE}/airship-agent ::: nodeinfo storage update --path ${STORAGE_PATH}

while :;
do
  NUM=`ps -ef | grep 'airship-agent' | grep -v grep | wc -l`
  if [ "${NUM}" -lt "1" ];
  then
	${ROOT_WORKSPACE}/airship-agent serve --workspace /opt/.airship --class box --supplier-id ${SUPPLIER_ID} --supplier-device-id ${DEVICE_ID} --daemon=false			
  fi
  sleep 30
done
