forked from jamf/jamfconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new EA - report JC license details
- Loading branch information
1 parent
ec2ec46
commit 74d4e38
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
additional_extension_attributes/Read_Jamf_Connect_License_Info.sh
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 |
---|---|---|
@@ -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 |