#!/bin/sh

echo "Uninstalling Homebridge..."
# make forever stop the app.
forever stop homebridge > /dev/null 2>&1

if [[ "$OSTYPE" == "linux*" ]]; then
  ## uninstall for linux

  # stop the service.
  sudo /etc/init.d/homebridge stop

  # remove the service from launching at boot.
  sudo update-rc.d -f homebridge remove
elif [[ "$OSTYPE" == "darwin"* ]]; then
  ## uninstall for OS X

  # tell launchd to stop the process.
  launchctl unload ~/Library/LaunchAgents/org.homebridge.plist
  # remove the launchd script.
  rm ~/Library/LaunchAgents/org.homebridge.plist
fi
