#!/bin/sh
# ####################################################################
# Exceed Connection Server 13.7
# Copyright (c) 1997-2009 Open Text Corporation. All Rights Reserved.
# ####################################################################
# admin
# $Revision: 13974 $
# #################################################################### 
. sys/msg.txt

pre="    "

if [ "${1}xxxx" = "xxxx" ]; then
        echo "${pre}${USAGE}: $0 $LOGFILE_ARG"
        exit 1
else
        logfile=$1
fi

${ECHO} "${pre}${ADMIN_ENTER_UNAME1}"

# get the name
read uname
if [ "${uname}xxx" = "xxx" ]; then
	uname="root"
fi

confpath="../conf"

# create the dir
userspath="${confpath}/users"

upath="${userspath}/${uname}"
mkdir "${upath}" > /dev/null 2>&1 ||true
if [ ! -d "${upath}" ] ; then
	${ECHO} "$FATAL $ADMIN_BAD_DIR ${upath}" >> $logfile
	${ECHO} "${pre}${ADMIN_BAD_DIR} ${upath}"
	exit 1
fi

# create the settings file
usettings="${upath}/settings.cfg"
cat > $usettings << EOF
[USER]
IsAdmin=1

EOF

if [ ! -f ${usettings} ]; then
	${ECHO} "$FATAL $ADMIN_BAD_FILE ${usettings}" >> $logfile
	${ECHO} "${pre}${ADMIN_BAD_FILE} ${usettings}" >> $logfile
	exit 1
fi

${ECHO} "${INFO} $ADMIN_SUCCESS ${uname}" >> $logfile

exit 0
