#!/bin/sh
# name:        rmnrserver.sh
# description: Stop daemon and remove previous version before package is upgraded
# os:          FreeBSD
# contact:     support@neorouter.com 

printusage()
{
    echo "Usage: $0 {userdata}"
}

prefix=/usr/local
NEOROUTERROOT=$prefix/ZebraNetworkSystems/NeoRouter

# ensure nrserver is not running
pkill nrserver

if [ "$1" = '' ] || [ "$1" = 'userdata' ]; then
    #remove NeoRouter server package
    rm $prefix/bin/nrserver
	rm $prefix/etc/rc.d/nrserver.sh
    rm $NEOROUTERROOT/openssl.cnf
    rm $NEOROUTERROOT/nrserver.README
    #remove userdata
    if [ "$1" = 'userdata' ]; then
        #remove user data used by NeoRouter server package
        rm $NEOROUTERROOT/*.db
        rm $NEOROUTERROOT/server.key
        rm $NEOROUTERROOT/server.crt
    fi

    #remove this script
    rm $prefix/bin/rmnrserver.sh
else
    printusage
    exit 1
fi

