LEFT | RIGHT |
1 #!/bin/sh | 1 #!/bin/sh |
2 ##################################################################### | |
3 ##################################################################### | |
4 ## The cause of this script is to make the output of the LDAP ## | |
5 ## sync cron job more readable by filtering all repeated lines ## | |
6 ##################################################################### | |
7 ##################################################################### | |
8 | 2 |
9 last_updated="" | 3 # Filter out uninformative output lines from the ldap-sync cron job script |
10 | 4 |
11 while IFS= read -r line; do | 5 last_action="" |
12 if echo "$line" | grep -q "Updating" || | |
13 echo "$line" | grep -q "Creating" | |
14 then | |
15 last_updated="$line" | |
16 fi | |
17 | 6 |
18 if echo "$line" | grep -q -v "Updating" && | 7 while read line; do |
19 echo "$line" | grep -q -v "Creating" && | 8 case "$line" in |
20 echo "$line" | grep -q -v "Found" && | 9 *-\>*) |
21 echo "$line" | grep -q -v "#" && | 10 if [ ! -z "$last_action" ] |
22 echo "$line" | grep -q -v "Synchronizing" && | 11 then |
23 echo "$line" | grep -q -v -F -e "->" | 12 echo "$last_action" |
24 then | 13 fi |
25 echo $line | |
26 fi | |
27 | 14 |
28 if echo "$line" | grep -q -F -e "->" | 15 echo "$line" |
29 then | 16 last_action="" |
30 echo $last_updated | 17 ;; |
31 echo $line | 18 --\ Found\ *\ users* | \ |
32 fi | 19 \#* | \ |
| 20 *Synchronizing\ *\ groups* | \ |
| 21 \*\*\ Synchronizing\ *\ users* | \ |
| 22 --\ Updating\ user\ \'*\'?\(*\)* | \ |
| 23 --\ Updating\ group\ \'*\'* | \ |
| 24 --\ Creating\ user\ \'*\'?\(*\)* | \ |
| 25 --\ Creating\ group\ \'*\'*) |
| 26 last_action="$line" |
| 27 ;; |
| 28 *) |
| 29 echo "$line" |
| 30 ;; |
| 31 esac |
33 done | 32 done |
LEFT | RIGHT |