#!/bin/sh

case "$1" in
  start)
    printf "Starting WEB UI: "
    [ ! -d /userdata/upgrade ] && mkdir -p /userdata/upgrade && sync
    /www/speaker-cgi -configPath /etc/ -embedStatic -uploadPath /userdata/upgrade > /dev/null &
    [ $? = 0 ] && echo "OK" || echo "FAIL"
    ;;
  stop)
    printf "Stopping WEB UI: "
    killall speaker-cgi
    [ $? = 0 ] && echo "OK" || echo "FAIL"
    ;;
  restart|reload)
    "$0" stop
    "$0" start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac