Skip to content

Commit

Permalink
Added new EA - report JC license details
Browse files Browse the repository at this point in the history
  • Loading branch information
txhaflaire committed Apr 8, 2022
1 parent ec2ec46 commit 74d4e38
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions additional_extension_attributes/Read_Jamf_Connect_License_Info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/zsh

####################################
# Checks for an existing Jamf Connect license installed on a Mac
# and reports license details similar to Jamf Connects' About window.

# MIT License
#
# Copyright (c) 2022 Jamf Software
####################################

# Try to read the com.jamf.connect.login.plist file for license information

licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect.login LicenseFile 2> /dev/null | /usr/bin/base64 --decode )

# If the file doesn't exist, try to read the com.jamf.connect.plist file for license information

if [ "$licenseInfo" = "" ]; then
licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect LicenseFile 2> /dev/null | /usr/bin/base64 --decode )
fi

# Return results to Jamf Pro

if [ "$licenseInfo" = "" ]; then

# No license file exists for Jamf Connect

echo "<result>No license</result>"

else

# read licensing information from found license file

licensedTo=$( /usr/bin/xpath -e '//key[text()="Name"]/following-sibling::string[1]/text()' 2> /dev/null ) <<< "$licenseInfo"
licenseKey=$( /usr/bin/xpath -e '//key[text()="LicenseKey"]/following-sibling::string[1]/text()' 2> /dev/null ) <<< "$licenseInfo"
dateIssued=$( /usr/bin/xpath -e '//key[text()="DateIssued"]/following-sibling::string[1]/text()' 2> /dev/null | /usr/bin/awk '{ print $1 }' ) <<< "$licenseInfo"
ExpiresOn=$( /usr/bin/xpath -e '//key[text()="ExpirationDate"]/following-sibling::string[1]/text()' 2> /dev/null | /usr/bin/awk '{ print $1 }' ) <<< "$licenseInfo"
numberOfSeats=$( /usr/bin/xpath -e '//key[text()="NumberOfClients"]/following-sibling::integer[1]/text()' 2> /dev/null ) <<< "$licenseInfo"

# Return license information to Jamf Pro

echo "<result>Licensed to: $licensedTo
License Key: $licenseKey
Date Issued: $dateIssued
Expires On: $ExpiresOn
Number of Seats: $numberOfSeats</result>"

fi

exit 0

0 comments on commit 74d4e38

Please sign in to comment.