!!! Overview A custom script that was used in a Menu System for a couple of clients. ! Primary Purpose This script performs a ndsrepair -R -l and redirects the output to the [/var/nds/autodsrp.log|ConfigFilesAutodsrp.log]. The [LDAPBuild Process|LDAPBuildProcess] distribute the file to: !Deployed Location The [LDAPBuild Process|LDAPBuildProcess] distribute the <buildhome>[Directory-Info.com]/config/autodsrp.sh file to /usr/bin/autodsrp.sh !Method of Execution The script is run via [cron.tab|NDSCron.tab] !Logging The script creates a log file [/var/nds/autodsrp.log|ConfigFilesAutodsrp.log]. In addtion, the script writes a log file to [/var/nds/autodsrp.csv|AutodsrpCSV]. !Other Notable Features The Tivoli agent monitors the [/var/nds/autodsrp.log|ConfigFilesAutodsrp.log] for the word "ERROR:" and sends an alert containing the line. NOTE:Check file in the NDSBuild directory for the latest version. Typical script content as implemented is shown below as of: 2005-07-29. {{{ #!/bin/bash #:autodsrp.sh # # Modification history: # 12/6/2002-- Added Y-m-d to BEGIN and END tag in the log # 2/25/2003-- Fixed undesired logging to /var/b1nds.log # Removed SUDO from command line (ndsuser can now directly # execute ndsrepair) # Converted to use printf instead of echo (different handling of # backslach characters in bash) # 11/13/2003-- Checkd for 8.7.1 # 4/5/2004 -- Fixed DOS cr/lf problem # 1/24/2005-- Significantly improved logging if [ -f /var/nds/.ndsenv ] then . /var/nds/.ndsenv_functions . /var/nds/.ndsenv else printf "\nMissing /var/nds/.ndsenv -- cannot run!\n" exit 1 fi # Ignore hangup -- may be an issue when running with a large DIB trap ' ' 1 # Turn off normal logging as ndsrepair output will go to autodsrp.log log_file="" # Specifiy location for autodsrp run history will go log_history=/var/nds/autodsrp.csv # BEGIN Main routine f_write_and_log "\n`date '+%Y-%m-%d %H:%M:%S'`: BEGIN $0\n" # 'ndsrepair' switches used here # # -R Repair the Local Database # -A no Resets the ndsrepair.log file (keeps the log from growing out of control) # -l yes Locks the eDirectory database during the repair operation # # By default -i, -d, -t, -r, -v and -c options are set. Their meanings are listed below: # -d Rebuilds the entire database # -t Performs a tree structure check # -i Checks the eDirectory database structure and the index # -r Repairs all the local replicas # -v Validates the stream files # -c Checks local references # Rotate previous log files if [ -f $edirPATH/autodsrp.5.log ]; then rm $edirPATH/autodsrp.5.log; fi if [ -f $edirPATH/autodsrp.4.log ]; then mv $edirPATH/autodsrp.4.log $edirPATH/autodsrp.5.log; fi if [ -f $edirPATH/autodsrp.3.log ]; then mv $edirPATH/autodsrp.3.log $edirPATH/autodsrp.4.log; fi if [ -f $edirPATH/autodsrp.2.log ]; then mv $edirPATH/autodsrp.2.log $edirPATH/autodsrp.3.log; fi if [ -f $edirPATH/autodsrp.1.log ]; then mv $edirPATH/autodsrp.1.log $edirPATH/autodsrp.2.log; fi if [ -f $edirPATH/autodsrp.log ]; then mv $edirPATH/autodsrp.log $edirPATH/autodsrp.1.log; fi # Record start time startTime=`date '+%Y-%m-%d %I:%M:%S %p'` # Execute the ndsrepair process $bindir/ndsrepair -R -l no -F $edirPATH/autodsrp.log -A no>/dev/null # Record end time endTime=`date '+%Y-%m-%d %I:%M:%S %p'` # Parse other "interesting" details from the log file dibOjbs=`grep "Total Objects in Database" $edirPATH/autodsrp.log | cut -d: -f2 | tr -d " "` result=`grep "Repair process" /var/nds/autodsrp.log | tail -1` # Write history log printf "`hostname`,\"$startTime\",\"$endTime\",$dibOjbs,\"$result\"\n" printf "`hostname`,\"$startTime\",\"$endTime\",$dibOjbs,\"$result\"\n">>$log_history f_write_and_log "\n`date '+%Y-%m-%d %H:%M:%S'`: END $0\n" }}} !! More Information There might be more information for this subject on one of the following: [{ReferringPagesPlugin before='*' after='\n' }]