#!/bin/bash
#

#
# antennad   File for automatic startup of Vaisala antenna daemon, on Linux platforms
#
# chkconfig: 345 97 0
# description: Vaisala antennad startup file

# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sigmet/profile.conf
. /etc/profile.d/sigmet.sh

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

if [ ! -x ${install_root}/bin/start_antennad ] ; then
    echo "ERROR: ${install_root}/bin/start_antennad file missing"
    exit 0
fi
if [ ! -x ${install_root}/bin/stop_antennad ] ; then
    echo "ERROR: ${install_root}/bin/stop_antennad file missing"
    exit 0
fi

RETVAL=0


start() {
  # Execute the commands to start iris
    echo -n $"Starting antennad: "
    ${install_root}/bin/start_antennad
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
	echo_success
    else
	echo_failure
    fi
    echo
    return $RETVAL
}

stop() {
  # Execute the commands to stop iris
    echo -n $"Stopping antennad: "
    ${install_root}/bin/stop_antennad
    RETVAL=$?
    echo
    return $RETVAL
}


case $1 in

'start')
	start
	;;

'stop')
	stop
	;;

'restart')
	stop
	start
	;;

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

exit $?
