Skip to content

Instantly share code, notes, and snippets.

@rtrouton
Last active December 20, 2022 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrouton/7bfa165734b3635da9ba01e19ecc1aa4 to your computer and use it in GitHub Desktop.
Save rtrouton/7bfa165734b3635da9ba01e19ecc1aa4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Description: Script to install the NexThink Collector agent using the csi.app's command-line
# options to install and register the NextThink agent using your organization's Customer Key.
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.XXXX)"
csiAppPath="$dmgMount/csi.app/Contents/MacOS/"
# Remove the trailing slash from the csiAppPath variable if needed.
csiAppPath=${csiAppPath%%/}
#installer variables
udpport="999"
tcpport="443"
tcpdata="enable"
assignment="enable"
tag_value="0"
nexthink_address="nexthink.server.goes.here"
customerKey="$(dirname $0)/CustomerKeys/*.txt"
# Mount the DMG
/usr/bin/hdiutil attach "$dmgFile" -mountpoint "$dmgMount" -nobrowse -noverify -noautoopen
# Install the Nextthink Collector software
# Define the parameters for csi.app for installing the Collector from the command line interface
"$csiAppPath"/csi -address "$nexthink_address" -port "$udpport" -tcp_port "$tcpport" -key "$customerKey" -data_over_tcp "$tcpdata" -use_assignment "$assignment" -tag "$tag_value"
#Disable/Enable Coordinator Service
launchctl bootout system /Library/LaunchDaemons/com.nexthink.collector.nxtcoordinator.plist
launchctl bootstrap system /Library/LaunchDaemons/com.nexthink.collector.nxtcoordinator.plist
# Unmount the DMG
hdiutil detach $dmgMount -force
exit $ERROR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment