#!/bin/bash
rvpl_inst_mime='install-mime --install --package=rvplayer \
	--content=audio/x-pn-realaudio \
	--test="test \"\$DISPLAY\" != \"\"" \
	--view="rvplayer %s" --quiet
'
oIFS=$IFS
if [ -x /usr/sbin/install-mime ];then
	rvpl_mime=`/usr/sbin/install-mime --list --content=audio/x-pn-realaudio 2>/dev/null `
	if [ -z "$rvpl_mime" ];then
		echo "There is no player listed for mime type 'audio/x-pn-realaudio', ie Real Audio."
		echo
		rvpl_info=`dpkg -l rvplayer|egrep -v "^(Desired|\| Status|\|/ Err|\|\|/ Name|\+\+\+\-)"|cut -b "1,2"`
		rvpl_desired=`echo $rvpl_info|cut -b 1`
		rvpl_status=`echo $rvpl_info|cut -b 2`
		if [ "$rvpl_desired" = "i" ];then
			echo -n "rvplayer is listed for installation"
			if [ "$rvpl_status" != "i" ];then
				echo ", but is not configured yet."
				echo "Not running install-mime."
			else
				echo ", and is already configured."
				echo "This is an error!"
				echo
				rvpl_test_inst=y
			fi
		else
			echo "rvplayer is *NOT* listed for installation"
			rvpl_exe=`which rvplayer`
			if [ -z "$rvpl_exe" ];then
				IFS=''
				cat <<_EOM_
There is no rvplayer on the path.
To hear Real Audio, please install rvplayer, preferably with
 the debian installer.
If you install it manually, then please run the following line:

$rvpl_inst_mime
_EOM_
				IFS=$oIFS
				read -p "Please press enter to continue. "
			else
				rvpl_test_inst=y
			fi
		fi
	fi
fi
if [ "$rvpl_test_inst" = "y" ];then
	while :;do
		read -p "Do you wish me to install a mime type for Real Audio? (Y/n/h)" ANS
		if [ -z "$ANS" ];then
			ANS=y
		fi
		case $ANS in
			Y*|y*)
				echo -n "Installing mime type for Real Audio..."
				eval $rvpl_inst_mime
				echo "done"
				break;;
			N*|n*)
				echo "As you wish."
				break;;
			H*|h*)
				IFS=''
				cat << _EOM_

Mime types are used by various programs to run 'players' for
different data types.  They are used extensively on the web.

In order for Netscape to play Real Audio data, there has to
be an entry for audio/x-pn-realaudio in the mime database.
If you answer 'y', then one will be installed.

This is the command that will be run:

$rvpl_inst_mime
_EOM_
				IFS=$oIFS
				read -p "Please press enter to continue"
				;;
		esac
	done
fi
