#!/bin/sh
#  executed at boot time with start or stop as argument
#  "start" may be followed by a mission script and other args
#
#  Starts or stops a local esp server
#

mission=    #mission to continue

: ${ESPcmdPort:=9999} ${ESPcheckpoints:=0}
export ESPcmdPort ESPcheckpoints

case "$1" in
  start)
    shift
    [ "$1" ] && mission="$@"
    out="`echo ~ftp`/$USER/$ESPmode/`date +%F%Z%H%M`.out" start esp $mission
   ;;

  stop)
    echo 'ESP.quit!' | espclient -r localhost shutdown
   ;;

  *)
    echo "usage:  $0 {start {optional mission} | stop}"
   ;;
esac