-
Notifications
You must be signed in to change notification settings - Fork 1
/
ServiceInstall.sh
26 lines (21 loc) · 1.4 KB
/
ServiceInstall.sh
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
#!/bin/bash
OS_BUILD=`sw_vers -buildVersion | /usr/bin/colrm 3`
User=`logname`
#Install LaunchD 'watchfile' to watch Manifest.plist for changes.
if [ $OS_BUILD = "9" ]
then
#10.6
Manifest="/Users/$User/Library/Application Support/AppStore/manifest.plist"
else
#10.7/8/9/10/11/12
Manifest=`find /var/folders -name manifest.plist 2>/dev/null | grep "/C/com.apple.appstore"`
fi
/usr/libexec/PlistBuddy -c "Add :Label string com.watch.manifest.appstore.apple" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
/usr/libexec/PlistBuddy -c "Add :ProgramArguments array" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
#test #/usr/libexec/PlistBuddy -c "Add :ProgramArguments:Item\ 0 string 'say lol'" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
/usr/libexec/PlistBuddy -c "Add :ProgramArguments:Item\ 0 string '/Users/$User/.repkg.sh'" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
/usr/libexec/PlistBuddy -c "Add :WatchPaths array '$Manifest'" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
/usr/libexec/PlistBuddy -c "Add :WatchPaths:Item\ 0 string '$Manifest'" /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist
cd "$(dirname "$0")"
cp ./repkg.sh /Users/$User/.repkg.sh
launchctl load -w /Users/$User/Library/LaunchAgents/com.watch.manifest.appstore.apple.plist