36 lines
1.3 KiB
Bash
36 lines
1.3 KiB
Bash
set -x
|
|
JH="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
|
|
|
|
LOGGEDINUSER=$3
|
|
GROUPPREFIX=$(echo "$4" | awk '{print tolower($0)}')
|
|
GROUPSUFFIX=$(echo "$5" | awk '{print tolower($0)}')
|
|
MSGSUCCESS=$6
|
|
MSGERRORADD=$7
|
|
MSGERRORNOTINGROUP=$8
|
|
|
|
NOMADPLIST="/Users/${LOGGEDINUSER}/Library/Preferences/com.trusourcelabs.NoMAD.plist"
|
|
HOSTNAME=$(scutil --get ComputerName | awk '{print tolower($0)}')
|
|
PCGROUP="${GROUPPREFIX}${HOSTNAME}${GROUPSUFFIX}"
|
|
|
|
echo "Searching for ${PCGROUP}"
|
|
|
|
OLDIFS=$IFS
|
|
IFS=$'\n'
|
|
declare -a ADGROUPS=($(/usr/libexec/plistbuddy -c "print \"Groups:\"" "${NOMADPLIST}" | awk '{print tolower($0)}' | sed -e 1d -e '$d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'))
|
|
IFS=$OLDIFS
|
|
|
|
echo "User is Member of the following Groups: ${ADGROUPS}"
|
|
|
|
|
|
if [[ "${ADGROUPS[@]}" =~ "${PCGROUP}" ]]; then
|
|
echo "User is in the Group"
|
|
RES=$(/usr/sbin/dseditgroup -o edit -a "$LOGGEDINUSER" -t user admin)
|
|
if [[ "${RES}" != "0" ]]; then
|
|
"$JH" -startlaunchd -windowType utility -description "$MSGSUCCESS" -button1 "OK" -defaultButton 1 -lockHUD
|
|
else
|
|
"$JH" -startlaunchd -windowType utility -description "$MSGERRORADD" -button1 "OK" -defaultButton 1 -lockHUD
|
|
fi
|
|
else
|
|
echo "User is not in the Group"
|
|
"$JH" -startlaunchd -windowType utility -description "$MSGERRORNOTINGROUP" -button1 "OK" -defaultButton 1 -lockHUD
|
|
fi |