这个是LDAP认证客户端与自动挂载家目录shell脚本配置,使用“authconfig-tui”图形化配置简单,但是后面需要手动操作,自动写入配置文件还没有研究透彻。以后完善

#!/bin/bash
yum install -y nss-pam-ldapd nfs-utils nfs autofs pam_ldap openldap openldap-clients
#showmount -e 172.16.16.22
automaster="/etc/auto.master"
automisc="/etc/auto.misc"
ldaphomedir="/ldapdir/users"
[ -d "$ldaphomedir" ] || mkdir -p "$ldaphomedir"
cat /etc/auto.misc | grep "172.16.16.22" &>/dev/null
if [ $? -eq 0 ]; then        
    echo        
    echo '"Autofs 172.16.16.22 is EXIST'        
    sleep 2
elif [ -f "$automisc" -a -f "$automaster"]; then
     sed -i '$a /ldapdir    /etc/auto.misc' $automaster
      sed -i '$a *    172.16.16.22:/ldapdir/users' $automisc
else
    echo "autofs is NOT exist "
fi
/etc/init.d/autofs restart
chkconfig autofs on
head -n 20 <<EOF
  ######################################################################
 #The next step configuration LDAP authentication information  #
 #Press the "space" key to select "*"              #
 #First:                               #
 #      Use LDAP ----------------------"*"          #
 #      Use MD5 Passwords--------------"*"          #
 #      Use Shadow Passwords-----------"*"          #
 #      Use LDAP Authentication--------"*"          #
 #Second:                                #
 #BASE dc=zxsoft,dc=com                       #
 #URI ldap://172.16.16.22                       #
 #you can remember this#                       #
 ######################################################################
EOF
echo
read -p "continue Y or N:"  select
case $select in
   "Y"|"y")
     authconfig-tui;;
   "N"|"n")  
      exit 2;;  
   *)      
    echo "Input Error" && exit 3 ;;
esac