#!/usr/bin/env sh
 
PLIST_PRODUCT=com.tarantool.tarantool.plist
LUANCHD_PLIST=/Library/LaunchDaemons/${PLIST_PRODUCT}

if [ -f ${LUANCHD_PLIST} ]
then
	launchctl unload ${LUANCHD_PLIST}
	rm -f ${LUANCHD_PLIST}
fi

cp ${3}/share/tarantool/${PLIST_PRODUCT} ${LUANCHD_PLIST}

if [ -f ${LUANCHD_PLIST} ]
then
	launchctl load ${LUANCHD_PLIST}
else
	echo "${LUANCHD_PLIST} could not install"
	exit 1
fi

exit 0
