Create a gist now

Instantly share code, notes, and snippets.

Bash script to update Adobe Flash Player on OS X (NPAPI Version).
# Script is a modified version of
# and
# Check if we are running as root
me=`basename "$0"`
if [[ "$USER" != "root" ]]; then
echo "You must run this script as root: Type \"sudo "$me"\"."
exit 1
latestver=`/usr/bin/curl -s | sed -n '/Safari/,/<\/tr/s/[^>]*>\([0-9].*\)<.*/\1/p' | head -1`
# Get the version number of the currently-installed Flash Player, if any.
currentinstalledver=`defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
# Compare the two versions, if they are different or Flash is not present, then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
echo "`date`: Current Flash version: ${currentinstalledver}"
echo "`date`: Available Flash version: ${latestver}"
echo "`date`: Downloading newer version."
curl -s -o `dirname $0`/flash.dmg $url
echo "`date`: Mounting installer disk image."
hdiutil attach `dirname $0`/flash.dmg -nobrowse -quiet
echo "`date`: Installing..."
installer -pkg /Volumes/Flash\ Player/Install\ Adobe\ Flash\\ Flash\ Player.pkg -target /
sleep 2
echo "`date`: Unmounting installer disk image."
hdiutil detach $(df | grep ${volname} | awk '{print $1}') -quiet
sleep 2
echo "`date`: Deleting disk image."
rm `dirname $0`/${dmgfile}
newlyinstalledver=`defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}"
echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}."
echo "--"
# If Flash is up to date already, just log it and exit.
echo "`date`: Flash is already up to date, running ${currentinstalledver}."
echo "--"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment