PATH=/usr/xpg4/bin:/usr/bin:/usr/sbin:/sbin
export PATH

ETCDIR=${PKG_INSTALL_ROOT}/etc

OSREL=`uname -r`
MAJOR=`echo $OSREL | cut -f1 -d.`
MINOR=`echo $OSREL | cut -f2 -d.`

if [ \( ${MAJOR} -lt 5 \) -o \( ${MAJOR} -eq 5 -a ${MINOR} -lt 10 \) ] ; then
	echo "This package is intended for Solaris 10 and better"
	echo "as well as OpenSolaris/Illumos derived distributions, only!"
	echo
	echo "Either upgarde your ancient OS or use the OpenDJ generic zip package."
	exit 3
fi

# check, whether the group ldapd exists
egrep -s '^ldapd:' ${ETCDIR}/group
if  [ $? -ne 0 ]; then
echo " 
WARNING:
  For security reason OpenDJ should be run as user with the group 'ldapd'.
  This group is not part of your ${ETCDIR}/group ! Please setup
  such an group! E.g. using:

	groupadd -g 109 ldapd
"
	BREAK="true"
fi

# check, whether a user ldapd exists
egrep -s '^ldapd:' ${ETCDIR}/passwd
if  [ $? -ne 0 ]; then
echo "
WARNING:
  For security reason OpenDJ should be run as user 'ldapd'.
  This user is not part of your ${ETCDIR}/passwd ! Please setup
  such an account! E.g.:

	useradd -c 'OpenDJ LDAP Server' -d /var/share/ldap/opendj \\
		-u 109 -g ldapd -s /bin/true ldapd
"
	BREAK="true"
fi

# scripts need ksh93
if [ ! -x ${PKG_INSTALL_ROOT}/bin/ksh93 ]; then
	echo "
ERROR:
  This package requires the AT&T Korn-Shell 93!
  In case you don't have a package, you can download a S10+ compatible
  version via http://dev.iws.cs.uni-magdeburg.de/lnf/i386/5.11/LNFksh93.pkg.gz
"
	BREAK="true"
fi
if [ "$BREAK" = "true" ]; then
	exit 3
fi

if [ ! -d ${PKG_INSTALL_ROOT}/lib/svc/manifest ]; then
	# S10
	echo "SVCDIR=var" >>$1
else
	echo "SVCDIR=lib" >>$1
fi
if [ ! -d ${PKG_INSTALL_ROOT}/etc/security/exec_attr.d ]; then
	# old RBAC
	echo "CLASSES=$CLASSES rbac" >>$1
else
	echo "CLASSES=$CLASSES rbac2" >>$1
fi

exit 0
