#!/bin/sh
# Simple System-checker to ensure everything is correct set up
# for X-CD-Roast.
# 18.6.96 T.Niederreiter

if [ "$DISPLAY" = "" ]; then
	echo "Please start X-Windows for the system-check."
	exit
fi

echo "-----------------------------"
echo "X-CD-Roast 0.95c System-Check"
echo "-----------------------------"
echo "If you fail any test, please investigate the problem!"
echo "-----------------------------"
echo

echo "Checking Kernel Version:"
echo
kversion=`uname -r`
k1=`echo $kversion |cut -d "." -f 1`
k2=`echo $kversion |cut -d "." -f 2`
k3=`echo $kversion |cut -d "." -f 3`
kcode=`expr $k1 \* 10000 + $k2 \* 100 + $k3`

echo -n "Found: $kversion, Need at least 1.99.6 : "
if [ $kcode -gt "19906" ]; then
	echo "Ok"
else
	echo "Not Ok - please upgrade!"
fi
echo
echo "----------------------------"
echo
echo "Checking SCSI-CD-Rom-Devices:"
echo
sr0=`ls /dev/sr0 2>/dev/null`
sr1=`ls /dev/sr1 2>/dev/null`
if [ "$sr0" = "" ]; then
	echo "/dev/sr0 not found"
else
	echo "/dev/sr0 found: OK"
fi
if [ "$sr1" = "" ]; then
	echo "/dev/sr1 not found"
else
	echo "/dev/sr1 found: OK"
fi
if [ "$sr1" = "" -o "$sr0" = "" ]; then
	echo "Please create the /dev/sr-Devices! (See README)"
fi

echo
echo "<press enter to continue>"
read
echo "----------------------------"
echo
echo "Checking TCL/TK/Tix-Versions (Please wait):"
echo
if [ -x bin/etixwish ]; then
	echo
	echo "Using precompiled etixwish. (recommended)"
	echo
	echo "System-check complete."
	exit
fi
type tixwish >/dev/null 2>/dev/null
if [ $? = 1 ]; then
	echo
	echo "tixwish not found! Please install tixwish and put it in your path!"
	echo 
	exit
else
	echo "puts \$tcl_patchLevel" >/tmp/SySTeSt
	echo "exit" >>/tmp/SySTeSt
	Tclversion=`tixwish -f /tmp/SySTeSt`
	echo "puts \$tk_patchLevel" >/tmp/SySTeSt
	echo "exit" >>/tmp/SySTeSt
	Tkversion=`tixwish -f /tmp/SySTeSt`
	echo "puts \$tix_patchLevel" >/tmp/SySTeSt
	echo "exit" >>/tmp/SySTeSt
	Tixversion=`tixwish -f /tmp/SySTeSt`
	echo "Tcl-Version $Tclversion (is this at least 7.4?)"
	echo "Tk-Version  $Tkversion (is this at least 4.0?)"
	echo "Tix-Version $Tixversion (is this at least 4.0?)"
	echo
	echo "**** Please check yourself if the versions-numbers are ok."
	echo "**** An automatically check is due the strange version-"
	echo "**** numbers of Tcl not possible."
	echo 
	echo "<press enter to continue>"
	read
	echo "------------------------"
	echo
	echo "Checking for tixwish-bug: "
	echo
	echo " Now a window should pop up with a little square and a button"
	echo " labeled \"Quit\" under it."
	echo
	echo " If the square is missing and you got an error-message, we have"
	echo " a problem - upgrade/downgrade your Tcl/Tk/Tix-Versions."
	echo
	echo " Note: A few Tcl/Tk/Tix-Kombinations are broken, even if all"
	echo "       have a version-number high enough. This case is nevertheless"
	echo "       very rare."

	echo 
	echo "<press \"Quit\"-button to continue>"

	echo "tixLabelFrame .b; pack .b" >/tmp/SySTeSt
	echo "button .q -text Quit -command "exit"; pack .q" >>/tmp/SySTeSt

	tixwish -f /tmp/SySTeSt
	rm -f /tmp/SySTeSt
fi
echo
echo "----------------------------"
echo
echo "System-check complete"
echo
echo " Note: This check looked only for the most common problems, if you "
echo "       passed all test, you can still run into troubles with other"
echo "       Tcl/Tk/Tix-Versions. Consult the README if you think that "
echo "       some things look weired."
echo
 
