AutoPkg recipes for NexThink Collector
2023-5-29 06:47:23 Author: derflounder.wordpress.com(查看原文) 阅读量:17 收藏

Home > AutoPkg, Mac administration, macOS, Packaging > AutoPkg recipes for NexThink Collector

AutoPkg recipes for NexThink Collector

A while back, I posted about how to build an installer for NexThink Collector, but my preference is to not do manual packaging if I can avoid it. Instead, my preference is to have AutoPkg handle packaging tasks whenever possible for the following reasons:

  1. I can ensure that the packaging task is handled the same way every time.
  2. Once I have the correct recipe written for AutoPkg, all I should need to do for future versions of the app is to run the AutoPkg recipe, wait a few minutes and then collect a properly-built installer.

With that in mind, I decided to revisit building an installer for NexThink Collector but this time build AutoPkg recipes which handle the following:

  1. Creating an installer package for NexThink Collector
  2. Creating an uninstaller for NexThink Collector

I was able to do this, so for those interested, please see below the jump for more details.

I’ve built several AutoPkg recipes for NexThink Collector:

  • NexThinkCollector.download: Downloads the latest NexThink Collector installer disk image
  • NexThinkCollector.pkg: Builds an installer package for NexThink Collector
  • NexThinkCollectorUninstaller.pkg: Builds an uninstaller package for NexThink Collector 
  • NexThinkCollector.sign: Signs the installer package produced by the NexThinkCollector.pkg recipe
  • NexThinkCollectorUninstaller.sign: Signs the uninstaller package produced by the NexThinkCollectorUninstaller.pkg recipe

All the recipes are available at the following location:

https://github.com/autopkg/rtrouton-recipes/tree/master/NexThinkCollector

The one which needs the most configuration via an AutoPkg override is the following:

  • NexThinkCollector.pkg

This is because the details of installing and configuring NexThink are going to vary between shops, because different shops are going to configure different options for NexThink. The various Input variable options will provide hopefully all the possible configuration options needed.

To map between the Input variables and the NexThink command line installation configuration options, please see the table below:


AutoPkg Input Variable NexThink Command Line Installation Configuration Option What it defines Required
NTSERVERADDRESS address Fully-qualified domain name of your NexThink instance. Yes
NTUDPPORT port UDP port of your NexThink Instance No
NTTCPPORT tcp_port TCP port of your NexThink Instance Yes
NTPROXYPACADDRESS proxy_pac_address The URL of a PAC address for automatic configuration of proxy settings. No
NTPROXYADDRESS proxy_address The fully-qualified domain name of a proxy for manual configuration of proxy settings No
NTPROXYPORT proxy_port The port number where a proxy is listening for connections for manual configuration of proxy settings. No
NTREMOTEACTIONS ra_execution_policy Configuring the NexThink Collector remote actions settings No
NTENGAGE engage Configuring the NexThink Collector campaign settings No
NTASSIGNMENT use_assignment Configuring the NexThink Collector automatic collector assignment No
NTDATAOVERTCP data_over_tcp Configuring NexThink Collector to send all data over TCP No
NTSTRINGTAG string_tag Configure NexThink Collector label (max 2048 characters) to identify an individual or batch installation of Collectors No

Note: There are two NexThink command line installation configurations that are not directly covered:

  • rootca
  • key

For the rootca command line installation configuration option, all the documentation I’ve found in the context of installing the NexThink Collector software on macOS is the following:

Graphical installation documentation

  • Root CA: Leave this field empty.

Command-line installation

  • rootca: Not required.

Since the rootca option doesn’t seem to be required at all and there’s no documentation available on how to configure it for the NexThink Collector software on macOS, I’m leaving it out of the AutoPkg recipe.

For the key command line installation configuration option, this functionality is covered by the following required Input variables:


AutoPkg Input Variable What it defines Required
NTCUSTOMERKEYDATA Contents of the NexThink Customer Key file Yes
NTCUSTOMERKEYNAME Filename of the NexThink Customer Key file Yes

If both Input variables are filled in, then the postinstall script used by the installer package generated by this AutoPkg recipe will call the key command line installation configuration option and use it to configure the NexThink Collector software with the proper Customer Key information.

To see how this looks in a recipe override of the NexThinkCollector.pkg recipe, let’s create one with the following Input variables set:

  • NTSERVERADDRESS: server.nexthink.com
  • NTTCPPORT: 443
  • NTREMOTEACTIONS: disabled
  • NTENGAGE: disable
  • NTASSIGNMENT: enable
  • NTDATAOVERTCP: enable
  • NTCUSTOMERKEYNAME: nexthink-customer-key.txt
  • NTCUSTOMERKEYDATA: 


With those variables set, the AutoPkg recipe override should look similar to what’s shown below:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0">
<dict>
<key>Identifier</key>
<string>local.pkg.NexThinkCollector</string>
<key>Input</key>
<dict>
<key>DOWNLOAD_URL</key>
<string>https://download.nexthink.com/releases/latest/OSX_Collector/Nexthink_Collector.dmg</string>
<key>NAME</key>
<string>NexThink Collector</string>
<key>NTASSIGNMENT</key>
<string>enable</string>
<key>NTCUSTOMERKEYDATA</key>
<string>—–BEGIN CUSTOMER KEY—–MIIDhzCCAm+gAwIBAgIEIa+KoTANBgkqhkiG9w0BAQsFADBbMScwJQYDVQQDDB5SZWdlcnkgU2VsZi1TaWduZWQgQ2VydGlmaWNhdGUxIzAhBgNVBAoMGlJlZ2VyeSwgaHR0cHM6Ly9yZWdlcnkuY29tMQswCQYDVQQGEwJVQTAgFw0yMjEyMDIwMDAwMDBaGA8yMTIyMTIwMjIwMDIxMFowSTEVMBMGA1UEAwwMbG9jYWxob3N0LmlvMSMwIQYDVQQKDBpSZWdlcnksIGh0dHBzOi8vcmVnZXJ5LmNvbTELMAkGA1UEBhMCVUEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaKRW9KeX4wg/838FkxmzaBjqf1DeKD5GKEqhUKz0y78Wwnsv2zAXGM4UkdZJP9zHtC9/wFQT+lhclDlogxkU9lfMADV7nMdGL0GkJzwMQNS52dPNXDup7/d9yRkyjkV0Pf4t2fJF3igoNXFQuBvuArkNV6hfja2gOEczOSAaJ7L7qRnSahLjciJRaCuEPjwneh3krhOFT+djwuYJMIvBDEqs+gfp4OPDDBtVg2scUUGRmHsC+JAoK+JwqYwB9TNt+9hZtGfDqgZSHebXEfRTguhQpBj0mPTo76EahAbHbXJhV+efg3jt32pZ6qRl8ffrZAjefWEAnOMyXQ7fbL+bpAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBRNHRZG3IKNH0kTRaiVfq6N8Ovp5zAfBgNVHSMEGDAWgBRNHRZG3IKNH0kTRaiVfq6N8Ovp5zANBgkqhkiG9w0BAQsFAAOCAQEAhpbntg+nwhIKgRuUidu/wXn197Ah0Pd4CYYxG5dR9rg8nWObx4QO6ApIH91nUUQVuV6mSTFtfy4yNQzxaROgZP9hDNvhd78D/ewXxp6bN/Xkn+c7SWrs/b1vHb2Dr1sDP4F9SAOrCI6TdoYa8UNhPXXSTt8M/hGSB2oWOpT2FAb2IbdmdYhDaibcJwp+/Had1FLbeDZgdgYCFoZLjws/9E/pIXjSxBYAJLbaQZffrfO5jCe2KesE73iQatW2IPynsFifRGGoMHXVLOfsLA9c2KDGqDmnJ+PvsBSe9rIpSJYC4WjR5Mt8W88kQSj05b9NqCsXmmMDEbD8uVLyKvQihA==—–END CUSTOMER KEY—–</string>
<key>NTCUSTOMERKEYNAME</key>
<string>nexthink-customer-key.txt</string>
<key>NTDATAOVERTCP</key>
<string>enable</string>
<key>NTENGAGE</key>
<string>disable</string>
<key>NTPROXYADDRESS</key>
<string></string>
<key>NTPROXYPACADDRESS</key>
<string></string>
<key>NTPROXYPORT</key>
<string></string>
<key>NTREMOTEACTIONS</key>
<string>disabled</string>
<key>NTSERVERADDRESS</key>
<string>server.nexthink.com</string>
<key>NTSTRINGTAG</key>
<string></string>
<key>NTTCPPORT</key>
<string>443</string>
<key>NTUDPPORT</key>
<string></string>
<key>SOFTWARETITLE</key>
<string>Collector</string>
<key>VENDOR</key>
<string>NexThink</string>
</dict>
<key>ParentRecipe</key>
<string>com.github.rtrouton.pkg.NexThinkCollector</string>
<key>ParentRecipeTrustInfo</key>
<dict>
<key>non_core_processors</key>
<dict/>
<key>parent_recipes</key>
<dict>
<key>com.github.rtrouton.download.NexThinkCollector</key>
<dict>
<key>path</key>
<string>~/github/rtrouton-recipes/NexThinkCollector/NexThinkCollector.download.recipe</string>
<key>sha256_hash</key>
<string>025505c8c4527bb20515a603a423f323f8230cae5a80c716390aa303a95cb84c</string>
</dict>
<key>com.github.rtrouton.pkg.NexThinkCollector</key>
<dict>
<key>path</key>
<string>~/github/rtrouton-recipes/NexThinkCollector/NexThinkCollector.pkg.recipe</string>
<key>sha256_hash</key>
<string>df09ce476b30b366f8fc02a390ff8123b3d245bd3382cc409903f08b2f3cd252</string>
</dict>
</dict>
</dict>
</dict>
</plist>

Once configured, the NexThinkCollector.pkg AutoPkg recipe should work with the NexThinkCollector.download recipe to do the following:

  • Download the latest NexThink Collector installer disk image
  • Wrap the disk image and CustomerKey file inside a separate installer package.
  • Use a postinstall script to perform the following actions:
  1. Identify the location of the disk image stored inside the installer package.
  2. Mount the disk image
  3. Identify the location of the csi.app on the mounted disk image.
  4. Identify the location of the CustomerKey file stored inside the installer package.
  5. Use the csi app’s command line tool to configure and run the NexThink-provided installer package on the mounted disk image, to install the NexThink Collector software.
  6. Unmount the disk image.

The other .pkg AutoPkg recipe I wrote is NexThinkCollectorUninstaller.pkg and it is much simpler in terms of operation. It uses the same technique described in my earlier post on how to build a NexThink Collector uninstaller and should not need configuration of any Input variables. The NexThinkCollectorUninstaller.pkg recipe works with the NexThinkCollector.download recipe to do the following:

  • Download the latest NexThink Collector installer disk image
  • Wrap the disk image inside a separate installer package.
  • Use a postinstall script to perform the following actions:
  1. Identify the location of the disk image stored inside the installer package.
  2. Mount the disk image
  3. Use the uninstall script to uninstall the NexThink Collector software.
  4. Unmount the disk image.

The AutoPkg recipe override should look similar to what’s shown below:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0">
<dict>
<key>Identifier</key>
<string>local.pkg.NexThinkCollectorUninstaller</string>
<key>Input</key>
<dict>
<key>DOWNLOAD_URL</key>
<string>https://download.nexthink.com/releases/latest/OSX_Collector/Nexthink_Collector.dmg</string>
<key>NAME</key>
<string>NexThink Collector Uninstaller</string>
<key>SOFTWARETITLE</key>
<string>Collector</string>
<key>SOFTWARETITLE1</key>
<string>Collector</string>
<key>SOFTWARETITLE2</key>
<string>Uninstaller</string>
<key>VENDOR</key>
<string>NexThink</string>
</dict>
<key>ParentRecipe</key>
<string>com.github.rtrouton.pkg.NexThinkCollectorUninstaller</string>
<key>ParentRecipeTrustInfo</key>
<dict>
<key>non_core_processors</key>
<dict/>
<key>parent_recipes</key>
<dict>
<key>com.github.rtrouton.download.NexThinkCollector</key>
<dict>
<key>git_hash</key>
<string>a580ead04110ccc2b938da2373b55e6d85ac9d09</string>
<key>path</key>
<string>~/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes/NexThinkCollector/NexThinkCollector.download.recipe</string>
<key>sha256_hash</key>
<string>025505c8c4527bb20515a603a423f323f8230cae5a80c716390aa303a95cb84c</string>
</dict>
<key>com.github.rtrouton.pkg.NexThinkCollectorUninstaller</key>
<dict>
<key>git_hash</key>
<string>a580ead04110ccc2b938da2373b55e6d85ac9d09</string>
<key>path</key>
<string>~/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes/NexThinkCollector/NexThinkCollectorUninstaller.pkg.recipe</string>
<key>sha256_hash</key>
<string>0c614e578c594e2ec0de010d5e95ec791d3fae840d6da0df5c297247f754e522</string>
</dict>
</dict>
</dict>
</dict>
</plist>

文章来源: https://derflounder.wordpress.com/2023/05/28/autopkg-recipes-for-nexthink-collector/
如有侵权请联系:admin#unsafe.sh