#!/bin/bash
### BEGIN INIT INFO
# Provides:          exagear-dsound-server
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: autostarter for ExaGear dsound server
# Description:       autostarter for ExaGear dsound server
### END INIT INFO

#
# This script is an autostarter for ExaGear dsound server
#
# Copyright (c) 2017 "Elbrus Technologies" LLC. All rights reserved.
#
# This script comes with NO warranty, not even for MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#

runlevel_normal=2
runlevel_stop=0

DSOUND_SERVER=/usr/bin/exagear-dsound-server

function invoke_start {
    start-stop-daemon -b -S -x ${DSOUND_SERVER}
}

function invoke_stop {
    start-stop-daemon  -K -x ${DSOUND_SERVER}
}

case "$1" in
    start|force-reload|reload)
        invoke_start "$@"
        ;;
    stop)
        invoke_stop "$@"
        ;;
    restart)
        invoke_stop stop
        invoke_start start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload|reload}"
        ;;
esac
