Skip to content

Commit

Permalink
Updated script
Browse files Browse the repository at this point in the history
  • Loading branch information
golbiga committed Nov 7, 2014
1 parent f21cb3f commit cbc7a0e
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions update_enduser_jamf/update_enduser_jamf.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
#!/bin/bash
# This script checks who is logged into the machine and if they are an AD user
# If the user is in AD, a recon will run and update the endUsername
# This script checks who is logged into the machine and updates username in JSS.

# Who is logged in and what type of account is it
currentuser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
accounttype=`dscl . -read /Users/$currentuser | grep UniqueID | cut -c 11-`
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

if [[ "$currentuser" = root ]];
then
echo "No one is logged in, exiting."
if [ $loggedInUser = "root" ]; then
echo "No one is logged in"
exit 1
else
if (( "$accounttype" < 1000 )); then
echo "This account is not in AD, exiting."
exit 1
else
echo "This account is in AD, lets run jamf recon."
/usr/sbin/jamf recon -endUsername $currentuser
fi
echo "Running recon for $loggedInUser `date`..."
# Run recon, submitting the users username which as of 8.61+ can then perform an LDAP lookup
sudo jamf recon -endUsername $loggedInUser
echo "Finished running recon for $loggedInUser `date`..."
fi
exit 0
exit 0

0 comments on commit cbc7a0e

Please sign in to comment.