#!/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/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

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

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