Hello all, hope this can help some of you out if not give you a starting point for your own version reporting script.
Often I am walking from the cafeteria and get stopped or I'm making my way through a cubicle farm to one customer and get pulled aside by another. Either way it almost always ends up being a conversation about software version this or update that. Being that my brain isn't a functioning Casper database (yet) I either have to open the app(s) in question to view it's version number or if it's a plugin that is yelling at them to update I simply rely on good'ol Firefox "about:plugins" url. I decided to write this little gem, package it up and deploy it as /usr/sbin/versions, so a quick:
COMMAND + spacebar
to search for and open Terminal and running "versions" will give me a quick overview of what I need to know.
Does anyone disagree with putting it in /usr/sbin path?
Code below
Edit: Rewrote almost the entire script. Hopefully someone will find it useful. I (or a user) can run this from Self Service when it's not convenient to access the JSS webmin.
#!/bin/sh
# Name : reportSystemInfo.sh
# Author : Snickasaurus
# Date : 20160117
# Purpose : Output a generated system report then open with default browser.
# Sauce : https://github.com/Snickasaurus/SystemReportToHTML/blob/master/runSystemReport.sh
# Variables
theTitle="System Report for host: [ $HOSTNAME ]"
theNow=$(date "+%Y/%m/%d at %r %Z")
theStamp="<h2>Created on $theNow by $USER</h2>"
# Begin script
# Remove previously ran report if found.
if [ -e /private/tmp/systemReport.html ]
then
rm /private/tmp/systemReport.html
fi
# Functions
function system_info
{
echo "<h3>System release info</h3>"
echo "<pre>"
sw_vers
echo "</pre>"
}
function show_uptime
{
echo "<h3>System uptime</h3>"
echo "<pre>"
uptime
echo "</pre>"
}
function drive_space
{
echo "<h3>Filesystem space</h3>"
echo "<pre>"
df -h
echo "</pre>"
}
function jss_check
{
echo "<h3>Jss Availability</h3>"
echo "<pre>"
jamf checkJSSConnection
echo "</pre>"
}
function user_list
{
echo "<h3>User List</h3>"
echo "<pre>"
userList=$(dscl /Local/Default -list /Users UniqueID | awk '$2 >= 500 { print $1; }')
for i in $userList
do
echo "$(id -un $i) > $(id -F $i)"
done
echo "</pre>"
}
function net_names
{
echo "<h3>Host Names</h3>"
echo "<pre>"
echo "ComputerName : $(scutil --get ComputerName)"
echo "HostName : $(scutil --get HostName)"
echo "LocalHostName : $(scutil --get LocalHostName)"
echo "NetBIOSName : $(defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName)"
echo "</pre>"
}
function sw_update
{
theAUTODOWNLOAD=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload)
if [ "$theAUTODOWNLOAD" == "1" ]
then
theAUTOD="True"
else
theAUTOD="False"
fi
theACECheck=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled)
if [ "$theACECheck" == "1" ]
then
theACE="True"
else
theACE="False"
fi
theCUICheck=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall)
if [ "$theCUICheck" == "1" ]
then
theCUI="True"
else
theCUI="False"
fi
theSECDATACheck=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall)
if [ "$theSECDATACheck" == "1" ]
then
theSECD="True"
else
theSECD="False"
fi
theLASTSUCCESS=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist LastSuccessfulDate | awk '{print $1,$2}')
echo "<h3>Software Update Settings</h3>"
echo "<pre>"
echo "Automatic download updates? = $theAUTOD"
echo "Automatic update check enabled? = $theACE"
echo "Automatic Critical Update install? = $theCUI"
echo "Automatic Security & Data install? = $theSECD"
echo "Last Successful Update = $theLASTSUCCESS"
echo "</pre>"
}
function app_data
{
if [ -f /Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app/Contents/Info.plist ]
then
theAAP=$(defaults read /Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app/Contents/Info.plist CFBundleShortVersionString)
else
theAAP="Missing"
fi
if [ -e /Applications/Safari.app ]
then
theFirefox=$(defaults read /Applications/Safari.app/Contents/Info.plist CFBundleShortVersionString)
else
theSafari="Missing"
fi
if [ -e /Applications/Google Chrome.app ]
then
theChrome=$(defaults read /Applications/Google Chrome.app/Contents/Info.plist CFBundleShortVersionString)
else
theChrome="Missing"
fi
if [ -e /Applications/Firefox.app ]
then
theFirefox=$(defaults read /Applications/Firefox.app/Contents/Info.plist CFBundleShortVersionString)
else
theFirefox="Missing"
fi
if [ -f /Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist ]
then
theFlash=$(defaults read /Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info CFBundleShortVersionString)
else
theFlash="Missing"
fi
if [ -f /Library/Application Support/Oracle/Java/Info.plist ]
then
theOracle=$(defaults read /Library/Application Support/Oracle/Java/Info.plist CFBundleShortVersionString)
else
theOracle="Missing"
fi
if [ -f /Applications/Microsoft Office 2011/Office/MicrosoftComponentPlugin.framework/Versions/14/Resources/Info.plist ]
then
theOffice11=$(defaults read /Applications/Microsoft Office 2011/Office/MicrosoftComponentPlugin.framework/Versions/14/Resources/Info CFBundleShortVersionString)
else
theOffice11="Missing"
fi
if [ -f /Applications/Sophos Anti-Virus.app/Contents/Info.plist ]
then
theSophos=$(/usr/libexec/PlistBuddy -c "print :ProductVersion:" /Library/Sophos Anti-Virus/product-info.plist)
else
theSophos="Missing"
fi
if [ -f /Applications/VMware Fusion.app/Contents/Info.plist ]
then
theVMWare=$(defaults read /Applications/VMware Fusion.app/Contents/Info.plist CFBundleShortVersionString)
else
theVMWare="Missing"
fi
if [ -f /Library/Internet Plug-Ins/Silverlight.plugin/Contents/Info.plist ]
then
theSilver=$(defaults read /Library/Internet Plug-Ins/Silverlight.plugin/Contents/Info.plist CFBundleShortVersionString)
else
theSilver="Missing"
fi
echo "<h3>Application Data</h3>"
echo "<pre>"
echo "Chrome = $theChrome"
echo "Firefox = $theFirefox"
echo "Safari = $theSafari"
echo "- - - - - - - - - - - - - - - - - - -"
echo "Flash = $theFlash"
echo "JavaO = $theOracle"
echo "Silverlight = $theSilver"
echo "- - - - - - - - - - - - - - - - - - -"
echo "Acrobat Pro = $theAAP"
echo "Office 2011 = $theOffice11"
echo "Sophos AV = $theSophos"
echo "VMware Fusion = $theVMWare"
echo "</pre>"
}
# Begin script
cat > /private/tmp/systemReport.html <<- EOF
<html>
<head>
<style>
body {background-color: black; color: white;}
h1 {text-align: center; color: red;}
h2 {text-align: center; color: green;}
h3 {color: blue;}
p {text-align: center;}
</style>
<title>$theTitle</title>
</head>
<body>
<h1>$theTitle</h1>
<p>$theStamp</p>
$(system_info)
$(show_uptime)
$(app_data)
$(drive_space)
$(jss_check)
$(user_list)
$(net_names)
$(sw_update)
</body>
</html>
EOF
open /private/tmp/systemReport.html
exit 0