#!/bin/tcsh
#   /***************************************************************************
#   **                                                                        **
#   **  License                                                               **
#   **  =======                                                               **
#   **                                                                        **
#   **  This software program is released under the terms of a license        **
#   **  agreement between you ('Licensee') and Intel. Do not use or load this **
#   **  software or any associated materials (collectively, the 'Software')   **
#   **  until you have carefully read the full terms and conditions of the    **
#   **  LICENSE located in this software package. By loading or using the     **
#   **  Software, you agree to the terms of this Agreement. If you do not     **
#   **  agree with the terms of this Agreement, do not install or use the     **
#   **  Software.                                                             **
#   ***************************************************************************/
#
#   /***************************************************************************
#   **                                                                                                                                                               **
#   ** INTEL CORPORATION                                                      							      **
#   **                                                                        											     **
#   ** This software is supplied under the terms of the license included                                        **
#   ** above.  All use of this software must be in accordance with the terms                                **
#   ** of that license.                                                       										   **
#   **                                                                        											      **
#   **  Abstract:                                                             										      **
#   **    Addition of a PROCfgd user										                            **
#   **                                                                        											      **
#   ***************************************************************************/

if ($# != 2) then
    echo Usage: $0 "<username> <password>"
    exit 1
endif
set passlen=`echo -n $2 | wc -c`
if ($passlen < 8) then
    echo Password must be at least 8 characters long
    exit 1
endif
ps -Cprocfgd > /dev/null
if ($? == 0) then
    echo -n "Unable to add a user while procfgd is running. Terminate procfgd? "
    set res=$<
    if ($res != "y" && $res != "Y" && $res != "yes" && $res != "Yes") then
        echo User not added. && exit 1
    endif
    killall -9 procfgd || exit 1
    echo procfgd terminated.
endif
mkdir -p /var/.procfgd || exit 1
echo createUser $1 MD5 $2 DES $2 >> /var/.procfgd/procfgd.conf || exit 1
echo User added successfully.
