立即注册 登录
About云-梭伦科技 返回首页

halley的个人空间 https://aboutyun.com/?5662 [收藏] [复制] [分享] [RSS]

日志

centos ldap 搭建脚本 不断修改中

已有 1207 次阅读2014-4-23 10:42 |个人分类:搭建还是搭建| centos, 的ldap简单脚本

#!/bin/sh
myDomain="hadoop"
passwd="111111"
net="eth0"

ldapuser=$myDomain

netip=`ifconfig $net |grep "inet addr" |awk '{print $2}' |cut -d ":" -f 2`
echo $net ip:$netip

HE="--------"
SLAPD_D=/etc/openldap/slapd.d
DB_D=/var/lib/ldap

SLAPD_CONF=/etc/openldap/slapd.conf
LAPD_CONF=/etc/openldap/ldap.conf

backdir=/etc/openldap/back/`date +"%Y%m%d%H%M%S"`

yum -y install openldap-clients openldap-servers openldap-devel openldap 1>/dev/null
echo "install openldap package:"$?
mkdir -p $backdir

cp -rp $SLAPD_D $backdir
rm $SLAPD_D/* -rf

mv $LAPD_CONF $backdir
echo "URI ldap://${netip}" >$LAPD_CONF
echo "BASE dc=$myDomain,dc=com" >>$LAPD_CONF
echo "TLS_CACERTDIR /etc/openldap/cacerts" >>$LAPD_CONF

cp -rp $DB_D $backdir
rm $DB_D/* -rf

mv $SLAPD_CONF $backdir

cp /usr/share/openldap-servers/slapd.conf.obsolete $SLAPD_CONF
sed -i "s/\<my-domain\>/$myDomain/g" $SLAPD_CONF

cp /usr/share/openldap-servers/DB_CONFIG.example $DB_D/DB_CONFIG
echo "slaptest -f $SLAPD_CONF -F $SLAPD_D"

slaptest -f $SLAPD_CONF -F $SLAPD_D 2>/dev/null
chown ldap.ldap -R $SLAPD_D
chown ldap.ldap -R $DB_D

/etc/init.d/slapd restart
secretpasswd=`slappasswd -s $passwd`
pwline=`grep rootpw $SLAPD_CONF -n | awk 'NR==1{print $1}' |cut -d ":" -f 1`
sed -i "$pwline irootpw\t$secretpasswd" $SLAPD_CONF
/etc/init.d/slapd stop
rm $SLAPD_D/* -rf
slaptest -f $SLAPD_CONF -F $SLAPD_D
chown ldap.ldap -R $SLAPD_D
chown ldap.ldap -R $DB_D
/etc/init.d/slapd start

yum -y install migrationtools 1>/dev/null
echo "install migrationtools:"$?
migr_file=/usr/share/migrationtools/migrate_common.ph
if [ ! -f ${migr_file}_bak ];then
cp $migr_file ${migr_file}_bak
else
cp ${migr_file}_bak $migr_file
fi

sed -i "s/padl/$myDomain/g" $migr_file

echo "/usr/share/migrationtools/migrate_base.pl | ldapadd -c -x -D "cn=Manager,dc=$myDomain,dc=com" -w $passwd"
/usr/share/migrationtools/migrate_base.pl | ldapadd -c -x -D "cn=Manager,dc=$myDomain,dc=com" -w $passwd
echo "add base info:"$?
grep "^${ldapuser}:" /etc/passwd >./passwd.ldif
echo "/usr/share/migrationtools/migrate_passwd.pl ./passwd.ldif |ldapadd -c -x -D \"cn=Manager,dc=$myDomain,dc=com\" -w $passwd"
/usr/share/migrationtools/migrate_passwd.pl ./passwd.ldif |ldapadd -c -x -D "cn=Manager,dc=$myDomain,dc=com" -w $passwd
echo "add passwd info:"$?
grep "^${ldapuser}:" /etc/group >./group.ldif
echo "/usr/share/migrationtools/migrate_group.pl ./group.ldif | ldapadd -c -x -D "cn=Manager,dc=$myDomain,dc=com" -w $passwd"
/usr/share/migrationtools/migrate_group.pl ./group.ldif | ldapadd -c -x -D "cn=Manager,dc=$myDomain,dc=com" -w $passwd
echo "add group info:"$?

echo "$HE info $HE
id : `id $myDomain`
host : `hostname`
eth0 : $netip"

qq:406384832

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

关闭

推荐上一条 /2 下一条