#!/bin/bash

if [ $EUID != 0 ] ; then
	echo "installer must be run as root"
	exit
fi

DSIPSVD_FILE=/etc/dsipsvd.conf

GW_CALL=`egrep -e '^ZR_CALLSIGN' $DSIPSVD_FILE | sed -e 's/ //g' | awk -F"=" '{print $2}' |sed -e 's/\r//'`

if [ X$GW_CALL == X ] ; then
	echo "unknown gateway callsign"
	exit
fi

cd /dstar/tmp

/dstar/tools/dplus-readv1

curl -O http://www.opendstar.org/tools/G2/gateways.txt
curl -O http://www.opendstar.org/tools/G2/users.txt

nohup /dstar/tools/dplus -c $GW_CALL >/var/log/dplus.log 2>&1 &

echo "dplus started for v1"
