#!/bin/bash
#determine safe uid/gid
WILDFIRE_USER=`nireport / /users name | grep "wildfire"`

WILDFIRE_GID=`nireport / /users gid | sort -n | egrep -v "\b[5-9][0-9]{2,5}\b" | tail -n 1`
let "WILDFIRE_GID=$WILDFIRE_GID+1"
echo $WILDFIRE_GID > /private/tmp/wildfiregid

if [ -z $WILDFIRE_USER] ; then
	WILDFIRE_UID=`nireport / /users uid | sort -n | egrep -v "\b[5-9][0-9]{2,5}\b" | tail -n 1`
	let "WILDFIRE_UID=$WILDFIRE_UID+1"
	echo $WILDFIRE_UID

	#create user
	niutil -create . /users/wildfire
	
	#set properties
	niutil -createprop . /users/wildfire gid $WILDFIRE_GID
	niutil -createprop . /users/wildfire uid $WILDFIRE_UID
	niutil -createprop . /users/wildfire shell /usr/bin/false
	niutil -createprop . /users/wildfire home /usr/local/wildfire/
	niutil -createprop . /users/wildfire realname "Jive Wildfire"
	niutil -createprop . /users/wildfire passwd '*'
fi