Flash Update Script

djdavetrouble
Contributor III

Deleted old cringey script , the real one is below.

90 REPLIES 90

rmanly
Contributor III

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
Contributor III

...

djdavetrouble
Contributor III

...

rtrouton
Release Candidate Programs Tester

@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.

rtrouton
Release Candidate Programs Tester

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

djdavetrouble
Contributor III

...

mm2270
Legendary Contributor III

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.

maiksanftenberg
Contributor II

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

djdavetrouble
Contributor III

...

jmercier
Contributor II

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

hcodfrie
Contributor

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

peterlbk
Contributor

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}

bjones
New Contributor III

@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

peterlbk
Contributor

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

cwaldrip
Valued Contributor

Does this script work for both NPAPI and PPAPI ?

peterlbk
Contributor

This is only for the NPAPI flash install

denmoff
Contributor III

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.

peterlbk
Contributor

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

denmoff
Contributor III

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.

MattCrawford
New Contributor III

@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

peterlbk
Contributor

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

cwaldrip
Valued Contributor

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.

:-)

cgiordano
Contributor

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

thatsmyjamf
New Contributor

@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

andrew_nicholas
Valued Contributor

@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.

donmontalvo
Esteemed Contributor III

cwaldrip
Valued Contributor

@thatsmyjamf If I modify...

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

with...

latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p' | awk 'NR1==1{print $1; exit}'`

I get an empty response.

russeller
Contributor III

I apologize for not knowing the original author of the flash script I use, but this works for me still with 10.9 and newer:

latestver=`curl -s http://www.adobe.com/software/flash/about/ | grep -A4 "Macintosh" | grep -A1 "Safari" | sed -e 's/<[^>][^>]*>//g' -e '/^ *$/d' |  tail -n 1 | awk '{print $1}' | tr -d "
"`

mm2270
Legendary Contributor III

Its been a while since I posted to this thread, but looking at it again, I'm wondering is there's any reason you aren't using the official Flash Player xml file for grabbing the latest version? Scraping a webpage with curl and trying to glean out the version string isn't very reliable. I should know as I have a few products I've needed to do that with in scripts because the vendor doesn't supply an official update xml or sparkle feed. Pain in the butt to get the current version string from these. And there's no knowing when the vendor will suddenly redesign their page and break your script.

FWIW, here is the official xml file that FlashPlayer actually uses to know there's an update. AutoPkg uses this same URL just so you know, so its reliable (as long as Adobe updates it in a timely manner at least)
http://fpdownload2.macromedia.com/get/flashplayer/update/current/xml/version_en_mac_pl.xml

If you need a different language xml, it shouldn't be too difficult to locate then simply by changing the "en_" in the above to something else, like "es_" for Spanish for example and trying the address in your browser.

The current version string shows up in the <update version= key right near the top and is easy to awk or grep out of the results. It does show up with commas instead of periods, but that's easy to change with sed or tr.
Example:

curl -sS http://fpdownload2.macromedia.com/get/flashplayer/update/current/xml/version_en_mac_pl.xml | xmllint --format - | awk -F'"' '/update version/{print $2}' | sed 's/,/./g'

The above prints back:

22.0.0.192

cwaldrip
Valued Contributor

Assuming that both the PPAPI and NPAPI are updated to the same version, I've updated the script with @MattCrawford's updates and even @mm2270's xml curl so that it updates both the NPAPI and the PPAPI.

I'm worried though if they don't update both to the same version at the same time though.

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


    # Get the version number of the currently-installed Flash Player, if any.
    latestver=`/usr/bin/curl -sS http://fpdownload2.macromedia.com/get/flashplayer/update/current/xml/version_en_mac_pl.xml | xmllint --format - | awk -F'"' '/update version/{print $2}' | sed 's/,/./g'`

    # The downloads only use the major version number, so shorten it for the download
    shortver=${latestver:0:2}

    # Here are the URLs for the downloads
    NPAPIurl=http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg
    if [ -e /Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist ];then
        currentinstalledNPAPI=`/usr/bin/defaults read /Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist CFBundleShortVersionString`
    else
        currentinstalledNPAPI="0"
    fi

    PPAPIurl=https://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx_ppapi_pkg.dmg
    if [ -e /Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin/Contents/Info.plist ];then
        currentinstalledPPAPI=`/usr/bin/defaults read /Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin/Contents/Info.plist CFBundleShortVersionString`
    else
        currentinstalledPPAPI="0"
    fi

    # Compare the two NPAPI versions, if they are different of Flash is not present then download and install the new version.
    if [ "${currentinstalledNPAPI}" != "${latestver}" ]; then
        /bin/echo "`date`: Current NPAPI Flash version: ${currentinstalledNPAPI}" >> ${logfile}
        /bin/echo "`date`: Available NPAPI Flash version: ${latestver}" >> ${logfile}
        /bin/echo "`date`: Downloading newer NPAPI version." >> ${logfile}
        /usr/bin/curl -s -o `/usr/bin/dirname $0`/flash.dmg $NPAPIurl
        /bin/echo "`date`: Mounting NPAPI 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}
        newlyinstalledNPAPI=`/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
        if [ "${latestver}" = "${newlyinstalledNPAPI}" ]; then
            /bin/echo "`date`: SUCCESS: NPAPI Flash has been updated to version ${newlyinstalledNPAPI}" >> ${logfile}
        else
            /bin/echo "`date`: ERROR: NPAPI Flash update unsuccessful, version remains at ${currentinstalledNPAPI}." >> ${logfile}
            /bin/echo "--" >> ${logfile}
        fi
    # If Flash is up to date already, just log it and exit.
    else
        /bin/echo "`date`: Flash NPAPI is already up to date, running ${currentinstalledNPAPI}." >> ${logfile}
        /bin/echo "--" >> ${logfile}
    fi

    # Compare the two PPAPI versions, if they are different of Flash is not present then download and install the new version.
    if [ "${currentinstalledPPAPI}" != "${latestver}" ]; then
        /bin/echo "`date`: Current PPAPI Flash version: ${currentinstalledPPAPI}" >> ${logfile}
        /bin/echo "`date`: Available PPAPI Flash version: ${latestver}" >> ${logfile}
        /bin/echo "`date`: Downloading newer PPAPI version." >> ${logfile}
        /usr/bin/curl -s -o `/usr/bin/dirname $0`/flash.dmg $PPAPIurl
        /bin/echo "`date`: Mounting PPAPI 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 Pepper 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}
        newlyinstalledPPAPI=`/usr/bin/defaults read /Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin/Contents/Info.plist CFBundleShortVersionString`
        if [ "${latestver}" = "${newlyinstalledPPAPI}" ]; then
            /bin/echo "`date`: SUCCESS: PPAPI Flash has been updated to version ${newlyinstalledPPAPI}" >> ${logfile}
        else
            /bin/echo "`date`: ERROR: PPAPI Flash update unsuccessful, version remains at ${currentinstalledPPAPI}." >> ${logfile}
            /bin/echo "--" >> ${logfile}
        fi
    # If Flash is up to date already, just log it and exit.
    else
        /bin/echo "`date`: PPAPI Flash is already up to date, running ${currentinstalledPPAPI}." >> ${logfile}
        /bin/echo "--" >> ${logfile}
    fi
exit

peterlbk
Contributor

I adjusted the script I wrote a bit. Seems some changes were made by Adobe.

Anyway, the reason why you can't use the xmll is that it regularly changes. That's the main reason why this script is more or less in use since 10.9. Besides I would never update flash in two version, already having problems updating one...

So here's the new version of the script:

#!/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' | head -1`
    # 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

thatsmyjamf
New Contributor

@cwaldrip - My apologies for the delay in response. My previous reply was actually my first here on JAMF Nation, and the moderator approval took a while :)

I goofed up the line. It should be as follows:

latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p' | grep 2 | awk 'NR==1{print $1; exit}'`

Below is the full text of the updated script we used on our Yosemite/El Cap Macs:

#!/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' | grep 2 | awk 'NR==1{print $1; exit}'`
    # 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

thatsmyjamf
New Contributor

@cwaldrip - My apologies for the delay in response. My previous reply was actually my first here on JAMF Nation, and the moderator approval took a while :)

I goofed up the line. It should be as follows:

latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p' | grep 2 | awk 'NR==1{print $1; exit}'`

Below is the full text of the updated script we used on our Yosemite/El Cap Macs:

#!/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' | grep 2 | awk 'NR==1{print $1; exit}'`
    # 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

cgiordano
Contributor

@thatsmyjamf There's always so many ways to write this stuff but I think you'd be able to shorten your variable from:

latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p' | grep 2 | awk 'NR==1{print $1; exit}'`

down to:

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

I found multiple results issue a little while back as well so I just added that and it was good to go.
thanks for the script as a whole, though, it's saved me so much time!
Chris

thatsmyjamf
New Contributor

@cgiordano - I love it! Thanks for the update. I am always trying to hone my awk/sed skillsets. This forum post has been a tremendous help.

cgiordano
Contributor

@thatsmyjamf Sure thing, glad to help. For the record, I love awk and abhor sed :P

thatsmyjamf
New Contributor

@cgiordano - Admittedly, I feel the exact same way! :)

cwaldrip
Valued Contributor

It looks like Adobe has changed the download URLs. The script is unable to get the latest NPAPI or PPAPI updates from the script...

http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_"${shortver}"_osx.dmg

i.e. http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_24_osx.dmg

peterlbk
Contributor

Allright guys, just checked and updated the script:

#!/bin/sh -x
#####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
#   UpdateFlash.sh -- Installs or updates Adobe Flash Player
#
#
####################################################################################################
#
#   Peter Loobuyck grabbed bits from the net 
#
####################################################################################################


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

#
    latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/</tr/s/[^>]*>([0-9].*)<.*/1/p' | head -1`
    # Get the version number of the currently-installed Flash Player, if any.
    shortver=${latestver:0:2}
    url=https://fpdownload.adobe.com/get/flashplayer/pdc/"${latestver}"/install_flash_player_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