#!/bin/sh
. /etc/sargraph.conf
##pass_user ver1.0
##This script will be used to reset password of users of SARGRAPH
if [ $# -eq 0 ]
then
echo "USAGE: pass_user <username>"
exit -1
fi
$EGREP $1 $USERCONF > /dev/null

if [ $? -eq 0 ]
then
CPASS=`$EGREP $1 $USERCONF|awk -F: '{print $2}'`
else
echo "ERROR: User $1 not exist!"
exit
fi
echo "Enter New Password:"
read pass1
echo "Confirm Password:"
read pass2
if [ $pass1 == $pass2 ]
then
pass1=`echo $1$pass1 | md5sum | cut -b 1-8`
$SED -i s/$1:$CPASS/$1:$pass1/ $USERCONF
echo "Password changed"
else
echo "ERROR: Password not matching"
exit
fi
