#!/bin/bash
ACTION () {
if [ -z "$4" ]
then
echo please give me a userfile
elif [ ! -e "$4" ]
then
echo "$4 is not exist!!"
else
for NAME in `cat $4`
do
USER=`getent passwd $NAME`
if [$1 "$USER" ]
then
$2 $NAME
[ "$2" = "useradd" ] && (echo westos | passwd --stdin $NAME)
else
echo $NAME $3
fi
done
fi
}
if [ "$1" = "create" ]
then
ACTION -z "useradd" 'exist' $2
elif [ "$1" = "delete" ]
then
ACTION -z "userdel -r " 'not exist' $2
else
echo "Useage: ctrl_user.sh <create|delete> <userfile"
fi
1,1 Top
ACTION () {
if [ -z "$4" ]
then
echo please give me a userfile
elif [ ! -e "$4" ]
then
echo "$4 is not exist!!"
else
for NAME in `cat $4`
do
USER=`getent passwd $NAME`
if [$1 "$USER" ]
then
$2 $NAME
[ "$2" = "useradd" ] && (echo westos | passwd --stdin $NAME)
else
echo $NAME $3
fi
done
fi
}
if [ "$1" = "create" ]
then
ACTION -z "useradd" 'exist' $2
elif [ "$1" = "delete" ]
then
ACTION -z "userdel -r " 'not exist' $2
else
echo "Useage: ctrl_user.sh <create|delete> <userfile"
fi
1,1 Top