| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Tool to rebuild all checksums for check_checksums |
| 4 |
# |
| 5 |
# |
| 6 |
# Copyright (C) 2013 Bernd Zeimetz <[email protected]> |
| 7 |
# |
| 8 |
# This program is free software: you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation, either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This program is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
set -e |
| 22 |
umask 027 |
| 23 |
|
| 24 |
for t in md5 sha1 sha224 sha256 sha384 sha512; do |
| 25 |
fname="/etc/nagios/check_checksums.${t}" |
| 26 |
tool="${t}sum" |
| 27 |
if [ -f ${fname} ]; then |
| 28 |
tmp=`mktemp` |
| 29 |
chown root:nagios ${tmp} |
| 30 |
chmod 640 ${tmp} |
| 31 |
|
| 32 |
trap "rm -f ${tmp}" EXIT |
| 33 |
|
| 34 |
sed 's,^[^ ]* ,,' ${fname} | while read f; do |
| 35 |
if [ -f "${f}" ]; then |
| 36 |
${tool} "${f}" >> ${tmp} |
| 37 |
else |
| 38 |
echo "${f} went missing, ignoring!" |
| 39 |
fi |
| 40 |
done |
| 41 |
|
| 42 |
ln "${fname}" "${fname}_`date '+%s'`" |
| 43 |
mv "${tmp}" "${fname}" |
| 44 |
fi |
| 45 |
done |
| 46 |
|
| 47 |
|