Below is new version, which includes command line parameters, using a local dir (e.g. floppy) and an fully interactive, mode with an 4-step wizard in english and german translation
Enjoy!!!
#!/bin/bash
#
# Install flash plugin - from website or from directory -
# (is kept if configuration is saved!)
#
# GPL
#
# Author: Fabian Franz <
[email protected]>
# Constants
VERSION="0.1";
FLASH_PATH= # unset flash path
FLASH_NAME="install_flash_player_6_linux.tar.gz"
FLASH_DIR="install_flash_player_6_linux"
FLASH_FILES="flashplayer.xpt libflashplayer.so"
FLASH_DL_PATH="http://macromedia.mplug.org/tarball/debian/install_flash_player_6_linux.tar.gz"
INTERACTIVE="yes"
clean_exit(){
[ -n "$TMP" ]&& rm -f "$TMP"
}
trap clean_exit EXIT
function setup_dialog()
{
# Set up dialog
XDIALOG_HIGH_DIALOG_COMPAT=1
export XDIALOG_HIGH_DIALOG_COMPAT
TMP="/tmp/knx-flashplugin.tmp$$"
DIALOG="dialog"
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
MAX=4 # number of steps
case "$LANGUAGE" in
de*)
BT="Flashplugin-Installation"
T1="Installation von Macromedia Flash (Schritt 0/$MAX)"
ET="Installation fehlgeschlagen"
ST="Installation erfolgreich"
MESSAGE0="Dieses Skript installiert das Macromedia-Flashplugin aus dem Internet oder von einem Verzeichnis Ihrer Wahl.\n\nAutor: Fabian Franz <
[email protected]>"
MESSAGE1="Soll das Flash-Plugin aus dem Internet heruntergeladen werden?"
MESSAGE2="Bitte geben Sie das Verzeichnis an, wo $FLASH_NAME gefunden werden kann."
MESSAGE3="PATH nicht gefunden. Das Skript wird beendet."
MESSAGE4="Scanne nach neuen Plugins. (Konqueror)"
MESSAGE5="Das Flash-Plugin wurde erfolgreich installiert."
;;
*)
BT="Flashplugin-Installation"
T1="Installation of Macromedia Flash (Step 0/$MAX)"
ET="Installation failed"
ST="Installation succeeded"
MESSAGE0="This script installs the Macromedia-flashplugin from the internet or from a directory of your choice.\n\nAuthor: Fabian Franz <
[email protected]>"
MESSAGE1="Shall the flash plugin be downloaded from the internet?"
MESSAGE2="Please insert the directory name, where $FLASH_NAME can be found."
MESSAGE3="PATH not found. The script will be terminated."
MESSAGE4="Scanning for new plugins. (Konqueror)"
MESSAGE5="The Flash-Plugin was successfully installed."
;;
esac
N=1; # Step 1
}
# Commandline parsing
while [ $# -ne 0 ];
do
if [ "$1" = "-ni" ];
then
INTERACTIVE="no"
fi
if [ "$1" = "-i" ];
then
INTERACTIVE="yes"
fi
if [ "$1" = "--help" ];
then
echo "install_flashplugin - version $VERSION"
echo "Usage: install_flashplugin <options from below>"
echo " -i - Interactive Dialog mode (default)"
echo " -ni - Non interactive install mode"
echo " -l directory - Where to find the flashplugin"
echo " if not given it is downloaded from the internet"
echo " --help - This help"
exit 1
fi
if [ "$1" = "-l" ];
then
FLASH_PATH=$2
fi
shift # next parameter
done
[ "$INTERACTIVE" = "yes" ] && setup_dialog
if [ -n "$DIALOG" ]; then
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --msgbox "$MESSAGE0" 15 70
N=$(($N+1))
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --yesno "$MESSAGE1" 15 70
RC=$?
N=$(($N+1))
cd /tmp
if [ $RC -eq 1 ]; # give location
then
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --inputbox "$MESSAGE2" 15 70 "$FLASH_PATH" 2>$TMP
[ $? -eq 1 ] && exit 1 # cancel ?
N=$(($N+1))
FLASH_PATH=$(<$TMP)
if [ -f $FLASH_PATH/$FLASH_NAME ]; then
cp $FLASH_PATH/$FLASH_NAME /tmp
else
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "${MESSAGE3/PATH/$FLASH_PATH/$FLASH_NAME}" 15 70 # error!
exit 1
fi
else # dl it
if [ $DIALOG = "dialog" ]; then
wget $FLASH_DL_PATH
else
xterm -e wget $FLASH_DL_PATH
fi
N=$(($N+1))
fi
# Now we should have a /tmp/$FLASH_NAME
if [ -f /tmp/$FLASH_NAME ];
then
tar xzf $FLASH_NAME
cd $FLASH_DIR
mkdir -p /home/knoppix/.netscape/plugins/
mkdir -p /home/knoppix/.mozilla/plugins/
cp $FLASH_FILES /home/knoppix/.netscape/plugins/
cp $FLASH_FILES /home/knoppix/.mozilla/plugins/
RC=$?
cd ..
#cleanup
rm -rf $FLASH_DIR
rm -f $FLASH_NAME
if [ $RC -eq 0 ];
then
# scan for new plugins
( nspluginscan 2>/dev/null; echo "100" ) | $DIALOG --backtitle "$BT" --title "${T1/0/$N}" --gauge "$MESSAGE4" 10 60
else
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "${MESSAGE3/PATH/$FLASH_FILES}" 15 70 # error!
exit 1
fi
else # /tmp/$FLASH_NAME not found
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "${MESSAGE3/PATH//tmp/$FLASH_NAME}" 15 70 # error!
exit 1
fi
$DIALOG --backtitle "$BT" --title "$ST" --msgbox "$MESSAGE5" 10 60
else # non interactive
cd /tmp
if [ -n "$FLASH_PATH" ];
then
cp $FLASH_PATH/$FLASH_NAME /tmp
else
wget $FLASH_DL_PATH
fi
if [ -f /tmp/$FLASH_NAME ];
then
tar xzf $FLASH_NAME
cd $FLASH_DIR
mkdir -p /home/knoppix/.netscape/plugins/
mkdir -p /home/knoppix/.mozilla/plugins/
cp $FLASH_FILES /home/knoppix/.netscape/plugins/
cp $FLASH_FILES /home/knoppix/.mozilla/plugins/
cd ..
#cleanup
rm -rf $FLASH_DIR
rm -f $FLASH_NAME
# scan for new plugins
nspluginscan
else
echo "Error accessing /tmp/$FLASH_NAME"
exit 1
fi
fi
exit 0 # Success!