| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
LOCKFILE=/var/lock/makewhatis.lock
|
| 4 |
|
| 5 |
# the lockfile is not meant to be perfect, it's just in case the
|
| 6 |
# two makewhatis cron scripts get run close to each other to keep
|
| 7 |
# them from stepping on each other's toes. The worst that will
|
| 8 |
# happen is that they will temporarily corrupt the database...
|
| 9 |
[ -f $LOCKFILE ] && exit 0
|
| 10 |
|
| 11 |
# if MAKEWHATISDBUPDATES variable is set to "n" or "N", then the
|
| 12 |
# update will not passed
|
| 13 |
|
| 14 |
MDU=`sed -n -e 's/^[[:blank:]]*MAKEWHATISDBUPDATES[[:blank:]]*\(.\)[[:blank:]]*$/\1/p' < /etc/man.config`
|
| 15 |
([ "$MDU" == "n" ] || [ "$MDU" == "N" ]) && exit 0
|
| 16 |
|
| 17 |
trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
|
| 18 |
touch $LOCKFILE
|
| 19 |
# Rebuild the database if makewhatis was since last full run,
|
| 20 |
# otherwise just update with new pages
|
| 21 |
if [ ! -f /var/cache/man/whatis ] ||
|
| 22 |
find /usr/sbin/makewhatis -newer /var/cache/man/whatis |grep -q .
|
| 23 |
then
|
| 24 |
makewhatis -w
|
| 25 |
else
|
| 26 |
makewhatis -U -w
|
| 27 |
fi
|
| 28 |
exit 0
|