Skip to main content

Deleted old cringey script , the real one is below.

If you are going to all this trouble to keep flash up to date why not just let it update itself?



It also seems like you are copy & pasting tidbits from all over the web...that is fine as far as it goes but you should try and learn from what you find and apply it elsewhere.



For example compare the usage of awk on your launchctl line to the crazy pipeline at the top.



awk '/loginwindow$/ {print $1; exit}'


sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*.[0-9]*' | awk 'NR < 2'


Not only are all these greps unnecessary because you could have used awk to do the work for you they are unnecessary for another reason as well. Very often in *NIX land but unfortunately not as often in OS X when you have to do backflips to get the info. you want it is because you are not asking the right question. Check man pages and see if you can get the info. out of the program directly before parsing its default output.



sw_vers -productVersion


Then you could do something like:



sw_vers -productVersion | awk -F. '{ print $2 }'


to get the minor version of the OS.



To find out what might be wrong with your launchctl line try changing the shebang to



#!/bin/bash -x


and see what is erroring in the output, and use pgrep if you are working with 10.8 only instead of ps.


...


...


@djdavetrouble,



As long as you're doing the latter script, I'd recommend installing the package that's available at /Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg. You would get an actual silent install (via the package).



This wouldn't install or update the Flash updater mechanism, but since you're handling the updates anyway, I don't see that as a significant drawback.


Here's a way to install the package and make the process invisible to your users:



#!/bin/sh

# Script to download and install Flash Player.
# Only works on Intel systems.

# Change working directory to /tmp

/usr/bin/cd /tmp

#download flash dmg. Yes I have agreed to all of the licensing terms and am fully compliant with everything in the whole world. Add -s to curl if you hate progress meters
echo downloading

/usr/bin/curl -O http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_11_osx.dmg

# Mount the install_flash_player_11_osx.dmg disk image in /Volumes

echo "`date`: Mounting installer disk image."
/usr/bin/hdiutil attach install_flash_player_11_osx.dmg -nobrowse -noverify -noautoopen

echo "`date`: Installing..."

/usr/sbin/installer -dumplog -verbose -pkg "/Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg" -target "/"

echo "`date`: Unmounting installer disk image."

# Clean-up

# Unmount the install_flash_player_11_osx.dmg disk image from /Volumes

/usr/bin/hdiutil eject -force /Volumes/Flash Player

# Remove the install_flash_player_11_osx.dmg disk image from /tmp

/bin/rm -rf /tmp/install_flash_player_11_osx.dmg

...


If you want to use the official Adobe process with the -install command, then there is one other option you could look at to make the install process invisible, assuming that's even important to you of course.



After downloading the DMG, mount it as you're already doing but copy the installer app to a tmp location, then use defaults to do the following to modify the installer app.



defaults write /tmp/Install Adobe Flash Player.app/Contents/Info NSUIElement -int 1


Then run the installation from that /tmp/ path instead and clean up everything at the end, just as you're doing now.



This can only be done on a copy of course since anything in a mounted disk image is read only, at least in the case of vendor supplied ones. What that setting does is make the app invisible when launched, or more precisely, not allow it to show an icon in the Dock. The rest of the install windows don't show up when run from a command line install, so adding that in effectively makes it invisible to the end user. But in the end you'd still be using the "official" Adobe installation method, for whatever that means to you.


Hi.
Have a look here https://jamfnation.jamfsoftware.com/discussion.html?id=4856.
The latest Flash versions allow an automated update process that uses fpsaud from /Library/Application Support/Adobe/Flash Player Install Manager.



I use the pkg method and deploy a mms.cfg with Silent Update Settings (located under /Library/Application Support/Macromedia.



It's working in our environment.



Cheers


...


i know this is an old post... but the original script up there... looks amazingly the same as i just found on another web page back in 2011 !!



is this script been tested on new systems... looks like im having errors with $ declared in the script


@rtrouton looks like your script leaves the installer in the root of the drive


Just created a new version of this script. This on works with 10.10 and flash version 17:



#!/bin/sh

if [[ "$USER" != "root" ]]; then
echo "You must run this script as root."
exit 1
fi
dmgfile="flash.dmg"
volname="Flash"
logfile="/Library/Logs/FlashUpdateScript.log"


latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p'`
# Get the version number of the currently-installed Flash Player, if any.
shortver=${latestver:0:2}
url=http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg
currentinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
#else
# currentinstalledver="none"
#fi
# Compare the two versions, if they are different of Flash is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
/bin/echo "`date`: Current Flash version: ${currentinstalledver}" >> ${logfile}
/bin/echo "`date`: Available Flash version: ${latestver}" >> ${logfile}
/bin/echo "`date`: Downloading newer version." >> ${logfile}
/usr/bin/curl -s -o `/usr/bin/dirname $0`/flash.dmg $url
/bin/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/bin/hdiutil attach `dirname $0`/flash.dmg -nobrowse -quiet
/bin/echo "`date`: Installing..." >> ${logfile}
/usr/sbin/installer -pkg /Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg -target / > /dev/null
/bin/sleep 10
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep ${volname} | awk '{print $1}') -quiet
/bin/sleep 10
/bin/echo "`date`: Deleting disk image." >> ${logfile}
/bin/rm `/usr/bin/dirname $0`/${dmgfile}
newlyinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
/bin/echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}" >> ${logfile}
else
/bin/echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi
# If Flash is up to date already, just log it and exit.
else
/bin/echo "`date`: Flash is already up to date, running ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi

{/quote}

@peterloobuyck



Hey Peter i have a question in reference to the script you have posted above. Does it work on 9.8? I have been doing some testing and the script is giving me an error.



Script result: 2015-09-28 17:48:34.500 defaults[1128:11711]
The domain/default pair of (/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version, CFBundleShortVersionString) does not exist
usage: dirname path
usage: dirname path
usage: dirname path
2015-09-28 17:49:00.597 defaults[1183:12075]
The domain/default pair of (/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version, CFBundleShortVersionString) does not exist


Hi @bjones, seems you have a point. If there is no Flash installed, you get that error. The script works though. If you run it again, it should be ok.



However, I did make changes do that one shouldn't give an error anymore, although for some systems it stills gives errors.I'll look into the matter a bit further.



#!/bin/sh

dmgfile="flash.dmg"
volname="Flash"
logfile="/Library/Logs/FlashUpdateScript.log"

# Get latest Flash version online
latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p'`

# Get the version number of the currently-installed Flash Player, if any.
shortver=${latestver:0:2}
url=http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg

#check if Flash is installed
if [ -f "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" ]
then
currentinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin" CFBundleShortVersionString`
else
currentinstalledver="noflash"
fi

# Compare the two versions, if they are different of Flash is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
/bin/echo "`date`: Current Flash version: ${currentinstalledver}" >> ${logfile}
/bin/echo "`date`: Available Flash version: ${latestver}" >> ${logfile}
/bin/echo "`date`: Downloading newer version." >> ${logfile}
/usr/bin/curl -s -o `/usr/bin/dirname $0`/flash.dmg $url
/bin/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/bin/hdiutil attach `dirname $0`/flash.dmg -nobrowse -quiet
/bin/echo "`date`: Installing..." >> ${logfile}
/usr/sbin/installer -pkg /Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg -target / > /dev/null
/bin/sleep 10
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep ${volname} | awk '{print $1}') -quiet
/bin/sleep 10
/bin/echo "`date`: Deleting disk image." >> ${logfile}
/bin/rm `/usr/bin/dirname $0`/${dmgfile}
newlyinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
/bin/echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}" >> ${logfile}
else
/bin/echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi
# If Flash is up to date already, just log it and exit.
else
/bin/echo "`date`: Flash is already up to date, running ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi

Does this script work for both NPAPI and PPAPI ?


This is only for the NPAPI flash install


I've been getting a lot of "failed" policy runs but the script seems to be successfully updating flash. It does, however, return an exit code of 239. Any ideas what would cause that error code? BTW, some runs are returning a 0 exit code.



Executing Policy Flash Updater Script
Running script flash_updater.sh...
Script exit code: 239
Script result: Mon Jan 25 10:39:15 EST 2016: Current Flash version: 20.0.0.267
Mon Jan 25 10:39:15 EST 2016: Available Flash version: 20.0.0.286
Mon Jan 25 10:39:15 EST 2016: Downloading newer version.
Mon Jan 25 10:39:15 EST 2016: Mounting installer disk image.
Mon Jan 25 10:39:18 EST 2016: Installing...
Mon Jan 25 10:39:34 EST 2016: Unmounting installer disk image.
Mon Jan 25 10:39:44 EST 2016: Deleting disk image.
Mon Jan 25 10:39:44 EST 2016: SUCCESS: Flash has been updated to version 20.0.0.286
239
Error running script: return code was 239.

Hi Dennis,



Just had another peek at my script. In my environment I get all ok responses. I attach my script underneath. Just to know, you'll also need to have an updated jss environment. Else all errors or fail messages will have the policy fail.



#!/bin/sh

dmgfile="flash.dmg"
volname="Flash"
logfile="/Library/Logs/FlashUpdateScript.log"

#
latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p'`
# Get the version number of the currently-installed Flash Player, if any.
shortver=${latestver:0:2}
url=http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg
currentinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
#else
# currentinstalledver="none"
#fi
# Compare the two versions, if they are different of Flash is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
/bin/echo "`date`: Current Flash version: ${currentinstalledver}" >> ${logfile}
/bin/echo "`date`: Available Flash version: ${latestver}" >> ${logfile}
/bin/echo "`date`: Downloading newer version." >> ${logfile}
/usr/bin/curl -s -o `/usr/bin/dirname $0`/flash.dmg $url
/bin/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/bin/hdiutil attach `dirname $0`/flash.dmg -nobrowse -quiet
/bin/echo "`date`: Installing..." >> ${logfile}
/usr/sbin/installer -pkg /Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg -target / > /dev/null
/bin/sleep 10
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep ${volname} | awk '{print $1}') -quiet
/bin/sleep 10
/bin/echo "`date`: Deleting disk image." >> ${logfile}
/bin/rm `/usr/bin/dirname $0`/${dmgfile}
newlyinstalledver=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
/bin/echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}" >> ${logfile}
else
/bin/echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi
# If Flash is up to date already, just log it and exit.
else
/bin/echo "`date`: Flash is already up to date, running ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi

Thanks for posting this @peterloobuyck I think i found the problem i was having. I was calling the jamfhelper.app to run a popup window to let people know that flash was updated. I was calling it from the old location instead of the new "usr/local" location.


@peterloobuyck Many thanks for this script has been so useful to us!
We now have this as part of our 'Update Window' each Sunday too keep everything unto date.



Recently I have been playing with an El Capitan distribution and found the script didn't work. Discovered this was due to the security changes in 10.11 on user writable locations, /usr/bin is no longer writable.



I've taken the liberty of updating your script and it seams to work fine for 10.11-



Many thanks again
Matt



#!/bin/sh
dmgfile="flash.dmg"
volname="Flash"
logfile="/Library/Logs/FlashUpdateScript.log"


latestver=`/usr/local/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p'`
# Get the version number of the currently-installed Flash Player, if any.
shortver=${latestver:0:2}
url=http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg
currentinstalledver=`/usr/local/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
#else
# currentinstalledver="none"
#fi
# Compare the two versions, if they are different of Flash is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
/local/echo "`date`: Current Flash version: ${currentinstalledver}" >> ${logfile}
/local/echo "`date`: Available Flash version: ${latestver}" >> ${logfile}
/local/echo "`date`: Downloading newer version." >> ${logfile}
/usr/local/curl -s -o `/usr/local/dirname $0`/flash.dmg $url
/local/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/local/hdiutil attach `dirname $0`/flash.dmg -nobrowse -quiet
/local/echo "`date`: Installing..." >> ${logfile}
/usr/sbin/installer -pkg /Volumes/Flash Player/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg -target / > /dev/null
/local/sleep 10
/local/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/local/hdiutil detach $(/local/df | /usr/local/grep ${volname} | awk '{print $1}') -quiet
/local/sleep 10
/local/echo "`date`: Deleting disk image." >> ${logfile}
/local/rm `/usr/local/dirname $0`/${dmgfile}
newlyinstalledver=`/usr/local/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
/local/echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}" >> ${logfile}
else
/local/echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
/local/echo "--" >> ${logfile}
fi
# If Flash is up to date already, just log it and exit.
else
/local/echo "`date`: Flash is already up to date, running ${currentinstalledver}." >> ${logfile}
/local/echo "--" >> ${logfile}
fi

Hi Matt, thank you for your contribution!



I just checked if my script had problems. Seems not on El Cap client with ubuntu server.



Peter


Maybe it's just me, but my El Capitan machine doesn't have the binaries curl, rm, or echo in /usr/local or /local, but in /usr/bin and /bin.



:-)


This is absolutely great, however I do have a question...



We'd only really be using this for initial installation, not post-deployment. Is there a way to install it then change the Update preferences to "Allow Adobe to install updates" via command line? I dug through some of the plist files and I didn't see anything that might control that so I don't know if a defaults write command would work.



Any suggestions would be great.
Thanks!
Chris


@cwaldrip - Same here for our El Cap installs and binary locations. What I did to update the script:



/usr/local - Changed all instances to /usr/bin
/local - Changed all instances to /bin



I am finding that the curl + sed line to grab the latest Flash version is returning two strings - both the current Mac OS X version and the NPAPI (Extended Support Release) version. The output, right now is:



22.0.0.192
18.0.0.360



To grab only the first line, add this command to the end of the script's curl command:



| awk 'NR1==1{print $1; exit}'



Source: http://stackoverflow.com/questions/22190902/cut-or-awk-command-to-print-first-string-of-first-row


@cgiordano I'm not sure if you've had your question answered, but what I believe you're looking for is the file located at /Library/Application Support/Macromedia/mms.cfg.


Reply