#!/bin/sh

. /etc/rc.status

# Reset status of this service
rc_reset
bin_dir=/opt/NGS/makRti4.5/bin/
conf_dir=/opt/NGS/makRti4.5-conf/

case "$1" in
    start)
        export RTI_ASSISTANT_DISABLE=1
        ${bin_dir}/rtiexec -R ${conf_dir}/rid.mtl &
        # ${bin_dir}/rtiForwarder -R ${conf_dir}/rid.mtl -t 192.168.133.147 -T 4001 -A 229.7.7.7 -P 4000 -N 192.168.133.147 -M -D 5050 &
        ${bin_dir}/rtiForwarder -R ${conf_dir}/rid.mtl -t 192.168.99.100 -T 4001 -A 229.7.7.7 -P 4000 -N 192.168.99.100 -M -D 5050 &
        ;;
    stop)
        ps -ef | grep rtiForwarder | awk '$0 !~ /grep/ {system("kill "$2)}'
        ps -ef | grep rtiexec | awk '$0 !~ /grep/ {system("kill "$2)}'
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start

        # Remember status and be quiet
        rc_status
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|}"
        exit 1
        ;;
esac
rc_exit


