Skip to content

Instantly share code, notes, and snippets.

@rderewianko rderewianko/GetCarbonBlack.sh Secret
Last active Mar 30, 2017

Embed
What would you like to do?
Get Carbon Black from the web
#!/bin/bash
###################################################################################
## Pull a fresh copy of Carbon Black via the API
## “Valentine’s Day’s coming? Aw crap! I forgot to get a girlfriend again!”
## Created: December, 2016
## Last Edit: March 30, 2017
## Created by Ross Derewianko
###################################################################################
### This should be formed in the format https://domain.carbonblack.com (no trailing slash)
if [ "$4" != "" ] && [ "$CBDomain" == "" ]; then
CBDomain=$4
fi
### This can be found by going to your CarbonBlack/RedCanary domain & then going to your profile (on the right)
if [ "$5" != "" ] && [ "$API" == "" ]; then
API=$5
fi
### To find this Go to -> Administration -> Sensors -> Select group-> Look at the URL for the number after #hosts/
if [ "$6" != "" ] && [ "$group" == "" ]; then
group=$6
else
group="1"
fi
zip_path="/private/tmp/CBsensor.zip"
#Download the CB sensor
curl -X "GET" "$CBDomain/api/v1/group/$group/installer/osx" -H "X-Auth-Token: $API" --output "$zip_path"
#Check to see if it downloaded, unzip it and install it.
if [[ -f "$zip_path" ]]; then
echo "file exists!"
#unzip the file
/usr/bin/unzip $zip_path -d /private/tmp/CBsensor
echo "lets install CB"
#installing CB -- Use to be with the Jamf Agent, but @owen.pragel started searching for his knife so it was changed.
installer -pkg /private/tmp/CBsensor/CarbonBlackClientSetup.pkg -target /
#Borrowed from 74bit's scripts
if [ $? == 0 ]; then
echo "Installed."
else
echo "Error Exit Code: $?"
exit 1
fi
# Delete CB Temp files
/bin/rm '/private/tmp/CBsensor.zip'
/bin/rm -rf /private/tmp/CBsensor/
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.