#!/bin/sh
set -e


getent group glite >/dev/null || addgroup --system glite

# sanitize passwd entry if it exists
PWENTRY=`getent passwd glite` || :
if [ "x$PWENTRY" != "x" ]
then 
    # we need a valid shell
    case $PWENTRY in
	*:/bin/false)
	userdel glite
	getent group glite >/dev/null || addgroup --system glite
	adduser --system --group --home /var/lib/glite --shell /bin/sh --disabled-password glite
	;;
    esac
else 
	adduser --system --group --home /var/lib/glite --shell /bin/sh --disabled-password glite
fi

mkdir -p /var/lib/glite /var/run/glite /var/spool/glite/lb-locallogger /var/spool/glite/lb-notif /var/spool/glite/lb-proxy 2>/dev/null || :
chown -R glite:glite /var/lib/glite /var/run/glite /var/spool/glite/lb-locallogger /var/spool/glite/lb-notif /var/spool/glite/lb-proxy

#DEBHELPER#
