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

ETCDIR=${PKG_INSTALL_ROOT}/etc
BREAK=''

# check for groups: dovecot, dovenull
MSG=''
egrep -s '^dovecot:' ${ETCDIR}/group
if  [ $? -ne 0 ]; then
	MSG='\tgroupadd -g 43 dovecot\n'
fi
egrep -s '^dovenull:' ${ETCDIR}/group
if  [ $? -ne 0 ]; then
	MSG="${MSG}\tgroupadd -g 44 dovenull\n"
fi

# check for users: dovecot, dovenull
egrep -s '^dovecot:' ${ETCDIR}/passwd
if  [ $? -ne 0 ]; then
	MSG="${MSG}\tuseradd -c 'Dovecot Internal' -d /var/dovecot \\ "
	MSG="${MSG}\n\t\t-u 43 -g dovecot -s /bin/true dovecot\n"
fi
egrep -s '^dovenull:' ${ETCDIR}/passwd
if  [ $? -ne 0 ]; then
	MSG="${MSG}\tuseradd -c 'Dovecot Auth Helpers' -d /var/dovecot \\ "
	MSG="${MSG}\n\t\t-u 44 -g dovenull -s /bin/true dovenull\n"
fi

if [ -n  "${MSG}" ]; then
	print '
WARNING:
  For security reasons Dovecot requires to accounts: One for login processes
  (per default account "dovenull" having group "dovenull") and one for doing
  unprivileged work (per default account "dovecot" having group "dovecot"). 
  At least one account or group is missing. Either add it to the system or
  adjust /etc/dovecot/conf.d/10-master.conf properly before starting the
  dovecot service. E.g.:

'"${MSG}"'
  For more information see: http://wiki2.dovecot.org/UserIds
'
	BREAK="true"
fi

#if [ "$BREAK" = "true" ]; then
#	exit 3
#fi

exit 0
