#!/usr/bin/env bash pid=$2 launchDir=~/Library/LaunchAgents/ if $1; then if [ ! -d "$launchDir" ]; then mkdir "$launchDir" fi launchctl unload ~/Library/LaunchAgents/com.symphony-search.data.plist cat > ~/Library/LaunchAgents/com.symphony-search.data.plist << EOT Label com.symphony-search.data.agent ProgramArguments /bin/sh scriptPath false SymphonyPID RunAtLoad StartInterval 60 StandardOutPath /dev/null StandardErrorPath /dev/null EOT launchctl load ~/Library/LaunchAgents/com.symphony-search.data.plist elif ps -p $pid > /dev/null then echo true else echo false rm -rf dataPath launchctl unload ~/Library/LaunchAgents/com.symphony-search.data.plist rm -rf ~/Library/LaunchAgents/com.symphony-search.data.plist fi