TweetFollow Us on Twitter

Extending the Casper Suite with Dummy Packages

Volume Number: 25
Issue Number: 09
Column Tag: system administration

Extending the Casper Suite with Dummy Packages

Adding custom management hooks

by Miles A. Leacy IV

Introduction

The Casper Suite by JAMF Software provides a robust management framework for automating system administration tasks. Through Smart Computer Groups, management policies can be assigned to machines that fit certain criteria such as computer name, IP address range and installed software packages, to name a few. In order to meet the challenges and demands of administering a set of Macs, system administrators will, on occasion, find that they would like to assign policies to or create Smart Computer Groups based on criteria that are not built in to the Casper Suite.

The Casper Suite's abilities to run shell scripts and track installed software packages on client Macs allow us to functionally extend our ability to create Smart Computer Groups to include nearly any criteria the system administrator requires. By using a shell script, we can check for desired criteria, and if found, cause a "dummy" package to be installed. We can then use the receipt from this package as criteria for a Smart Computer Group.

For the example in this article, we will assume that we would like to put all Macs that have pending firmware updates into a Smart Computer Group called Firmware Updates Available. A system administrator could run a report that lists the members of this Smart Computer Group. This report can serve as a list of Macs that a technician will need to visit to perform the updates since firmware updates are one of the few administrative items that cannot be automated.

Components

There are five components to this technique; a script to check for desired criteria and trigger a policy to install the dummy package when the criteria are met, a policy to run the script, a custom-triggered policy to install the dummy package, the dummy package itself, and a Smart Computer Group consisting of computers with a receipt for the dummy package.

Script

The first item we need is the script. This script will check for the desired criteria, in this case, whether a Mac has available firmware updates. If the criteria are found, the script will trigger a policy using the custom trigger firmwareUpdatesAvailable. If the criteria are found, the script will delete the receipt for a package called firmwareUpdatesAvailable.pkg. This structure will allow the script to act as a toggle, adding or removing the package receipt depending on whether the designated criteria are found. This script uses the jamf command line tool present on all Macs managed by the Casper Suite. For our example, we will use the script below:

#!/bin/bash
##### HEADER BEGINS #####
# filename: scr_sys_findFirmwareUpdates.bash
#
# This script is provided "as is".
# The author offers no warranty or guarantee of any kind.
# Use of this script is at your own risk.
# The author takes no responsibility for loss of use,
# loss of data, or any other negative effects.
#
# Test thoroughly in a lab environment
# before use on production systems.
#
# This script checks for available firmware updates. If found,
# a policy to install a dummy package is triggered.
#
##### HEADER ENDS #####
# store the number of available firmware updates
# in the variable $fwupdate
fwupdate=`softwareupdate -l | grep -c Firmware`
# if there are firmware updates available,
# issue the custom trigger "firmwareUpdatesAvailable"
#
# if no firmware updates are available,
# delete the receipt for firmwareUpdatesAvailable.pkg
if [ $fwupdate -gt 0 ]
then
jamf policy -trigger firmwareUpdatesAvailable
else
rm -R /Library/Receipts/firmwareUpdatesAvailable.pkg
rm –R /Library/Application\ Support/JAMF/Receipts/firmwareUpdatesAvailable.pkg
fi
exit 0

Once you have saved your script, set its permissions to allow execution by typing the following command in Terminal.app (adding the executable permission to all):

chmod a+x /path/to/scr_sys_findFirmwareUpdates.bash

You will then need to add the script to your JSS using the Casper Admin application. If you are unfamiliar with this process you may review the Casper Suite Documentation (referenced at the end of this article).

This script is specific to our example, but by altering the if statement and supplying any supporting variables, you can check for any criteria that you can find with a script. When writing your own scripts for dummy packages, be sure that your trigger matches the custom trigger used in the policy that installs your dummy package (discussed below), and that the rm commands matches the receipts for your dummy package. Receipts for Apple .pkg format packages are stored at /Library/Receipts/packageName.pkg. The Casper Suite stores receipts at /Library/Application Support/JAMF/Receipts/packageName.pkg. and /Library/ApplicationSupport/JAMF/Receipts/packageName.dmg for Apple .pkg format packages and .dmg format packages built by Composer, the packaging application component of the Casper Suite, respectively.

Criteria-Checking Policy

This policy should run on all Macs that you would like to check for the desired criteria and will run the script we discussed above as a "before" script. If you're familiar with adding scripts to a policy in the Casper Suite, you may want to skip to the next section.

Log in to you're the web interface on your JAMF Software Server (JSS), and create a new policy by clicking the Management tab, then Policies, and Create New Policy… In the policy editor's General tab, give your policy an appropriate name, and a category if you wish. Categories are created in the Casper Admin application or through the Casper Admin link in the JSS' Admin tab and can be invaluable for keeping your list of policies organized and readable. For details and instructions, see the Casper Suite Documentation referenced at the end of this article. The criteria-checking policy's Triggered By: event will depend on your needs, but for this example, we'll choose startup. Selecting Ongoing in the Execution Frequency: field will ensure that this policy runs each time the target Macs are booted. Figure 1 illustrates how the General tab should look when we're done configuring it.


Figure 1. Criteria-Checking Policy General Tab

Once the General tab is configured, we'll click the Scope tab. Don't click the Save Policy button yet. Doing so will exit the policy editor. The changes we make in each tab will be saved until we exit the policy editor allowing us to navigate through the tabs freely until we're certain that the policy is configured as we need it to be. In the Scope tab, we'll select the radio button next to Assign to All Computers. This will ensure that this policy will be run on all Macs that are managed by the Casper Suite.

Next, we'll select the Scripts tab in the policy editor. In the Scripts tab, we will add our script to the policy. The script we're using in this example is called scr_sys_findFirmwareUpdates.bash. Click the Add Script link, then choose Run Before under the scr_sys_findFirmwareUpdates.bash entry and finally, click the Add Script(s) button.


Figure 2. Criteria-Checking Policy Scripts Tab

The last item we'll add to this policy is the Update Inventory action. Select the Advanced tab in the policy editor, then click the checkbox next to Update Inventory, then click the Save Policy button. Updating inventory is very important for our purposes, because until inventory data is updated, Macs with the desired criteria will fail to appear in the proper Smart Computer Group. Once you have saved the policy, you should see it listed along with any other policies already configured on your JSS. If you click the Show Plan link next to the new policy, the plan should look like Figure 3.


Figure 3. Criteria-Checking Policy Plan

The Dummy Package

The dummy package is the core of this technique. It is simply a package that does not contain any software to be installed. You can use Composer, the packaging tool provided with the Casper Suite, or your favorite package editing application to create this package. The only item of importance in this package is its name. You should choose a name that is descriptive of what you are using the package to identify; in this case, we will use the name firmwareUpdatesAvailable.pkg. Once created, the package is added to the JSS using Casper Admin.

If you would like to be able to use the indexing feature in Casper Admin with your dummy package in order to allow the Casper Suite to uninstall the dummy package, you will need to have at least one file in your package. /Library/DummyPackages/packageName.txt is suggested, but any convention that makes sense to you will do.

If you are unfamiliar with package creation, adding packages to the JSS or package indexing, you may review the Casper Suite Documentation (referenced at the end of this article).

Custom-Triggered Policy

In the script discussed above, we used the command jamf policy -trigger firmwareUpdatesAvailable. This tells the jamf command line tool on the client Mac to consult the JSS and execute any policies that are scoped to this Mac and triggered by the custom trigger firmwareUpdatesAvailable. Now we'll create the policy that is triggered by this custom trigger and will install the dummy package. If you are familiar with creating custom-triggered policies, you may want to skip this section.

As before, we'll create a new policy. Click Management, then Polices, then Create New Policy… In the General tab, we'll give the policy a descriptive name, and select other (Manually specify the run at action in this field) --> from the Triggered By: menu. In the text field next to the Triggered By: menu, type the custom trigger (firmwareUpdatesAvailable, for our example).


Figure 4. Custom-Triggered Policy General Tab

In the Scope tab, we'll select Assign to All Computers again.

Next, we'll select the Packages tab, and click the Add Package link. This will bring us to the package selection page seen in Figure 5. In the Action menu next to firmwareUpdatesAvailable.pkg, select Install then click the Add Package(s) button.


Figure 5. Custom-Triggered Policy Package Selection

Once again, select the Advanced tab, click the Update Inventory checkbox, then click the Save Policy button. When you're finished, the policy plan should look like the plan shown in Figure 6.


Figure 6. Custom-Triggered Policy Plan

Smart Computer Group

Once the two policies above have run, the package firmwareUpdatesAvailable.pkg will be installed on any managed Macs with available firmware updates. We can now create a Smart Computer Group containing all Macs with a receipt for this package. If you are familiar with creating Smart Computer Groups with the Casper Suite, you may skip this section.

To create our Smart Computer Group, we'll log in to our JSS, select the Management tab, click the Smart Computer Groups link, and then click the New Smart Computer Group button. This takes us to the Edit Smart Computer Group interface. Here, we will type Firmware Updates Available in the Computer Group Name: field. Then, we click the + button next to Receipts Info. This opens a pop-up window, where we will click Packages Installed By Casper. This adds a line under the Receipts Info header called Packages Installed By Casper. We'll leave the drop down menu set to has and click the ellipsis (…) next to the text field. This will present us with a pop up window listing all of the packages that the Casper Suite is currently tracking. We'll click firmwareUpdatesAvailable.pkg in this list, which will populate the text field and return us to the Edit Smart Computer Group interface. At this point, our interface should look like Figure 7. Click the Save Group button to save the Smart Computer Group.


Figure 7. Edit Smart Computer Group

Once you save the Smart Computer Group, you are taken to a list of all Smart Computer Groups in your JSS. If you click the View Members button next to the Firmware Updates Available group, you will be shown a list of all Macs in your JSS that have a receipt for the firmwareUpdatesAvailable.pkg package. This is the same view you would see if you ran an advanced search in your JSS' Inventory tab using the Firmware Updates Available computer group as your search criteria.


Figure 8. Firmware Updates Available
Smart Computer Group Members

Conclusion

By using dummy packages, you can extend the management capabilities of the Casper Suite to allow you to group computers based on criteria that are not built in to the software. The dummy package technique has been used to track such items as Active Directory group membership, battery cycles & charge capacity, computers with a Windows installation and many more. Any information you can test for in a script can be used as criteria for a dummy package. This technique is limited only by your imagination and your scripting skills.

For Further Reference

As mentioned throughout this article, you can learn more about the various functions of the Casper Suite from the Casper Suite 6.0 Documentation available at the link below.

http://jamfsoftware.com/libraries/pdf/support/Casper_Suite_Documentation.pdf


Miles A. Leacy IV has been working with Macs for over twenty years. In that time, he has worked with small, medium & enterprise businesses, K-12 & higher education, and governmental organizations. He dabbles in creative pursuits such as graphic design, video production, video editing and web design. Miles maintains a blog for Mac sysadmins at http://themacadmin.com. You can reach him at miles.leacy@themacadmin.com.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »

Price Scanner via MacPrices.net

New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more
Updated Apple MacBook Price Trackers
Our Apple award-winning MacBook Price Trackers are continually updated with the latest information on prices, bundles, and availability for 16″ and 14″ MacBook Pros along with 13″ and 15″ MacBook... Read more
Every model of Apple’s 13-inch M3 MacBook Air...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices are the lowest currently available for new 13″ M3 MacBook Airs among... Read more
Sunday Sale: Apple iPad Magic Keyboards for 1...
Walmart has Apple Magic Keyboards for 12.9″ iPad Pros, in Black, on sale for $150 off MSRP on their online store. Sale price for online orders only, in-store price may vary. Order online and choose... Read more
Apple Watch Ultra 2 now available at Apple fo...
Apple has, for the first time, begun offering Certified Refurbished Apple Watch Ultra 2 models in their online store for $679, or $120 off MSRP. Each Watch includes Apple’s standard one-year warranty... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
IT Systems Engineer ( *Apple* Platforms) - S...
IT Systems Engineer ( Apple Platforms) at SpaceX Hawthorne, CA SpaceX was founded under the belief that a future where humanity is out exploring the stars is Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.