#!/bin/bash
######################################################
# install_hpltt -  "hp Library & Tape Tools"
######################################################
#
# Please do not edit this file. Generated Automatically
# 
# This script is used to install hp Library & Tape Tools
# The valid exit values are:
#    - 0 --> no problems encountered
#    - 1 --> there was a fatal error encountered
######################################################
# check whether user has passed '-force- option.If yes, handle it properly
if [ "$1" = "-force" ]
then
if [ -n "$2" ]
then
echo "Invaild options passed for the 'install_hpltt' script"
echo "Usage:"
echo "1) install_hpltt -force"
echo "2) install_hpltt"
exit 1
fi
rpm -ivh ltt-4.20.0.0-4.i386.rpm --nopre
unzip jre.zip 
cp -R ./jre  /opt/ltt/
chmod 777 /opt/ltt/jre/bin/java
rm -rf jre
rm -rf jre.zip
else
if [ -n "$1" ]
then
echo "Invaild options passed for the 'install_hpltt' script"
echo "Usage:"
echo "1) install_hpltt -force"
echo "2) install_hpltt"
exit 1
fi
rpm -ivh ltt-4.20.0.0-4.i386.rpm
unzip jre.zip 
cp -R ./jre /opt/ltt/
chmod 777 /opt/ltt/jre/bin/java
rm -rf jre
rm -rf jre.zip
fi
if [ $? -eq 0 ]
then
pdir=${PWD}
cd $pdir
echo "<?xml version=\"1.0\"?>" > setuplog.xml
echo "<!DOCTYPE Root [<!ELEMENT Root (ReleaseVersion,InstallLocation)> <!ELEMENT ReleaseVersion (#PCDATA)> <!ELEMENT InstallLocation (#PCDATA)> ]>" >> setuplog.xml
echo "<Root>" >> setuplog.xml
echo "<ReleaseVersion> 4.20.0.0 </ReleaseVersion>" >> setuplog.xml
echo "<InstallLocation> /opt/ltt/hp_ltt </InstallLocation>" >> setuplog.xml
echo "</Root>" >> setuplog.xml
chown -R root:sys /opt/ltt
exit 0
else
exit 1
fi
