-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·50 lines (39 loc) · 1.98 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·50 lines (39 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash
# check if Python is there , grep -q means quite
if which python | grep -q 'python'; then
# check if the version is right. Notice we redirect stderr to stdout, because python outputs in stderr
if python --version 2>&1 | grep -q '2.7'; then
echo 'Python 2.7 found in the system.'
else
echo 'A version of Python other than 2.7 was found in the system. Track-Dir-Change might not work (but try it)'
fi
if which python | grep -q '/usr/bin/python'; then
echo 'Python found at the expected location.'
else
echo 'Python found in different location than expected, updating the script...'
sed -i '' s%/usr/bin/python%`which python`% trackDirFileChanges.py
fi
else
echo 'Python not found. Install Python 2.7 and try again'; exit
fi
# Check if an argument was provided. If not exit with error message Usage: ./install.sh DIR_MONITORED
${1?"Usage: $0 DIR_MONITORED"}
# substitute HOMEDIR with the current dir in the plist template.
# Use % instead of the usual / because the directory path contains /
# also create a new file, do not substitute infile
sed s%HOMEDIR%`pwd`%g net.boulis.TrackDir.plist.template > net.boulis.TrackDir.plist
# substitute TRACKEDDIR infile with the first argument to the install script
sed -i '' s%TRACKEDDIR%$1%g net.boulis.TrackDir.plist
echo 'Created plist file from template.'
# check if an older agent is there
if [ -f ~/Library/LaunchAgents/net.boulis.TrackDir.plist ]; then
echo "Older plist file found, trying to stop and unload old agent."
launchctl stop net.boulis.TrackDir
launchctl unload ~/Library/LaunchAgents/net.boulis.TrackDir.plist
rm ~/Library/LaunchAgents/net.boulis.TrackDir.plist
fi
# move the newly created plist file in the right location, so that the agent can start automatically at bootup.
mv net.boulis.TrackDir.plist ~/Library/LaunchAgents/
# launch the agent
launchctl load ~/Library/LaunchAgents/net.boulis.TrackDir.plist
echo 'New agent loaded and launched.'