#!/bin/sh
### BEGIN INIT INFO
# Provides:          edgeserver
# Required-Start:    $syslog $local_fs $remote_fs postgresql
# Should-Start:      aksusbd
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:	     0 1 6
# Short-Description: Run /opt/platform.init if it exist
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
	if [ -x /opt/platform.init ]; then
	        [ "$VERBOSE" != no ] && log_begin_msg "Running EDGE boot script (/opt/platform.init)"
		/opt/platform.init
		ES=$?
		[ "$VERBOSE" != no ] && log_end_msg $ES
		return $ES
	fi
}

do_stop() {
	if [ -x /opt/platform.shutdown ]; then
	        [ "$VERBOSE" != no ] && log_begin_msg "Running EDGE shutdown script (/opt/platform.shutdown)"
		/opt/platform.shutdown
		ES=$?
		[ "$VERBOSE" != no ] && log_end_msg $ES
		return $ES
	fi
}

case "$1" in
    start)
	do_start
        ;;
    reload|force-reload)
        echo "Error: argument '$1' currently not supported" >&2
        exit 3
        ;;
    stop)
	do_stop
        ;;
    restart)
	do_stop
	sleep 5
	do_start
	;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
