#
# Preinstall Scriptlet used by RPM mvn plugin to do preinstall checks and actions.
#
# Here we are checking if an oracle user exists, and if it doesnt, create it.
#
DESC="The Oracle Software Owner User"

#Check oinstall exists 
getent group oinstall &>/dev/null || groupadd -f -g 54321 oinstall 

#Check user exists
getent passwd oracle &>/dev/null 

if [ $? -ne 0 ];
then 
  #user doesnt exist, check for 54321
  getent passwd 54321 &>/dev/null
  if [ $? -ne 0 ];
  then
    useradd -u 54321 -g oinstall -c "${DESC}" oracle
  else
    useradd -g oinstall -c   "${DESC}" oracle
  fi 
fi