#!/bin/sh
#

if [ -d "/opt/openfire" ]; then
	/bin/rm -rf /tmp/openfireInstallBackup
	/bin/mkdir -p /tmp/openfireInstallBackup

	if [ -f /opt/openfire/conf/openfire.xml ]; then
		/bin/cp -f /opt/openfire/conf/openfire.xml /tmp/openfireInstallBackup/openfire.xml
	fi
	if [ -f /opt/openfire/conf/security.xml ]; then
		/bin/cp -f /opt/openfire/conf/security.xml /tmp/openfireInstallBackup/security.xml
	fi
	if [ -f /opt/openfire/resources/security/keystore ]; then
		/bin/cp -f /opt/openfire/resources/security/keystore /tmp/openfireInstallBackup/keystore
	fi
	if [ -f /opt/openfire/resources/security/truststore ]; then
		/bin/cp -f /opt/openfire/resources/security/truststore /tmp/openfireInstallBackup/truststore
	fi
	if [ -f /opt/openfire/resources/security/client.truststore ]; then
		/bin/cp -f /opt/openfire/resources/security/client.truststore /tmp/openfireInstallBackup/client.truststore
	fi
	if [ -f /opt/openfire/lib/log4j.xml ]; then
		/bin/cp -f /opt/openfire/lib/log4j.xml /tmp/openfireInstallBackup/log4j.xml
	fi

	if [ -x "/usr/sbin/svcadm" ]; then
		/usr/sbin/svcadm disable openfire
	fi

	if [ -x "/usr/sbin/svccfg" ]; then
		/usr/sbin/svccfg delete -f openfire
	fi
fi
