脚本作用:用于接收users.txt多用户配置文件的用户传寄给交互脚本(sync_shell.sh)
脚本名称: ldap_sync.sh
脚本内容:
#!/bin/bash#Get basic variablessource ./init.sh
#LDAP User Synchronization Core Methodfunctionusers_action(){param1=${1}echo${param1[*]}>${LDAP_USERS}echo${LDAP_USERS}bash ./sync_shell.sh
}#Ambari integrated ldap user file parsing methodfunctionfor_in_file(){foriin`cat $SYNC_USERS`do
users_action $itrue> ./user.txt
done}#Amabri integration, ldap user integration and synchronization
for_in_file
3、定时任务日志脚本
脚本作用:用户定时更新同步LDAP用户并生成详细同步日志
脚本名称:cron_sync_job.sh
脚本内容:
#Build ldap user synchronization log#Switch to the synchronization directorycd /etc/ambari-server/ldap
#Introducing initialization configuration variablessource ./init.sh
echo"=======================>(ambari ldap user sync)Start creating log file:"log_date=`date +%Y-%m-%d`"_ladp_integrated_synchronization.log"touch${LOG_HOME}/$log_dateecho"=======================>(ambari ldap user sync)Log file creation completed!"echo"=======================>(ambari ldap user sync)Enable ambari integrated Ldap user synchronization program!">>${LOG_HOME}/$log_datestart_date=$(date +%Y%m%d' '%H:%M:%S)echo"=======================>(ambari ldap user sync)The start time of this ambari ldap user synchronization:${start_date}">>${LOG_HOME}/$log_datebash ./ldap_sync.sh >>${LOG_HOME}/$log_dateend_date=$(date +%Y%m%d' '%H:%M:%S)#Statistics on synchronization time of ldap userstime_difference=$(($(date +%s -d "${end_date}")-$(date +%s -d "${start_date}")))echo"=======================>(ambari ldap user sync)The ambari ldap user synchronization is completed this time:${end_date}">>${LOG_HOME}/$log_dateecho"=======================>(ambari ldap user sync)The total time spent for this ambari ldap user synchronization:${time_difference}s">>${LOG_HOME}/$log_date