#!/bin/bash

PRODDIR=/opt/products/dstar

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

if [ ! -d $PRODDIR ] ; then
	echo "$PRODDIR not found"
	exit
fi

DSTARGW=/opt/products/dstar/dstar_gw
DSIPSVD=$DSTARGW/dsipsvd/dsipsvd.conf

if [ ! -r $DSIPSVD ]; then
    echo "$DSIPSVD not found"
    exit
fi

cd /tmp

if [ -d $PRODDIR/apache ] ; then
#G2 install
curl -O http://www.opendstar.org/.admins/.certs/dsgw-cert-install-G2.sh
bash ./dsgw-cert-install-G2.sh
else
#G3 install
curl -O http://www.opendstar.org/.admins/.certs/dsgw-cert-install-G3.sh
bash ./dsgw-cert-install-G3.sh
fi

exit 0
