将ldif文件中的数据导入到ldap目录中,分虚系统。
-
#!/bin/sh
-
-
START_LOG=/tmp/openldap_start_log
-
-
#add for tos_ldap
-
export LD_LIBRARY_PATH=:/tmp/ldap_tos/BerkeleyDB/lib:/tmp/ldap_tos/openssl/lib:/tmp/ldap_tos/openldap/lib
-
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
-
-
tos4a_slapadd()
-
{
-
echo "begin tos4a_slapadd" >> $START_LOG
-
-
if [ $OPERATION != "reset" ] && [ $OPERATION != "normal" ];then
-
echo "input $OPERATION, operation error" >> $START_LOG
-
exit 1
-
else
-
echo "operation: $OPERATION" >> $START_LOG
-
fi
-
-
LDAP_DB_FILE=/se_mnt/ldap_whole_db.ldif
-
#LDAP_BACKUP_DB_FILE=/se_mnt/bak_ldap_whole_db.ldif
-
LDAP_RESET_DB_FILE=/tos/etc/aaaa_reset_ldap.ldif
-
LDAP_PATH=/tmp/ldap_tos/openldap
-
DATA_PATH=var/openldap-data
-
-
if [ $OPERATION = "reset" ];then
-
-
if [ ! -f $LDAP_RESET_DB_FILE ];then
-
echo "reset db file doesn't exist!" >> $START_LOG
-
#echo "reset db file doesn't exist!"
-
exit 1
-
fi
-
else
-
if [ ! -f $LDAP_DB_FILE ];then
-
echo "db file don't exist!" >> $START_LOG
-
#echo "db file don't exist!"
-
exit 1
-
fi
-
fi
-
-
mv $LDAP_PATH/$DATA_PATH/DB_CONFIG / >> $START_LOG
-
-
killall -9 slapd;killall -9 slapd >> $START_LOG
-
-
rm -f $LDAP_PATH/$DATA_PATH/* >> $START_LOG
-
if [ $? -ne 0 ];then
-
echo "rm database error!" >> $START_LOG
-
exit 2
-
fi
-
-
mv /DB_CONFIG $LDAP_PATH/$DATA_PATH/DB_CONFIG >> $START_LOG
-
-
if [ $OPERATION = "reset" ];then
-
echo "reset: use reset file" >> $START_LOG
-
#echo "reset: use reset file"
-
slapadd -l $LDAP_RESET_DB_FILE >> $START_LOG
-
else
-
echo "use saved db file" >> $START_LOG
-
#echo "use saved db file"
-
slapadd -l $LDAP_DB_FILE >> $START_LOG
-
fi
-
-
if [ $? -ne 0 ];then
-
echo "slapadd error" >> $START_LOG
-
exit 3
-
fi
-
-
#rm -f $LDAP_PATH/$DATA_PATH/log.* >/null
-
-
$LDAP_PATH/libexec/slapd & >/null
-
-
if [ $? -ne 0 ];then
-
echo "start openldap failed" >> $START_LOG
-
exit 4
-
fi
-
-
echo "tos4a_slapadd end" >> $START_LOG
-
exit 0
-
}
-
-
echo -e "\n\n******************** start slapadd.sh\n" >> $START_LOG
-
echo -e "\nwill import ldif to ldap" >> $START_LOG
-
-
OPERATION=$1
-
tos4a_slapadd
-
-
echo -e "\n******************** slapadd.sh done\n" >> $START_LOG
阅读(572) | 评论(0) | 转发(0) |