-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |