#! /bin/bash
# $Header: /global/src/etc/cl-manage-scripts/patches/RCS/P-firefox-jdk,v 1.4 2010/10/21 05:32:49 pb22 Exp $
#
# Command to create /usr/lib/firefox-1.5.0.2/plugins/libjavaplugin_oji.so
# Called with a single argument, the file to be edited
#
###atch-file #ilename = /usr/lib/firefox-1.5.0.2/plugins/libjavaplugin_oji.so
# patch-file operation = shell
# patch-file distmatches = Fedora|CentOS|Red.Hat.Enterprise.Linux
# patch-file fileexists = /usr/lib/firefox-1.5.0.2/plugins/libjavaplugin_oji.so

plugin=libjavaplugin_oji.so
files="`echo /usr/java/*/plugin/i386/ns7/libjavaplugin_oji.so /usr/java/*/jre/plugin/i386/ns7/libjavaplugin_oji.so`"
dirs="`echo  /usr/lib/firefox*/plugins/.`"
want=
got=

for	dir in $dirs
do	test -r $dir/$plugin || want="$want $dir"
done

for	file in $files
do	test -r $file && got=$file
done

case "$want" in '') exit 0;; esac

# TODO: check that there just isn't a jdk to use ...
case "$got" in '') exit 0;; esac
# Alternative - having checked that it should have worked, complain
case "$got" in '') echo $0: no $files found 1>&2; exit 1;; esac

echo "Need to fix $want"

for	dir in $want
do	ln -svf $got $dir
	ls -ld $dir/$plugin
	ls -lLd $dir/$plugin
done
