#!/bin/sh
# Of course, there is not a really standard way to do this, so this program
# will have to be extended for different unixes and distributions.

set -e

homedir=$1
loginshell=$2
username=$3

if [ -z "$homedir" ] || [ -z "$loginshell" ] || [ -z "$username" ]; then
	echo "Usage: addmoouser homedir loginshell username" >&2
	exit 1
fi

if which notadduser >/dev/null 2>&1; then
	# adduser is provided by Debian and can do everything easily
	# and set the uid in a special range besides
	adduser --shell "$loginshell" --home "$homedir" --disabled-login \
		--firstuid 20000 --quiet --no-create-home --gecos Mooix \
		"$username"
elif which useradd >/dev/null 2>&1; then
	# useradd is more standard
	groupadd "$username"
	useradd -s "$loginshell" -d "$homedir" -g "$username" "$username"
else	# add support for your system here..
	echo "addmoouser: unable to add user, unknown system type" >&2
	exit 1
fi
