Skip to content

Commit

Permalink
Update computer_info_jamfhelper.sh
Browse files Browse the repository at this point in the history
code cleanup, more detailed use notes
  • Loading branch information
smashism authored Sep 5, 2018
1 parent 295fc5e commit 306bab8
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions self-service/computer_info_jamfhelper.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
#!/bin/sh

###
#
# adapted by github.com/smashism
# created 2015-03-12
# last updated 2016-11-07 - change from cocoaDialog to jamfHelper
# uses jamfHelper to display computer information to user
# helpful for troubleshooting if user can't find info themselves
#
# offered AS IS with no warranty or guarantee
#
# "If we hit that bullseye, the rest of the dominoes should fall like a house of cards. Checkmate."
# Name: computer_info_jamfhelper.sh
# Description: This script is designed for a Self Service policy that, when run,
# displays a jamfHelper popup with information collected from the
# Mac, including IP address, current user, computer name, OS version,
# MAC addresses, RAM, boot volume size, and usage information.
# Author: Emily KW
# Created: 2017-08-16
# Last Modified: 2018-09-05
#
###

IPAddresses=`ifconfig | grep " active" -B3 | grep "inet " | cut -d " " -f2`
CurrentUser=`who | grep "console" | awk '{print $1}'`
computername=`jamf getComputerName | cut -d ">" -f2 | cut -d "<" -f1`
OSVersion=`sw_vers | grep "ProductVersion" | awk '{print $2}'`
en1MACAddress=`ifconfig en1 | grep "ether" | cut -d" " -f2`
en0MACAddress=`ifconfig en0 | grep "ether" | cut -d" " -f2`
TotalRam=`system_profiler SPHardwareDataType | grep "Memory:" | cut -d":" -f2`
BootVolume=`system_profiler SPSoftwareDataType | grep "Boot Volume:" | cut -d":" -f2`
TotalBootDriveSize=`df -g / | tail -1 | awk '{print $2}'`
AvailBootDriveSize=`df -g / | tail -1 | awk '{print $4}'`
PercentUsed=`df -g / | tail -1 | awk '{print $5}'`
IPAddresses=$(ifconfig | grep " active" -B3 | grep "inet " | cut -d " " -f2)
currentUser=$( python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");' )
computerName=$(jamf getComputerName | cut -d ">" -f2 | cut -d "<" -f1)
OSVersion=$(sw_vers | grep "ProductVersion" | awk '{print $2}')
en1MACAddress=$(ifconfig en1 | grep "ether" | cut -d" " -f2)
en0MACAddress=$(ifconfig en0 | grep "ether" | cut -d" " -f2)
TotalRam=$(system_profiler SPHardwareDataType | grep "Memory:" | cut -d":" -f2)
BootVolume=$(system_profiler SPSoftwareDataType | grep "Boot Volume:" | cut -d":" -f2)
TotalBootDriveSize=$(df -g / | tail -1 | awk '{print $2}')
AvailBootDriveSize=$(df -g / | tail -1 | awk '{print $4}')
PercentUsed=$(df -g / | tail -1 | awk '{print $5}')

#jamfHelper variables

windowType="utility"
title=""
heading="Your Computer Info"
description="Computer IP addresses are:
heading="Hello $currentUser, here is the info for $computerName"
description="Computer IP addresses on this Mac:
$IPAddresses
OS version is $OSVersion
Wired MAC Address is $en0MACAddress
Expand All @@ -43,4 +44,7 @@ icon=/Applications/Utilities/System\ Information.app/Contents/Resources/ASP.icns

# jamfHelper command

"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" -windowType "$windowType" -windowPosition "$windowPosition" -title "$title" -heading "$heading" -description "$description" -icon "$icon" -iconSize "$iconSize" -button1 "Close" -defaultButton 1 -countdown "$timeout" -timeout "$timeout"
"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" -windowType "$windowType" -title "$title" -heading "$heading" -description "$description" -icon "$icon" -button1 "Close" -defaultButton 1 -countdown "60" -timeout "60"

# "If we hit that bullseye, the rest of the dominoes should fall like a house of cards. Checkmate."
exit 0

0 comments on commit 306bab8

Please sign in to comment.