#!/bin/sh -e
# Creates new user account and prepares Homeros environment in newly created home directory
# Michael Pozhidaev <msp@altlinux.org>
# Date: 2011-04-06

THIS="${0##*/}"

if [ -z "$1" ]; then
    echo "$THIS:new user account name is not specified" >&2
    exit 1;
fi

if [ "$1" == '--help' ]; then
cat <<EOF
$THIS: the utility to create and prepare new user account with Homeros settings
Usage: $THIS [--help] [new_user_account_name]
NOTE: This utility does not set any password for newly created account. Use passwd command after $THIS invocation.
EOF
    exit 0
fi

/usr/sbin/useradd -m -k /etc/skel.homeros "$1"
eval "NEWDIR=~$1"
/usr/bin/homeros-prepare-user-home "$NEWDIR"
/bin/chown -R "$1:$1" "$NEWDIR"
