#!/bin/sh
#
# VIA RAID Management Software Uninstallation Script
# VIA Technologies Ltd.
#

# configure information
prefix_path=/usr/local
#module_path=/lib/modules/`uname -r`/misc

version_string=2.10
package_name=viaraid-$version_string

raidtoolbin=viaraid-gtk
raidtoolconf=viaraid.conf
#raidtoolmod=viasraid.o
raidtooldoc_path=/usr/share/doc/$package_name/

#check user permission
e_user=`whoami`

if [ $e_user != "root" ]; then
	echo "Root user required to uninstall VIA Raid Tool for Linux."
	exit 1
fi

# check if the program is running
pidof $raidtoolbin > /dev/null
if [ $? -eq 0 ] ; then
	echo "The software is running. Please stop it first."
	exit 1
fi 

#ask the prefix path
while true; do
echo -n "Please spceify the base directory you has installed the files. [/usr/local]"
read userinput
if [ "$userinput" = "" ]; then
	break
else
	prefix_path="$userinput"
	[ -d "$userinput" ] && break
fi
done

bin_path=${prefix_path}/bin


echo "Starting uninstall VIA Raid Tool for Linux, please wait..."

#uninstall binaries
rm -f ${bin_path}/${raidtoolbin}
#uninstall configuration file
rm -f /etc/${raidtoolconf}
#uninstall help document
rm -rf ${raidtooldoc_path}

echo
echo "VIA Raid Tool has been uninstalled successfully."
echo

