-
Notifications
You must be signed in to change notification settings - Fork 2
/
privilegesPostInstall.sh
62 lines (49 loc) · 1.48 KB
/
privilegesPostInstall.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# postinstall.sh
# Marc Thielemann, 2016/08/26
ERROR=0
HELPER_PATH="$3/Applications/Utilities/Privileges.app/Contents/Library/LaunchServices/corp.sap.privileges.helper"
if [[ -f "$HELPER_PATH" ]]; then
# create the target directory if needed
if [[ ! -d "$3/Library/PrivilegedHelperTools" ]]; then
/bin/mkdir -p "$3/Library/PrivilegedHelperTools"
/bin/chmod 755 "$3/Library/PrivilegedHelperTools"
/usr/sbin/chown -R root:wheel "$3/Library/PrivilegedHelperTools"
fi
# move the privileged helper into place
/bin/cp -f "$HELPER_PATH" "$3/Library/PrivilegedHelperTools"
if [[ $? -eq 0 ]]; then
/bin/chmod 755 "$3/Library/PrivilegedHelperTools/corp.sap.privileges.helper"
# create the launchd plist
PLIST="$3/Library/LaunchDaemons/corp.sap.privileges.helper.plist"
/bin/cat > "$PLIST" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>corp.sap.privileges.helper</string>
<key>MachServices</key>
<dict>
<key>corp.sap.privileges.helper</key>
<true/>
</dict>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/corp.sap.privileges.helper</string>
</array>
</dict>
</plist>
EOF
/bin/chmod 644 "$PLIST"
# load the launchd plist only if installing on the boot volume
if [[ "$3" = "/" ]]; then
/bin/launchctl load -wF "$PLIST"
fi
else
ERROR=1
fi
else
ERROR=1
fi
exit $ERROR