#!/bin/sh

ARGS=$1

OSFLAVOR=`uname`
if [ $OSFLAVOR = 'SunOS' -o $OSFLAVOR = 'FreeBSD' ]
then
	ARGS=0
fi

if [ $OSFLAVOR = 'Linux' -a $ARGS = 'remove' ]
then
	ARGS=0
fi


if [ -z "$OSVC_ROOT_PATH" ]
then
	FLAG=/var/lib/opensvc/postinstall.restart
else
	FLAG=$OSVC_ROOT_PATH/var/postinstall.restart
	PATH=$PATH:$OSVC_ROOT_PATH/bin
	export PATH
fi

nodemgr daemon running >/dev/null 2>&1
RUNNING=$?

if [ "$ARGS" = '0' ]
then
	# uninstall package
	if [ $RUNNING -eq 0 ]
	then
                echo "stopping opensvc daemon"
		nodemgr daemon stop
	fi
	exit 0
fi

