#!/bin/sh # /etc/init.d/javaif.sh # Derived from /etc/init.d/java.sfs.sh in java-sfs.sh by Uten #set -x #DEBUG test $1 || exit setvar ARGUMENT = "$1" proc update_configuration { setvar JAVAHOME = "$(javaiffind)" local UPDATECONFIG=false if test $JAVAHOME { if test -d "$JAVAHOME/jre" { #JDK setvar JREHOME = ""$JAVAHOME/jre"" } else { setvar JREHOME = "$JAVAHOME" } setvar JAVAVERSION = "$($JAVAHOME/bin/java -version 2>&1 | grep 'version' | cut -f3 -d ' ' | tr -d '\"')" if test "$JREHOME $JAVAVERSION" != "$PREVJREHOME $PREVVERSION" { local UPDATECONFIG=true } } else { setvar JREHOME = '''' setvar JAVAVERSION = '''' if test $PREVJAVAHOME -o $PREVJREHOME -o $PREVVERSION { local UPDATECONFIG=true } } if test $UPDATECONFIG = true { setvar SEDSCRIPT1 = ""/JAVAHOME=/ s%=.*%=${JAVAHOME}%"" setvar SEDSCRIPT2 = ""/JREHOME=/ s%=.*%=${JREHOME}%"" setvar SEDSCRIPT3 = ""/JAVAVERSION=/ s%=.*%=${JAVAVERSION}%"" sed -i -e $SEDSCRIPT1 -e $SEDSCRIPT2 -e $SEDSCRIPT3 /etc/javaif.conf } } proc add_plugin_links { for ONEBROWSER in $BROWSERS { if test -d /usr/lib/$ONEBROWSER { for ONEPLUGIN in $BROWSERPLUGINS { mkdir -p /usr/lib/$ONEBROWSER/plugins if test -f $JREHOME/lib/i386/$ONEPLUGIN { ln -sf $JREHOME/lib/i386/$ONEPLUGIN /usr/lib/$ONEBROWSER/plugins/$(basename $ONEPLUGIN) } } } } } proc remove_plugin_links { for ONEBROWSER in $BROWSERS { if test -d /usr/lib/$ONEBROWSER { for ONEPLUGIN in $BROWSERPLUGINS { if test -d /usr/lib/$ONEBROWSER/plugins { rm -f /usr/lib/$ONEBROWSER/plugins/$(basename $ONEPLUGIN) } } } } } proc add_icon_links { for ONEIMAGE in $IMAGES { if test -f $JREHOME/lib/images/icons/$ONEIMAGE { ln -sf $JREHOME/lib/images/icons/$ONEIMAGE /usr/share/pixmaps/ } } for ONEMAINICON in $MAINICONS { if test -f $JREHOME/lib/desktop/icons/hicolor/16x16/apps/$ONEMAINICON { ln -sf $JREHOME/lib/desktop/icons/hicolor/16x16/apps/$ONEMAINICON /usr/local/lib/X11/mini-icons/ } } for ONEMIMEICON in $MIMEICONS { if test $ROXMIMEPATH -a -f $JREHOME/lib/desktop/icons/hicolor/48x48/mimetypes/gnome-mime-$ONEMIMEICON { ln -sf $JREHOME/lib/desktop/icons/hicolor/48x48/mimetypes/gnome-mime-$ONEMIMEICON $ROXMIMEPATH/$ONEMIMEICON } } for ONEGROUP in hicolor HighContrast HighContrastInverse LowContrast { if test -d $JREHOME/lib/desktop/icons/$ONEGROUP { mkdir -p /usr/share/icons/$ONEGROUP/16x16/apps mkdir -p /usr/share/icons/$ONEGROUP/48x48/apps for ONEMAINICON in $MAINICONS { if test -f $JREHOME/lib/desktop/icons/$ONEGROUP/16x16/apps/$ONEMAINICON { ln -sf $JREHOME/lib/desktop/icons/$ONEGROUP/16x16/apps/$ONEMAINICON /usr/share/icons/$ONEGROUP/16x16/apps/ } if test -f $JREHOME/lib/desktop/icons/$ONEGROUP/48x48/apps/$ONEMAINICON { ln -sf $JREHOME/lib/desktop/icons/$ONEGROUP/48x48/apps/$ONEMAINICON /usr/share/icons/$ONEGROUP/48x48/apps/ } } mkdir -p /usr/share/icons/$ONEGROUP/16x16/mimetypes mkdir -p /usr/share/icons/$ONEGROUP/48x48/mimetypes for ONEMIMEICON in $MIMEICONS { if test -f $JREHOME/lib/desktop/icons/$ONEGROUP/16x16/mimetypes/gnome-mime-$ONEMIMEICON { ln -sf $JREHOME/lib/desktop/icons/$ONEGROUP/16x16/mimetypes/gnome-mime-$ONEMIMEICON /usr/share/icons/$ONEGROUP/16x16/mimetypes/ } if test -f $JREHOME/lib/desktop/icons/$ONEGROUP/48x48/mimetypes/gnome-mime-$ONEMIMEICON { ln -sf $JREHOME/lib/desktop/icons/$ONEGROUP/48x48/mimetypes/gnome-mime-$ONEMIMEICON /usr/share/icons/$ONEGROUP/48x48/mimetypes/ } } } } } proc remove_icon_links { for ONEIMAGE in $IMAGES { rm -f /usr/share/pixmaps/$ONEIMAGE } for ONEMAINICON in $MAINICONS { rm -f /usr/local/lib/X11/mini-icons/$ONEMAINICON } for ONEMIMEICON in $MIMEICONS { test $ROXMIMEPATH && rm -f $ROXMIMEPATH/$ONEMIMEICON } for ONEGROUP in hicolor HighContrast HighContrastInverse LowContrast { for ONEMAINICON in $MAINICONS { rm -f /usr/share/icons/$ONEGROUP/16x16/apps/$ONEMAINICON rm -f /usr/share/icons/$ONEGROUP/48x48/apps/$ONEMAINICON } for ONEMIMEICON in $MIMEICONS { rm -f /usr/share/icons/$ONEGROUP/16x16/mimetypes/gnome-mime-$ONEMIMEICON rm -f /usr/share/icons/$ONEGROUP/48x48/mimetypes/gnome-mime-$ONEMIMEICON } } } case (ARGUMENT) { start|change { setvar BROWSERS = ''''; setvar BROWSERPLUGINS = '''' setvar IMAGES = ''''; setvar MAINICONS = ''''; setvar MIMEICONS = '''' source /etc/javaif.conf setvar PREVJAVAHOME = "$JAVAHOME" setvar PREVJREHOME = "$JREHOME" setvar PREVVERSION = "$JAVAVERSION" setvar FORCEEXECPATH = 'false' setvar ROXMIMEPATH = $(find /usr -maxdepth 5 -name "MIME" | grep -m 1 'ROX-Filer') update_configuration if test $JAVAHOME { if test $PREVJREHOME { remove_plugin_links remove_icon_links } add_plugin_links add_icon_links # Remove possible conflicting override links & script from PET/SFS package for ONEEXEC in java javac javaws jcontrol jjs { rm -f /usr/bin/$ONEEXEC } rm -f /etc/init.d/java.sfs.sh # possible conflicting init scripts rm -f etc/init.d/java } else { remove_plugin_links remove_icon_links } } }