-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetApplicationPermission.sh
66 lines (43 loc) · 1.44 KB
/
setApplicationPermission.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
63
64
65
66
#!/bin/sh
####################################################################################################
#
# ABOUT
#
# Sets permissions on the application passed as Parameters 4 & 5.
#
####################################################################################################
#
# HISTORY
#
# Version 1.0, 12-Dec-2017, Dan K. Snelson
#
####################################################################################################
# Variables
loggedInUser=$(stat -f%Su /dev/console)
applicationPath="$5"
# If Parameter 5 is blank, exit ...
if [ -z "${applicationPath}" ]; then
echo "Application Path not specified; exiting."
exit 1
fi
# Check for a specified owner (Parameter 4)
# Defaults to currently logged-in user
if [ "$4" != "" ] && [ "$owner" == "" ]; then
owner="${4}"
else
echo "Parameter 4 is blank; using \"${loggedInUser}\" as the owner."
owner="${loggedInUser}"
fi
# Check if the specified application is installed ...
testDirectory="/Applications/${applicationPath}"
if [ -d "${testDirectory}" ] ; then
echo "/Applications/${applicationPath} located; proceeding ..."
echo "Setting permissions on /Applications/${applicationPath} ..."
/usr/sbin/chown ${owner} "/Applications/${applicationPath}"
echo "Set owner of \"/Applications/${applicationPath}\" to ${owner}."
exit 0
else
echo "/Applications/${applicationPath} NOT found; nothing to do."
exit 0
fi
exit 0