#!/bin/tcsh

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") 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.
