#!/bin/bash

echo "At first run this script will configure your gish,"
echo "then you'll have to rerun this script only if"
echo "the script ./gishsound doesnt works fine."
echo ""
echo "LGPL licensed (include wherever you want)"

ISOK2="x"
echo "do you want to (re)configure openal sound per-user? (y/n)"
echo "note, this is highly suggested in case of segfaults"
read ISOK2
if [ "x$ISOK2" == "xy" ] ;then
	sh openalconf.sh
fi

LOCATE=`which locate`
if [ "x$LOCATE" == "x" ] ;then
	echo "no locate found!"
	echo "you need to manually insert some files location"
	echo "give me full path of libalut.so"
	read ALUT
	echo "give me full path of openal.so"
	read OPENAL
	echo "give me full path of libogg.so"
	read OGG
	echo "give me full path of libvorbis.so"
	read VORBIS
else
	ALUT=`locate -r "/usr.*libalut.so$"`
	OPENAL=`locate -r "/usr.*openal.so$"`
	OGG=`locate -r "/usr.*libogg.so$"`
	VORBIS=`locate -r "/usr.*libvorbis.so$"`
fi

echo "LD_PRELOAD=\"$ALUT:$OPENAL:$OGG:$VORBIS\" ./gish -sound" > gishsound.sh
chmod u+x gishsound.sh
echo "from now on, type ./gishsound.sh to start gish"

