Flash player/Installation script

From OLPC
Jump to navigation Jump to search

This is a script for installing Flash on your XO. To use:

  • Copy the text of the script below and save it as installflash.sh on your XO
  • Open the Terminal activity
  • Navigate to the directory where the script is stored (cd path/to/directory)
  • Run the script (./installflash.sh)
#!/bin/bash

# fl: A script for friendlier Flash installation for the XO-1.
# Obligatory MIT license follows:
#
#####
#
# Copyright (c) 2007 Phil Bordelon
# 
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
#####

# The USER_FLASH_URI is the address to download the .tar.gz that
# is used for user installation.
#USER_FLASH_URI="http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz"
USER_FLASH_URI="http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz"

# The USER_FLASH_TARBALL is the filename that should result from
# the above URI download.  These should match.
USER_FLASH_TARBALL="install_flash_player_9_linux.tar.gz"

# The USER_FLASH_FILEPATH is the actual file we want out of the
# tarball.
USER_FLASH_FILEPATH="install_flash_player_9_linux/libflashplayer.so"

# And the USER_FLASH_FILENAME is the actual filename bits of that.
# (Yes, I am beginning to suspect I should have used Python for
# this program.)
USER_FLASH_FILENAME="libflashplayer.so"

# The MOZILLA_PLUGIN_DIR is the directory for installing user
# Mozilla plugins.
MOZILLA_PLUGIN_DIR="/home/olpc/.mozilla/plugins"

# SUDO holds the path to the sudo executable.  We use its
# presence to determine whether or not we should use 'sudo'
# or 'su - -c'.
SUDO="/usr/bin/sudo"

# The RPM_FLASH_URI is the address for the RPM version of Flash
# that we install.
RPM_FLASH_URI="http://fpdownload.macromedia.com/get/flashplayer/current/flash-plugin-9.0.48.0-release.i386.rpm"

# The FLTMPDIR is a directory we're going to unpack things into,
# etc. so as to not clutter the primary file system.
FLTMPDIR="FLTMPDIR"

# First, we make sure we're in a decent working directory.
mkdir "${FLTMPDIR}"
cd "${FLTMPDIR}"

# Now, step '3': Grab the tarball.
echo
echo "***** Downloading the Flash tarball from Adobe ... *****"
echo
wget "${USER_FLASH_URI}"

# Note if the wget failed ...
if [[ $? -ne 0 ]]; then
   echo
   echo "!!!!!         There was an error downloading Flash.         !!!!!"
   echo "!!!!! Please verify that you are connected to the Internet. !!!!!"
   echo "!!!!!               ERROR CODE: X-FL-WGETBAD                !!!!!"
   echo
   exit
fi

# Note if we didn't get the file we expected.
if [[ ! -f "${USER_FLASH_TARBALL}" ]]; then
   echo
   echo "!!!!! The downloaded filename does not match what we expected. !!!!!"
   echo "!!!!!  Please report this issue to whomever pointed you here.  !!!!!"
   echo "!!!!!                 ERROR CODE: X-FL-TARRONG                 !!!!!"
   echo
   exit
fi

# Okay, so far so good.  Time to unpack. ('4')
echo
echo "***** Unpacking the Flash tarball ... *****"
echo
tar xvf "${USER_FLASH_TARBALL}" "${USER_FLASH_FILEPATH}"

if [[ $? -ne 0 ]]; then
   echo
   echo "!!!!!     The Flash tarball did not unpack successfully.     !!!!!"
   echo "!!!!! Please report this issue to whomever pointed you here. !!!!!"
   echo "!!!!!                ERROR CODE: X-FL-FUNPACK                !!!!!"
   echo
   exit
fi

# Now, make the directory ... ('5')
echo
echo "***** Making the Mozilla plugin directory ... *****"
echo

if [[ ! -d "${MOZILLA_PLUGIN_DIR}" ]]; then
   mkdir -p "${MOZILLA_PLUGIN_DIR}"
fi

if [[ ! -d "${MOZILLA_PLUGIN_DIR}" ]]; then
   echo
   echo "!!!!!   The Mozilla plugin directory could not be created.   !!!!!"
   echo "!!!!! Please report this issue to whomever pointed you here. !!!!!"
   echo "!!!!!                ERROR CODE: X-FL-MPLUGDR                !!!!!"
   echo
   exit
fi

# Lastly for the user bits, move the plugin into the proper location. ('6')
echo
echo "***** Moving the Flash plugin into the Mozilla plugin directory ... *****"
echo

mv "${USER_FLASH_FILEPATH}" "${MOZILLA_PLUGIN_DIR}"

if [[ ! -f "${MOZILLA_PLUGIN_DIR}/${USER_FLASH_FILENAME}" ]]; then
   echo
   echo "!!!!!       The Flash plugin could not be installed.         !!!!!"
   echo "!!!!! Please report this issue to whomever pointed you here. !!!!!"
   echo "!!!!!                ERROR CODE: X-FL-MPLUGMV                !!!!!"
   echo
   exit
fi

# And, as a grand finale, install the RPM. ('7' and '8' in one go.)

echo
echo "***** Installing the Flash RPM ... *****"
echo

if [[ -f "${SUDO}" ]]; then
   "${SUDO}" "rpm -i ${RPM_FLASH_URI}"
else
   su - -c "rpm -i ${RPM_FLASH_URI}"
fi

if [[ $? -ne 0 ]]; then
   echo
   echo "!!!!!         The Flash RPM could not be installed.          !!!!!"
   echo "!!!!! Please report this issue to whomever pointed you here. !!!!!"
   echo "!!!!!                ERROR CODE: X-FL-RPMFAIL                !!!!!"
   echo
   exit
fi

echo
echo "^^^^^ Flash installation is complete.  You will have to close ^^^^^"
echo "^^^^^ any running Browse activities and restart Browse to use ^^^^^"
echo "^^^^^                  the new Flash plugin.                  ^^^^^"
echo