#!/bin/sh

echo "Bacula file daemon @BACULA_VERSION@ uninstaller"

# Remove startup item
echo "* Bacula startup item... "
if [ -f /Library/LaunchDaemons/org.bacula.bacula-fd.plist ]; then
	sudo launchctl unload /Library/LaunchDaemons/org.bacula.bacula-fd.plist
	sudo rm /Library/LaunchDaemons/org.bacula.bacula-fd.plist
	echo "  + removed successfully"
else
  echo "  - not found, nothing to remove"
fi

echo "* Bacula file daemon... "
if [ -d "/usr/local/bacula-@BACULA_VERSION@" ]; then
  sudo rm -r "/usr/local/bacula-@BACULA_VERSION@"
	echo "  + removed successfully"
else
  echo "  - not found, nothing to remove"  
fi

echo "* Installer receipt... "
if [ -d "/Library/Receipts/Bacula File Daemon @BACULA_VERSION@.pkg" ]; then
  sudo rm -r "/Library/Receipts/Bacula File Daemon @BACULA_VERSION@.pkg"
	echo "  + removed successfully"
else
  echo "  - not found, nothing to remove"  
fi
