#!/bin/sh

#
# XMMS plugin installation script
#
# Copyright (C)2001 4Front Technologies
#

product="OSS/3D for XMMS plugin 5.5.1"
myfile="libxmoss3d.so"
mypath=`echo -n $0 | sed -e 's/\/xminstall.sh//'`
p=""

cd "$mypath"

if test -e "$myfile"; then
    echo "$product installation."
    echo "Copyright (C)2001 4Front Technologies"
    echo ""
    echo "If you are running now XMMS, please quit it before pressing ENTER."
    echo "PRESS ENTER TO READ LICENSE AGREEMENT..."
    read    
else
    echo "Unable to find $myfile in directory '$mypath'"
    echo "Please, get original installation from 4Front Techonologies"
    echo ""
    echo "PLEASE ENTER TO ABORT"
    read
    exit 1
fi


if test -e "LICENSE"; then
    cat LICENSE | more
    echo ""
    echo "PLEASE ENTER IF YOU ACCEPT LICENSE AGREEMENT AND CTRL-C OTHERWISE"    
    read
else
    echo "LICENSE AGREEMENT not found!"
    echo ""
    echo "Please, get original installation from 4Front Techonologies"    
    echo "PLEASE ENTER TO ABORT"
    read
    exit 1
fi

for t in /opt/kde2/bin          \
         /sbin                  \
	 /usr/sbin              \
	 /usr/local/sbin        \
	 $HOME/bin              \
	 /usr/local/bin         \
	 /usr/bin               \
	 /usr/X11R6/bin         \
	 /bin                   \
	 /usr/lib/java/bin      \
	 /usr/games/bin         \
	 /usr/games             \
	 /opt/gnome/bin         \
	 /opt/kde/bin           \
	 /usr/gnome/bin         \
	 /usr/kde/bin           \
	 /usr/kde2/bin          \
	 /usr/local/gnome/bin   \
	 ; do

    if test -x $t/xmms-config; then
        p=$t/xmms-config
    fi
done

h=$HOME/.xmms/Plugins

if test -n "$p"; then
    i=`$p --effect-plugin-dir`
else
    i=$h
fi

if test `whoami` = root; then
    f=$i/$myfile
else    
    f=$h/$myfile
fi

if test -e $f; then
    echo -n "Removing existing copy... "
    rm $f

    if test -e $f; then
        echo "unable to delete $f!"
        echo "Possibly you don't have enough previleges to install plugin."
        echo "Try copying $myfile file manually to $f"
        exit 1
    fi
    echo "$f removed"
fi


echo -n "Copying plugin file... "

if test `cp $myfile $f >/dev/null 2>/dev/null`; then
    echo "error copying $myfile to $f"
else
    echo "ok"
fi

if test -e $f; then
    echo "Installation completed!"
    echo "Plugin installed to $f"
    echo ""    
else
    echo "Error installing plugin"
    echo "(Possibly unable to detect XMMS installation or cannot write to dest. file)"
    echo "Try copying $myfile file manually to YOURXMMSDIRECTORY/Effect/$myfile"
    echo ""
fi
