Hi everyone! I am new to this scripting game and I was wondering if I can garner some knowledge on using the script function in composer to install a series of programs, all condensed in one convenient PKG file. Basically, I have everything working EXCEPT I can't get our anti-virus (Cylance) to install WHILE inserting the license token into the program using the script function.
TLDR: I am trying to run a script using composer to install Cylance (and other apps) with the license key so it doesn't prompt the user, but can't get it to install, let alone have it apply the license key. NOTE: this is not being pushed by jamfpro (I have that working successfully), rather I want to create a new pkg with the Cylance license key embedded so the user isn't prompted.
Currently, I am using the postflight script to install VMware Horizon Client (I found this script somewhere else on the forums but can't seem to find it again) and it works great.
#!/bin/shpostflight
Not supported for flat packages.
pathToScript=$0 pathToPackage=$1 targetLocation=$2 targetVolume=$3 VendorDMG="/private/var/tmp/VMware-Horizon-Client-5.0.0-12557381.dmg"###########################################
Check for the presence of the Vendor .dmg file
if [ -e "$VendorDMG" ] then # Mount the vendor .dmg file echo "Mounting $VendorDMG" hdiutil attach "$VendorDMG" -nobrowse sleep 3 else echo "Vendor .dmg file not found, look for $VendorDMG" echo "Exiting script, please verify name and location of .dmg" exit 1 #Stop HERE# fi#######################################
If present, Remove the earlier copies of the VMware Horizon Client from /Applications
Start a running count of old apps we find
#######################################
OldCopy=0Look for older client name version
if [ -e "/Applications/VMware View Client.app" ] then let "OldCopy=OldCopy+1" echo "Found VMware View, now removing" rm -Rf "/Applications/VMware View Client.app" fiLook for not quite as old client name version
if [ -e "/Applications/VMware Horizon View Client.app" ] then let "OldCopy=OldCopy+1" echo "Found VMware Horizon View, now removing" rm -Rf "/Applications/VMware Horizon View Client.app" fiLook for current name copy of Application
if [ -e "/Applications/VMware Horizon Client.app" ] then let "OldCopy=OldCopy+1" echo "Removing original App" sudo rm -Rf "/Applications/VMware Horizon Client.app" sleep 3 fiReport what was found when looking for older copies
if [ Oldcopy != 0 ] then # Report older name versions found echo "Found $OldCopy Older .app copies" else # Report no older copies found echo "No older named .apps found" fi########################################
Copy the .app from the mounted vendor .dmg volume
If App name changes, the next line needs modified
########################################
cp -Rf "/Volumes/VMware Horizon Client/VMware Horizon Client.app" "/Applications/VMware Horizon Client.app" sleep 3Check if the copy completed and .app is present, modify via chown and chmod
if [ -e "/Applications/VMware Horizon Client.app" ] then echo "Application successfully copied" sudo chown root:wheel "/Applications/VMware Horizon Client.app" sudo chmod 755 "/Applications/VMware Horizon Client.app" else echo "Application not found!, check the $VendorDMG file" fiUnMount the vendor .dmg file, remove the vendor.dmg as cleanup
echo "UnMounting $VendorDMG" hdiutil detach "/Volumes/VMware Horizon Client" sleep 3 sudo rm -Rf "$VendorDMG" echo "Finished! Check status messages above" exit 0 ## Success exit 1 ## Failure
I am trying to get another script using postinstall to install Cylance, but I am not sure how to go about scripting it. I put the original Cylance pkg file in a tmp folder along with a .sh file with this content (updating TOKEN HERE with my license key. I found this lovely script in this forum https://www.jamf.com/jamf-nation/discussions/19218/installing-cylance-package#responseChild123682 - install cylance script):
#!/bin/sh!/bin/bash
echo TOKEN HERE > /private/tmp/Cylance/cyagent_install_token sudo installer -pkg /private/tmp/Cylance/CylancePROTECT.pkg -target / exit 0
Then I set the post install script as:
#!/bin/shpostinstall
!/bin/bash
pathToScript=$0 pathToPackage=$1 targetLocation=$2 targetVolume=$3 /private/tmp/Cylance/install_cylance_with_token.sh exit 0 ## Success exit 1 ## Failure
I have also just tried copying the content from the .sh file directly to the postinstall script so it reflected this:
#!/bin/shpostinstall
!/bin/bash
pathToScript=$0 pathToPackage=$1 targetLocation=$2 targetVolume=$3 echo TOKEN HERE > /private/tmp/Cylance/cyagent_install_token sudo installer -pkg /private/tmp/Cylance/CylancePROTECT.pkg -target / exit 0 ## Success exit 1 ## Failure
All of the apps install except Cylance. Although the pkg file I run places the original Cylance installer in the tmp folder I had designated earlier, it just won't install.


