Posted on 04-19-2017 01:29 PM
Hi,
I'm trying to create a policy to push out Project Libre 1.7 to a Mac workstation. There are a couple requirements for the install:
1) Project Libre requires that Java also be installed. We already have a seperate package for java.
2) If Java exists the install will continue and Project Libre will install but the status will report as 'failed' if the Java version installed is > what is in the policy. This happened to me as I manually upgraded java and was at a greater version.
My thought was to write a script (which i'm lousy at) to verify if Java is installed. It would then install both .pkg files from the cache location under JAMF/Downloads. The script looks as follows:
CurrentUser=stat -f "%Su" /dev/console
JavaFolder="/Library/Application Support/Oracle/java"
SoftwareLocation="/Library/Application Support/JAMF/Downloads/"
if [ -d "$JavaFolder" ]
then
echo " "
echo "/Java is already installed. Continuing with the install"
echo " "
else
sudo installer -pkg "$SoftwareLocation"/Java8Update112.pkg -target /Applications
fi
sudo installer -pkg "$SoftwareLocation"/ProjectLibre-1.7.pkg -target /Applications
The following is the error message in the policy logs. I also get the same error from the terminal. It basically looks like I don't have rights to that directory but I'm not sure how to get around that problem as it looks like Casper has it locked down.
[STEP 1 of 6]
Executing Policy Project Libre-1.7
[STEP 2 of 6]
Caching package Java8Update112.pkg...
Downloading Java8Update112.pkg...
Downloading https://d1yt58bk9i9lao.cloudfront.net/Java8Update112.pkg...
[STEP 3 of 6]
Caching package ProjectLibre-1.7.pkg...
Downloading ProjectLibre-1.7.pkg...
Downloading https://d1yt58bk9i9lao.cloudfront.net/ProjectLibre-1.7.pkg...
[STEP 4 of 6]
Running script Project Libre Script - Check for JavaInstall Project...
Script exit code: 1
Script result: installer: Error the package path specified was invalid: '/Library/Application Support/JAMF/Downloads//Java8Update112.pkg'.<br/>installer: Error the package path specified was invalid: '/Library/Application Support/JAMF/Downloads//ProjectLibre-1.7.pkg'.<br/>
Error running script: return code was 1.
[STEP 5 of 6]
[STEP 6 of 6]
Any assistance would be greatly appreciated. Especially if I'm going about this completely wrong :-)
Posted on 04-19-2017 01:51 PM
@Foster It looks like your script is failing because of the paths to your installers. There's the escape in Application Support and an extra '/' after downloads:
'/Library/Application Support/JAMF/Downloads//Java8Update112.pkg'
I would take a different approach to installing the software that would take out the need to script the install.
#!/usr/bin/env bash
#######################################################################################
# Collects information to determine which version of the Java plugin is installed and #
# then returning that version back if major version (1.X) match what we're searching #
# for with SEARCH_FOR_VERSION. Builds the result as 1.X.Y, ignoring the build number, #
# where X is major version and Y is the minor version. #
#######################################################################################
NOT_INSTALLED="Not Installed"
SEARCH_FOR_VERSION="8"
RESULT=""
if [ -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" ] ; then
RESULT=$( /usr/bin/defaults read "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" CFBundleVersion )
REPORTED_MAJOR_VERSION=`echo "$RESULT" | awk -F'.' '{print $2}'`
REPORTED_MINOR_VERSION=`echo "$RESULT" | awk -F'.' '{print $3}'`
if [ "$REPORTED_MAJOR_VERSION" != "$SEARCH_FOR_VERSION" ] ; then
RESULT="$NOT_INSTALLED"
else
RESULT=1."$REPORTED_MAJOR_VERSION".$REPORTED_MINOR_VERSION
fi
else
RESULT="$NOT_INSTALLED"
fi
echo "<result>$RESULT</result>"
Posted on 04-20-2017 04:59 AM
I agree with @Foster , scoping based on Java is the easier option.
As mentioned above you are defining the SoftwareLocation with a trailing /, which is then input again in your script. You need to remove the trailing / when defining the path.
Posted on 04-20-2017 09:21 AM
Definitely some great ideas here ...to help you get the right extension attribute for Java and its versions, steal the one JAMF uses for patch management reporting...add it then yourself manually. This will help you get good smart groups to know what you can target rationally.