-
Notifications
You must be signed in to change notification settings - Fork 23
/
get_config_diff.sh
executable file
·42 lines (37 loc) · 1.42 KB
/
get_config_diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# This script may be executed after updating via git (i.e. git pull) to show the
# difference between the currently used configuration files and the possibly
# updated ones in git. Based on the output, the currently used and updated ones
# should be merged (like *.rpmnew files). Permission mismatch warnings are
# directed to stderr. Thus, redirect stdout to a file to get only the
# differences between the files:
# ./get_config_diff.sh > config.diff
ignore=(
'/etc/dhcp-nmsprime/blocked.conf'
'/etc/dhcp-nmsprime/cmts_gws.conf'
'/etc/dhcp-nmsprime/endpoints-host.conf'
'/etc/dhcp-nmsprime/modems-clients-public.conf'
'/etc/dhcp-nmsprime/modems-host.conf'
'/etc/dhcp-nmsprime/mta.conf'
'/etc/kea/gateways6.conf'
'/etc/kea/hosts6.conf'
'/var/log/nmsprime/tftpd-cm.log'
'/var/named/dynamic/in-addr.arpa.zone'
'/var/named/dynamic/nmsprime.test.zone'
)
for file in $(find /var/www/nmsprime -maxdepth 4 -path "*/Install/config.cfg"); do
while read -r line; do
f_from="$(dirname $file)/files/$(echo "$line" | cut -d'=' -f1 | xargs)"
f_to=$(echo "$line" | cut -d'=' -f2 | xargs)
if [ ! -f "$f_to" ]
then
f_to='/dev/null'
else
if [ $(stat -c "%a" "$f_from") -ne $(stat -c "%a" "$f_to") ]; then
echo "permission mismatch: $f_from $f_to" >&2
fi
fi
diff -u "$f_to" "$f_from"
echo ""
done < <(awk '/\[files\]/{flag=1;next}/\[/{flag=0}flag' "$file" | grep '=' | sed -f <(printf '\|%s|d\n' "${ignore[@]}"))
done