Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Creating a NexThink uninstaller for deployment via Jamf Pro

$
0
0

As a follow-up to my previous post on building an installer for NexThink Collector which could be deployed via Jamf Pro, I also needed to build an uninstaller for this software. Fortunately, NexThink ships an uninstaller script on the same disk image that it uses to ship its installer.

Screenshot 2022 12 03 at 3 31 46 PM

NexThink’s install documentation for the macOS version of the Collector software assumes that a human is doing the following to run the uninstall process:

A. Mounting the disk image
B. Opening the Terminal application
C. Using the uninstaller script to run the uninstallation process.

Screenshot 2022 12 03 at 3 47 10 PM

In my case, I decided to do the following to deploy the uninstaller via Jamf Pro:

  1. Wrap the disk image inside a separate installer package.
  2. Use a postinstall script to perform the following actions:

A. Identify the location of the disk image stored inside the installer package.
B. Mount the disk image
C. Use the uninstall script to uninstall the NexThink Collector software.
D. Unmount the disk image.

For more details, please see below the jump.

Pre-requisites:

  • Packages
  • Vendor-provided NexThink disk image with the NexThink Collector uninstaller script

 

Building the NexThink Collector uninstaller

1. Set up a new Packages project and select Raw Package.

Screenshot 2022 12 04 at 3 53 01 PM

 

2. In this case, I’m naming the project NexThink Collector Uninstaller 22.9.1.14.

Screenshot 2022 12 04 at 3 53 24 PM

 

3. Once the Packages project opens, click on the Project tab. You’ll want to make sure that the your information is correctly set here (if you don’t know what to put in, check the Help menu for the Packages User Guide. The information you need is in Chapter 4 – Configuring a project.)

Screenshot 2022 12 04 at 3 53 48 PM

In this example, I’m not changing any of the options from what is set by default.

 

4. Next, click on the Settings tab. In the case of my project, I want to install with root privileges and not require a logout, restart or shutdown.

To accomplish this, I’m choosing the following options in the Settings section:

In the Tag section:

  • Identifier: set as appropriate (for my uninstaller, I’m using com.nexthink.pkg.collector.uninstaller.)
  • Version: set as appropriate (for my uninstaller, I’m using 22.9.1.14. )

In the Post-installation Behavior section:

On Success: should be set to Do Nothing.

In the Options section:

  • Require admin password for installation should be checked
  • Relocatable should be unchecked
  • Overwrite directory permissions should be unchecked
  • Follow symbolic links should be unchecked

Screenshot 2022 12 04 at 3 54 48 PM

 

5. Select the Payload tab. Nothing here should be changed from the defaults.

Screenshot 2022 12 04 at 3 54 58 PM

 

6. Select the Scripts tab.

Under the Additional Resources section, add the following file:

  • The NexThink disk image

Screenshot 2022 12 04 at 3 56 04 PM

Screenshot 2022 12 04 at 3 56 08 PM

 

The last part is telling the NexThink uninstall script to run. For this, you’ll need a postinstall script.

Here’s the postinstall script being used for this example:


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


#!/bin/bash
# Description: Script to uninstall NexThink Collector.
ERROR=0
# File Paths
if [[ -f "$(/usr/bin/find $(dirname $0) -maxdepth 1 \( -iname \*\.dmg \))" ]]; then
dmgFile="$(/usr/bin/find $(dirname $0) -maxdepth 1 \( -iname \*\.dmg \))"
fi
dmgMount="$(/usr/bin/mktemp -d /tmp/NexThink_Collector_Uninstaller.XXXX)"
# Remove the trailing slash from the dmgMount variable if needed.
dmgMount=${dmgMount%%/}
# Mount the DMG
/usr/bin/hdiutil attach "$dmgFile" -mountpoint "$dmgMount" -nobrowse -noverify -noautoopen
# Uninstall the NexThink Collector software
"$dmgMount"/uninstaller
# Unmount the DMG
hdiutil detach $dmgMount -force
exit $ERROR
view raw

postinstall

hosted with ❤ by GitHub

If not already selected, select the postinstall script and add it to the project.

Screenshot 2022 12 04 at 3 56 20 PM

Screenshot 2022 12 04 at 3 56 24 PM

 

7. Build the package. (If you don’t know to build, check the Help menu for the Packages User Guide. The information you need is in Chapter 3 – Creating a raw package project and Chapter 10 – Building a project.)

Testing the installer

Once the package has been built, test it by installing it on a test machine which has the following:

  • The NexThink Collector software installed

The end result should be that the NexThink Collector software is removed from the Mac.


Viewing all articles
Browse latest Browse all 764

Trending Articles