From 25981deac42070674ba8588b6544ad6407ca97df Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Mon, 14 Sep 2015 23:20:13 -0400 Subject: [PATCH] conditionalize the install/uninstall scripts to support linux or darwin. --- script/install | 20 ++++++++++++++++---- script/uninstall | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/script/install b/script/install index c4eaf76..450d377 100755 --- a/script/install +++ b/script/install @@ -7,9 +7,21 @@ echo "Installing Homebridge..." APP_PATH=`pwd` USER_NAME=`whoami` -cp startup/org.homebridge.plist ~/Library/LaunchAgents/org.homebridge.plist -sed -i '' -e "s#%USER%#$USER_NAME#g" ~/Library/LaunchAgents/org.homebridge.plist -sed -i '' -e "s#%PATH%#$APP_PATH#g" ~/Library/LaunchAgents/org.homebridge.plist +if [[ "$OSTYPE" == "linux*" ]]; then +## install for linux + echo "" +elif [[ "$OSTYPE" == "darwin"* ]]; then + ## install for OS X -launchctl load -w -F ~/Library/LaunchAgents/org.homebridge.plist + # copy template plist to the correct path. + cp startup/org.homebridge.plist ~/Library/LaunchAgents/org.homebridge.plist + + # Set the current user for the script to run as. + sed -i '' -e "s#%USER%#$USER_NAME#g" ~/Library/LaunchAgents/org.homebridge.plist + # Set the current path for where the app lives. + sed -i '' -e "s#%PATH%#$APP_PATH#g" ~/Library/LaunchAgents/org.homebridge.plist + + # Tell launchd to start it. + launchctl load -w -F ~/Library/LaunchAgents/org.homebridge.plist +fi diff --git a/script/uninstall b/script/uninstall index 50a6745..753e4d0 100755 --- a/script/uninstall +++ b/script/uninstall @@ -1,6 +1,17 @@ #!/bin/sh echo "Uninstalling Homebridge..." +# make forever stop the app. forever stop homebridge > /dev/null 2>&1 -launchctl unload ~/Library/LaunchAgents/org.homebridge.plist -rm ~/Library/LaunchAgents/org.homebridge.plist + +if [[ "$OSTYPE" == "linux*" ]]; then +## install for linux + echo "" +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