adpw(){
if test 1 = 1
then
x=0;
cat user.txt | while read line
do
x=`expr $x + 1`
usr=`echo $line | awk '{print $1}'`
pro=`echo $line | awk '{print $2}'`
#pro=`echo $line | awk '{print $2}'|awk -F "." '{print $1}'`
echo "Add user $usr,$x"
if [ ! -f /u/tiptop/profile/${pro} ]
then
echo "Bad profile,please check !"
continue
else
if [ "${pro}" = "it.profile" ] || [ "${pro}" = "itall.profile" ]
then
echo "$usr" >> /u/tiptop/profile/itlogin.txt
adituser
else
aduser
fi
fi
done
fi
}
aduser(){
useradd -g tiptop -s /bin/ksh -d /home/${pro} $usr
if [ ! -f /home/${pro}/.profile ]
then
ln -sf /u/tiptop/profile/${pro} /home/${pro}/.profile
fi
echo "$usr:foxconn123" > /tmp/passwd
chpasswd < /tmp/passwd
chage -d 0 $usr
}
adituser(){
useradd -g tiptop -s /bin/ksh -m -d /home/${usr} $usr
chown ${usr}:tiptop /home/${usr}
chmod 755 /home/${usr}
if [ ${pro} = "it.profile" ]
then
ln -sf /u/tiptop/profile/it.profile /home/${usr}/.profile
else
ln -sf /u/tiptop/profile/itall.profile /home/${usr}/.profile
fi
echo "$usr:foxconn123" > /tmp/passwd
chpasswd < /tmp/passwd
chage -d 0 $usr
}
adpw 2>&1|tee log
sleep 3
/usr/lib64/yp/ypinit -m <<! > /dev/null
^d
y
!
/usr/sbin/yppush -h ap2 passwd.byname
/usr/sbin/yppush -h ap2 group.byname
/usr/sbin/yppush -h ap2 shadow.byname
/usr/sbin/yppush -h ap3 passwd.byname
/usr/sbin/yppush -h ap3 group.byname
/usr/sbin/yppush -h ap3 shadow.byname