#!/bin/sh
# $NetBSD: script,v 1.2 2004/03/09 20:06:42 garbled Exp $

if [ -n "$6" ]; then
	CTIME=`date +%s`
	EXPIRE=`expr $6 \* 24 \* 60 \* 60 + $CTIME`
	EXPIRE=`echo "-e $EXPIRE"`
fi
if [ -z $5 ]; then
	if [ -r "/etc/usermgmt.conf" ]; then
		BASE=`grep base_dir /etc/usermgmt.conf | awk '{print $2}'`
	fi
	if [ -n "$BASE" ]; then
		HOME=`echo "${BASE}/${1}"`
	else
		HOME=`echo "/home/${1}"`
	fi
else
	HOME=$5
fi
if [ -z $8 ]; then
	UID=""
else
	UID="-u $8"
fi
if [ $3 != "NONE" ]; then
	SG="-G $3"
fi
useradd $SG $UID -c "$4" -d $HOME $EXPIRE -g $2 -m -s $7 -v $1
if [ $? -eq 0 ]; then
	echo "User $1 successfully created"
fi
