#!/bin/sh
# rds 01 June 2007
# Script to  install Application Server License Management Software.                          
test `uname -s` = Linux && echocmd="echo -e" || echocmd="echo"

$echocmd "To run your applications in a production environment"
$echocmd "you need a deployment license installed using Apptrack." 
$echocmd "See your Deployment Licensing Guide for details."
$echocmd "Installing Apptrack...\n"

if test ! -w /etc/passwd
then
	$echocmd "You must be running as root to execute this script"
	exit 1
fi

if test "$COBDIR." = "."
then
	$echocmd "You must set the environment variable COBDIR to point to the product directory to execute this script"
	exit 1
fi

HERE=`pwd`
if test "$COBDIR." != "$HERE."
then
	$echocmd "You must be running from current COBDIR directory to execute this script"
	exit 1
fi

set +u

unset COBPATH
unset COBDATA
unset COBSW

LIBPATH=$COBDIR/lib:$LIBPATH:/lib
export LIBPATH


./aslmf/initaslm

chown root ./aslmf/aslmupdb
chmod 4755 ./aslmf/aslmupdb

chown root ./aslmf/aslmrmshm
chmod 4755 ./aslmf/aslmrmshm

touch /var/mfaslmf/USERLOG
chmod 666 /var/mfaslmf/USERLOG

if test ! -f /var/mfaslmf/nolicense
then
if test -f ./aslmf/nolicense
then
	cp ./aslmf/nolicense /var/mfaslmf
fi
fi	

if test -f /var/mfaslmf/nolicense
then
chmod 755 /var/mfaslmf/nolicense
fi

if test ! -f /var/mfaslmf/watermark
then
if test -f ./aslmf/watermark
then
	cp ./aslmf/watermark /var/mfaslmf
fi
fi

if test -f /var/mfaslmf/watermark
then
chmod 755 /var/mfaslmf/watermark
fi

if test -f ./aslmf/LMFOPTPLATFORM
then
	cp ./aslmf/LMFOPTPLATFORM /var/mfaslmf
fi	

if test ! -f /var/mfaslmf/aslmodf
then
if test -f ./aslmf/aslmodf
then
	cp ./aslmf/aslmodf /var/mfaslmf
	chmod 766 /var/mfaslmf/aslmodf
fi
fi	

./aslmf/init2aslm

if test -f /var/mfaslmf/LMFOPTPLATFORM
then
chmod 444 /var/mfaslmf/LMFOPTPLATFORM
fi

chmod 644 ./aslmf/userstat.gnt

chmod 755 /var/mfaslmf
 
$echocmd "Access permissions on directory /var/mfaslmf have changed on this release"
$echocmd "Write access permission has been removed except for superuser use"

$echocmd "Apptrack installation complete\n"
exit 0
