conditionalize the install/uninstall scripts to support linux or darwin.

This commit is contained in:
Jon Maddox
2015-09-14 23:20:13 -04:00
parent 6540c25baf
commit 25981deac4
2 changed files with 29 additions and 6 deletions

View File

@@ -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