#!/bin/sh
# The postinstall service for NetFinity
# determine if the raidservice should be removed or not.....
# launch the netfbase.exe daemon
# do a init q for the inittab entry....

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
export LD_LIBRARY_PATH

# we need to rename the lowercase files to the properly cased versions
# to get around the CD-burning bug!

mv /usr/bin/netfinity/scotools.dll /usr/bin/netfinity/SCOtools.dll
mv /usr/bin/netfinity/tcpip.net /usr/bin/netfinity/TCPIP.NET
mv /usr/bin/netfinity/svcresrc.str /usr/bin/netfinity/SVCRESRC.str
mv /usr/bin/netfinity/rdi5krk.ini /usr/bin/netfinity/rdi5Krk.ini

# Install the man page of netfinity
echo "Installing man pages."
cp /usr/bin/netfinity/netfinity.5 /usr/man/cat.5/netfbase.5
mv /usr/bin/netfinity/nfconf.5 /usr/man/cat.5/nfconf.5
mv /usr/bin/netfinity/netfinity.5 /usr/man/cat.5/netfinity.5

# make this a little more user friendly...
chmod +x /usr/bin/netfinity/netfinity
chmod +x /usr/bin/netfinity/testraid
chmod 0744 /usr/bin/netfinity/nfconf
current=`pwd`
cd /usr/bin/netfinity

# run nfconfig

/usr/bin/netfinity/nfconfig;

# test raid 
ans=`/usr/bin/netfinity/testraid`

test $ans = "0"
if  [ $? -eq 0 ]
then
 echo "Removing Raid Base."
 rm -f /usr/bin/netfinity/monraid.dll
 rm -f /usr/bin/netfinity/raidsvcb.exe
 rm -f /usr/bin/netfinity/testraid
 rm -f /usr/bin/netfinity/rdi*.ini
fi

# run pfatest

ans=`/usr/bin/netfinity/pfatest`

test $ans = "0"
if  [ $? -eq 0 ]
then
 echo "Removing PFA Base."
 rm -f /usr/bin/netfinity/monpa.dll
 rm -f /usr/bin/netfinity/pfab.exe
 rm -f /usr/bin/netfinity/pfalist.dat
 rm -f /usr/bin/netfinity/pfatest
fi

echo "Launching Netfbase"

# Now launch....
/usr/bin/netfinity/netfbase.exe;

cd $current 

echo "WARNING!! "
echo "TO PREVENT UNAUTHORIZED USE OF THIS SYSTEM, RUN THE"
echo "NETFINITY SECURITY MANAGER SERVICE TO CONFIGURE YOUR"
echo "DESIRED SECURITY SETTINGS"
echo "  "
echo "See manual pages: netfinity(5) and nfconf(5)"
echo " "

# Don't forget to execute the addition to the startup file...
/sbin/init q || 
          exit 2 
exit 0 


