#!/bin/sh

if [ -f /tmp/openfireInstallBackup/openfire.xml ]; then 
	/bin/mv /tmp/openfireInstallBackup/openfire.xml /usr/local/openfire/conf/openfire.xml
fi
if [ -f /tmp/openfireInstallBackup/security.xml ]; then 
	/bin/mv /tmp/openfireInstallBackup/security.xml /usr/local/openfire/conf/security.xml
fi

if [ -f /tmp/openfireInstallBackup/keystore ]; then
	/bin/mv /tmp/openfireInstallBackup/keystore /usr/local/openfire/resources/security/keystore
fi

if [ -f /tmp/openfireInstallBackup/truststore ]; then
	/bin/mv /tmp/openfireInstallBackup/truststore /usr/local/openfire/resources/security/truststore
fi

if [ -f /tmp/openfireInstallBackup/client.truststore ]; then
	/bin/mv /tmp/openfireInstallBackup/client.truststore /usr/local/openfire/resources/security/client.truststore
fi

if [ -f /tmp/openfireInstallBackup/log4j.xml ]; then
	/bin/mv /tmp/openfireInstallBackup/log4j.xml /usr/local/openfire/lib/log4j.xml
fi

OPENFIRE_HOME=/usr/local/openfire/
OPENFIRE_GID=`cat /private/tmp/openfiregid`
rm /private/tmp/openfiregid

sudo chown -R openfire $OPENFIRE_HOME
sudo chgrp -R $OPENFIRE_GID $OPENFIRE_HOME
sudo chmod o-rwx $OPENFIRE_HOME
sudo chown root:wheel /Library/LaunchDaemons/org.jivesoftware.openfire.plist

/bin/launchctl load /Library/LaunchDaemons/org.jivesoftware.openfire.plist
