Chinaunix首页 | 论坛 | 博客
  • 博客访问: 803245
  • 博文数量: 274
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 862
  • 用 户 组: 普通用户
  • 注册时间: 2015-10-24 15:31
个人简介

不合格的程序猿

文章分类

全部博文(274)

文章存档

2019年(3)

2018年(1)

2017年(4)

2016年(160)

2015年(106)

我的朋友

分类: 系统运维

2016-03-07 20:54:25

将ldif文件中的数据导入到ldap目录中,分虚系统。

点击(此处)折叠或打开

  1. #!/bin/sh

  2. START_LOG=/tmp/openldap_start_log

  3. #add for tos_ldap
  4. export LD_LIBRARY_PATH=:/tmp/ldap_tos/BerkeleyDB/lib:/tmp/ldap_tos/openssl/lib:/tmp/ldap_tos/openldap/lib
  5. export PATH=/tos/bin:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/tos/bin:/tos/bin::/tmp/ldap_tos/BerkeleyDB/bin:/tmp/ldap_tos/openssl/bin:/tmp/ldap_tos/openldap/bin:/tmp/ldap_tos/openldap/sbin

  6. tos4a_slapadd()
  7. {
  8.     echo "begin tos4a_slapadd" >> $START_LOG

  9.     if [ $OPERATION != "reset" ] && [ $OPERATION != "normal" ];then
  10.         echo "input $OPERATION, operation error" >> $START_LOG
  11.         exit 1
  12.     else
  13.         echo "operation: $OPERATION" >> $START_LOG
  14.     fi

  15.     LDAP_DB_FILE=/se_mnt/ldap_whole_db.ldif
  16.     #LDAP_BACKUP_DB_FILE=/se_mnt/bak_ldap_whole_db.ldif
  17.     LDAP_RESET_DB_FILE=/tos/etc/aaaa_reset_ldap.ldif
  18.     LDAP_PATH=/tmp/ldap_tos/openldap
  19.     DATA_PATH=var/openldap-data
  20.     
  21.     if [ $OPERATION = "reset" ];then

  22.         if [ ! -f $LDAP_RESET_DB_FILE ];then
  23.             echo "reset db file doesn't exist!" >> $START_LOG
  24.             #echo "reset db file doesn't exist!"
  25.             exit 1
  26.         fi
  27.     else
  28.         if [ ! -f $LDAP_DB_FILE ];then
  29.             echo "db file don't exist!" >> $START_LOG
  30.             #echo "db file don't exist!"
  31.             exit 1
  32.         fi
  33.     fi

  34.     mv $LDAP_PATH/$DATA_PATH/DB_CONFIG / >> $START_LOG
  35.     
  36.     killall -9 slapd;killall -9 slapd >> $START_LOG

  37.     rm -f $LDAP_PATH/$DATA_PATH/* >> $START_LOG
  38.     if [ $? -ne 0 ];then
  39.         echo "rm database error!" >> $START_LOG
  40.         exit 2
  41.     fi

  42.     mv /DB_CONFIG $LDAP_PATH/$DATA_PATH/DB_CONFIG >> $START_LOG

  43.     if [ $OPERATION = "reset" ];then
  44.         echo "reset: use reset file" >> $START_LOG
  45.         #echo "reset: use reset file"
  46.         slapadd -l $LDAP_RESET_DB_FILE >> $START_LOG
  47.     else
  48.         echo "use saved db file" >> $START_LOG
  49.         #echo "use saved db file"
  50.         slapadd -l $LDAP_DB_FILE >> $START_LOG
  51.     fi

  52.     if [ $? -ne 0 ];then
  53.         echo "slapadd error" >> $START_LOG
  54.         exit 3
  55.     fi
  56.     
  57.     #rm -f $LDAP_PATH/$DATA_PATH/log.* >/null
  58.     
  59.     $LDAP_PATH/libexec/slapd & >/null

  60.     if [ $? -ne 0 ];then
  61.             echo "start openldap failed" >> $START_LOG
  62.             exit 4
  63.     fi

  64.     echo "tos4a_slapadd end" >> $START_LOG    
  65.     exit 0
  66. }

  67. echo -e "\n\n******************** start slapadd.sh\n" >> $START_LOG
  68. echo -e "\nwill import ldif to ldap" >> $START_LOG

  69. OPERATION=$1
  70. tos4a_slapadd

  71. echo -e "\n******************** slapadd.sh done\n" >> $START_LOG

阅读(572) | 评论(0) | 转发(0) |
0

上一篇:modify_toscfg_for_ngvone

下一篇:slapcat.sh

给主人留下些什么吧!~~