#!/bin/sh
# UFS Explorer Standard Recovery version 4.5 basic installer script.
# Copyright (c) 2010 LLC SysDev Laboratories

set -e
echo "UFS Explorer Standard Recovery version 4.5 basic installer script."
echo "Copyright (c) 2010 LLC SysDev Laboratories"

echo "Testing for compatibility..."
./src/ufsxsci --test
if [ "$?" -ne 0 ]; then
 exit 1
fi
echo "OK"

echo "Installing UFS Explorer..."
if [ -x "`which ufsxsci 2>/dev/null`" ]; then
 echo "UFS Explorer is already installed"
else
echo "`cp ./src/ufsxsci /usr/bin/ufsxsci 2>/dev/null`"
if [ -x "`which ufsxsci 2>/dev/null`" ]; then
 mkdir /usr/share/doc/ufsxsci/	
 cp ./src/AUTHORS /usr/share/doc/ufsxsci/AUTHORS
 cp ./src/BUGS /usr/share/doc/ufsxsci/BUGS
 cp ./src/copyright /usr/share/doc/ufsxsci/copyright
 cp ./src/EULA.htm /usr/share/doc/ufsxsci/EULA.htm
 cp ./src/manual.htm /usr/share/doc/ufsxsci/manual.htm
 cp -r ./src/content/ /usr/share/doc/ufsxsci/content/

 mkdir /usr/lib/ufsxsci
 mkdir /usr/lib/ufsxsci/plugins
 cp ./src/*.ciso /usr/lib/ufsxsci/plugins/
 mkdir /usr/lib/ufsxsci/sig/
 cp ./src/*.urrs /usr/lib/ufsxsci/sig/

 cp ./src/ufsxsci.xpm /usr/local/share/pixmaps/ufsxsci.xpm
 cp ./src/*.desktop /usr/local/share/applications/

 if [ -x "`which update-menus 2>/dev/null`" ]; then
	update-menus
 fi
 echo "UFS Explorer was installed successfully. You may run the software as 'ufsxsci'. To access local drives, run the software as 'root' (e.g. 'kdesu ufsxsci')"
else
 echo "Unable to install UFS Explorer. Please re-run the script with root privilegues (e.g. 'sudo ./install' or 'su root -c ./install')"
fi
fi
