Posted on 03-26-2018 10:17 AM
Hello Everyone. My name is Chris. I made this handy script that mounts cached DMGs and installs the contents silently for users. I know this isn't a big deal or anything but I wanted to contribute something for those learning to script for bash or may be in a packaging position for JSS for the first time and need something to reference to help them along. Please feel free to use this to your hearts content. The example below is for JRE10
-Cheers
#!/bin/bash
##########################################################################
# Install Application from DMG in Jamf Waiting ROOM
# Created By: Christopher Glover
# Date: 03/26/2018
#
# Disclaimer:
# These scripts come without warranty of any kind. Use them at your own risk.
# I assume no liability for the accuracy, correctness, completeness, or usefulness of any information
# provided by this site nor for any sort of damages using these scripts may cause.
##########################################################################
# Changes directory to '/library/Application Support/JAMF/Waiting Room/' this is where JSS storred cached files.
cd /library/Application Support/JAMF/Waiting Room/
#Mounts Downloaded DMG within the Jamf Waiting room
hdiutil attach -nobrowse jre-10_osx-x64_bin.dmg
#Changes Directory to '/Volumes/Java 10.app/Contents/Resources' (this is where the PKG lives with its dependancies)
cd /Volumes/Java 10/Java 10.app/Contents/Resources/
#Calls the installer and installs it to the root of the dirve which is the default
installer -pkg JavaAppletPlugin.pkg -target /
#Backs out of the DMG (This has to happen or else the DMG resource will be busy and cant be dismounted
cd /
#Sleeps for 20 seconds to finish up any lingering processes from installer
sleep 20
#Detatches the DMG
hdiutil detach /Volumes/Java 10/
#Changes directory to '/library/Application Support/JAMF/Waiting Room/' this is where JSS storred cached files
cd /library/Application Support/JAMF/Waiting Room/
echo "cleaning up"
#Cleans Up the dmg so it doesnt take up space on machine
rm jre-10_osx-x64_bin.dmg
#cleans out the XML
rm jre-10_osx-x64_bin.dmg.cache.xml
exit 0
Posted on 03-26-2018 10:34 AM
@TheBeastie With your example you can just upload the PKG that is inside the DMG. Deploy the PKG with a policy and you are all set.
This may be helpful as well. You can deploy a policy with "Install Cached" which will do exactly what your script is doing. Additionally you can select "Install Cached Packages" from the Maintenance payload which will install all items in the Waiting Room.
Posted on 03-26-2018 10:39 AM
but doesnt that only work with dmgs that only have .pkgs? what about .exec and .app files?
Posted on 03-27-2018 12:48 PM
@TheBeastie Well Jamf Admin supports PKGs, DMGs, and MPKGs (with the exception of .app that is an OS Installer). So if you do have an .app that you would like to deploy, you would use composer to build a DMG/PKG. Then cache it with a policy.
Install Cached Packges will install any "Package" (DMG/PKG) in the Waiting Room folder.
Posted on 03-27-2018 12:56 PM
In the specific script example posted by @TheBeastie they are installing the embedded JavaAppletPlugin.pkg inside the Java Plug-in installer app bundle, something Java has been doing now for a while.
In my case, I simply drill into the Contents folder of the Java app bundle and extract the pkg and upload that directly to Jamf Admin. It doesn't need to remain inside that location and installed from there to work in my experience, so there really shouldn't be a need to do anything special with the Java plug-in install other than getting that embedded pkg from the app and using that.
Posted on 03-28-2018 08:43 AM
I guess one instance where my script would come in handy is VPN installation and configuration. Im doing the below for this.
#!/bin/bash
#######################################################################################################
# Install Application from DMG in Jamf Waiting ROOM #
# Created By: Christopher Glover #
# Date: 03/26/2018 #
# #
# Disclaimer: #
# These scripts come without warranty of any kind. Use them at your own risk. #
# I assume no liability for the accuracy, correctness, completeness, or usefulness of any information #
# provided by this site nor for any sort of damages using these scripts may cause. #
#######################################################################################################
# We're checking to see if Pulse Secure.app already exists and if so remove it. We do this because VPN configuration wont take place unless older client is removed first.
echo "Checking for older Pulse clients"
cd /Applications/
# Checking if the application exists
if [ -d "~/Applications/Pulse Secure.app" ]; then
# If it does exist it will remove
rm -rf "/Applications/Pulse Secure.app/"
fi
echo "Starting installation now"
# Changes directory to '/library/Application Support/JAMF/Waiting Room/' this is where JSS storred cached files.
cd /library/Application Support/JAMF/Waiting Room/
#Mounts Downloaded DMG within the Jamf Waiting room
hdiutil attach -nobrowse PulseSecure-5.3r2.0-b853.dmg
#Changes Directory to '/Volumes/Pulse/' (this is where the PKG lives with its dependancies)
cd /Volumes/Pulse/
#Calls the installer and installs it to the root of the dirve which is the default
installer -pkg PulseSecure.pkg -target /
echo "configuring vpn connections"
#Configures VPN client with FRB Custom file Generated by VPN admins
/Applications/Pulse Secure.app/Contents/Plugins/JamUI/./jamcommand -importfile /Volumes/Pulse/FRB.jnprpreconfig
sleep 10
#Backs out of the DMG (This has to happen or else the DMG resource will be busy and cant be dismounted
cd /
#Sleeps for 20 seconds to finish up any lingering processes from installer
sleep 20
#Detatches the DMG
hdiutil detach /Volumes/Pulse/
#Changes directory to '/library/Application Support/JAMF/Waiting Room/' this is where JSS storred cached files
cd /library/Application Support/JAMF/Waiting Room/
echo "cleaning up"
#Cleans Up the dmg so it doesnt take up space on machine
rm PulseSecure-5.3r2.0-b853.dmg
#cleans out the XML
rm PulseSecure-5.3r2.0-b853.dmg.cache.xml
#reloading dock
echo "Reloading Dock"
killall Dock
echo "Work Complete"
exit 0
Posted on 03-28-2018 04:02 PM
@TheBeastie Do you have a github? I have one that is currently being redesigned. But I have over 800 scripts for Mac, Linux/BSD and JAMF.
Posted on 03-29-2018 08:43 AM
I actually dont. I was thinking about putting some of my work in a github. I do a lot of stuff for OSX and FreeBSD and Windows. May be worth my while to put my work there since I have over 2000 scripts that I tend to forget I even have.
Posted on 03-29-2018 01:03 PM
Recently deleted all the info off of mine. Starting over as it was a bad design in the first place. Going to take weeks to get all of my scripts back in there. I believe it's worth it though. Especially if you're a good scripter and don't mind sharing. And it definitely seems you're proud of your work and like sharing.
Posted on 09-30-2019 09:47 PM
@amit.vasani , I've simply zipped any other supporting files for the installation and cached the zip file into Waiting Room folder. Then I used the simple unzip -o "source/zipfile" -d "destination" command to unpack the contents and used the files for the commands in the script.
Uploading the zip file to Jamf Admin is fine. It just recognises it as unknown format.
Posted on 04-05-2021 02:30 PM
Just here to say that this was helpful. Thank you.