/
promoteUser.sh
34 lines (30 loc) · 1.07 KB
/
promoteUser.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
#!/bin/zsh
emulate -LR zsh # Reset zsh options
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Simple Zsh tempadmin v0.1
#
# Catalina compatible script for Jamf Self Service to grant standard
# users temporary admin rights.
#
# Modified by soundsnw, original code by Armin Briegel
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
# If no current user is logged in, exit quietly
if [[ -z "$currentUser" ]]; then
echo "No user logged in, exiting"
exit 0
fi
# Check if the current user already in the admin group
if dseditgroup -o checkmember -m "$currentUser" admin; then
echo "$currentUser"" is already in the admin group"
else
# Create timestamp file
echo "Creating timestamp"
touch "/usr/local/tatime"
chmod 600 "/usr/local/tatime"
# Run Jamf recon to activate the demote script
echo "Running recon"
( /usr/local/jamf/bin/jamf recon ) & disown
# Add the user to the admin group
echo "Adding ""$currentUser"" to the admin group"
dseditgroup -o edit -a "$currentUser" -t user admin
fi