Remove unnecessary Group tag for localisation packages
[platform/upstream/rpm.git] / packaging / rpmconfigcheck
1 #! /bin/bash
2 # Copyright (c) 2002 SuSE GmbH Nuernberg, Germany.
3 #
4 # Author: Michael Schroeder <feedback@suse.de>
5 #
6 # /etc/init.d/rpmconfigcheck
7 # /usr/sbin/rcrpmconfigcheck
8 #
9 # Script to scan for unresolved .rpmnew, .rpmorig, and .rpmsave files
10 #
11 ### BEGIN INIT INFO
12 # Provides: rpmconfigcheck
13 # Required-Start: $remote_fs
14 # Required-Stop: $null
15 # Default-Start: 2 3 5
16 # Default-Stop:
17 # Description: rpm config file scan
18 ### END INIT INFO
19
20 . /etc/rc.status
21
22 # First reset status of this service
23 rc_reset
24
25 configcheckfile=/var/adm/rpmconfigcheck
26 packages=/var/lib/rpm/Packages
27
28 test -z "$1" && set start
29
30 case "$1" in
31     start|restart|try-restart|reload|force-reload)
32         if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $packages -ot $configcheckfile \) ; then
33             echo -n "Searching for unresolved configuration files"
34             if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then
35                 test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old
36                 rpm -qalc | sort | perl -lne '-e "$_.rpmnew" and print "$_.rpmnew"; -e "$_.rpmorig" and print "$_.rpmorig"; -e "$_.rpmsave" and print "$_.rpmsave"' > $configcheckfile
37             else
38                 mv -f $configcheckfile $configcheckfile.old
39                 while read l; do
40                     test -e $l && echo $l
41                 done < $configcheckfile.old > $configcheckfile
42                 true
43             fi
44             rc_status -v
45             if test -s $configcheckfile; then
46                 echo "Please check the following files (see /var/adm/rpmconfigcheck):"
47                 sed -e 's/^/    /' < $configcheckfile
48                 touch $configcheckfile.old
49                 cat $configcheckfile $configcheckfile.old | sort | uniq -d > $configcheckfile.dup
50                 cat $configcheckfile $configcheckfile.dup | sort | uniq -u > $configcheckfile.new
51                 if test -s $configcheckfile.new ; then
52                     (
53                     echo "----------------------------------------------------------------------"
54                     echo "----------------------------------------------------------------------"
55                     echo "rpmconfigcheck"
56                     date
57                     echo "----------------------------------------"
58                     echo "This is a warning message."
59                     echo "rpmconfigcheck has found the following new unresolved config files"
60                     echo "(all files are listed in /var/adm/rpmconfigcheck):"
61                     cat $configcheckfile.new
62                     echo "----------------------------------------"
63                     ) >> /var/log/update-messages
64                 fi
65             fi
66             rm -f $configcheckfile.old $configcheckfile.dup $configcheckfile.new
67         fi
68         ;;
69     stop)
70         ;;
71     status)
72         rc_failed 4
73         rc_status -v
74         ;;
75      *)
76         echo "Usage: $0 {start}"
77         exit 1
78         ;;
79 esac
80 rc_exit