Skip to content

Commit 0b7498b

Browse files
authored
Create setApplicationPermission.sh
1 parent 18415b0 commit 0b7498b

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

setApplicationPermission.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/sh
2+
####################################################################################################
3+
#
4+
# ABOUT
5+
#
6+
# Sets permissions on the application passed as Parameters 4 & 5.
7+
#
8+
####################################################################################################
9+
#
10+
# HISTORY
11+
#
12+
# Version 1.0, 12-Dec-2017, Dan K. Snelson
13+
#
14+
####################################################################################################
15+
16+
17+
# Variables
18+
loggedInUser=$(stat -f%Su /dev/console)
19+
applicationPath="$5"
20+
21+
22+
# If Parameter 5 is blank, exit ...
23+
if [ -z "${applicationPath}" ]; then
24+
25+
echo "Application Path not specified; exiting."
26+
27+
exit 1
28+
29+
fi
30+
31+
32+
33+
# Check for a specified owner (Parameter 4)
34+
# Defaults to currently logged-in user
35+
if [ "$4" != "" ] && [ "$owner" == "" ]; then
36+
owner="${4}"
37+
else
38+
echo "Parameter 4 is blank; using \"${loggedInUser}\" as the owner."
39+
owner="${loggedInUser}"
40+
fi
41+
42+
43+
44+
# Check if the specified application is installed ...
45+
testDirectory="/Applications/${applicationPath}"
46+
if [ -d "${testDirectory}" ] ; then
47+
48+
echo "/Applications/${applicationPath} located; proceeding ..."
49+
50+
echo "Setting permissions on /Applications/${applicationPath} ..."
51+
52+
/usr/sbin/chown ${owner} "/Applications/${applicationPath}"
53+
54+
echo "Set owner of \"/Applications/${applicationPath}\" to ${owner}."
55+
56+
exit 0
57+
58+
else
59+
60+
echo "/Applications/${applicationPath} NOT found; nothing to do."
61+
62+
exit 0
63+
64+
fi
65+
66+
exit 0

0 commit comments

Comments
 (0)