Initial import from FreeBSD RELENG_4:
[dragonfly.git] / etc / periodic / weekly / 330.catman
1 #!/bin/sh -
2 #
3 # $FreeBSD: src/etc/periodic/weekly/330.catman,v 1.5.2.5 2002/04/15 00:44:16 dougb Exp $
4 #
5
6 # If there is a global system configuration file, suck it in.
7 #
8 if [ -r /etc/defaults/periodic.conf ]
9 then
10     . /etc/defaults/periodic.conf
11     source_periodic_confs
12 fi
13
14 case "$weekly_catman_enable" in
15     [Yy][Ee][Ss])
16         if [ ! -d /usr/share/man/cat1 ]
17         then
18             echo '$weekly_catman_enable is set but /usr/share/man/cat1' \
19                 "doesn't exist"
20             rc=2
21         else
22             echo ""
23             echo "Reformatting manual pages:"
24
25             MANPATH=`/usr/bin/manpath -q`
26             if [ $? = 0 ]
27             then
28                 if [ -z "${MANPATH}" ]
29                 then
30                     echo "manpath failed to find any manpath directories" 
31                     rc=3
32                 else
33                     man_locales=`/usr/bin/manpath -qL`
34                     rc=0
35          
36                     # Preformat original, non-localized manpages  
37                     echo /usr/libexec/catman.local "$MANPATH" |
38                         su -fm man || rc=3
39
40                     # Preformat localized manpages.
41                     if [ -n "$man_locales" ]
42                     then
43                         for i in $man_locales
44                         do
45                             echo /usr/libexec/catman.local -L \
46                                 "$MANPATH" | LC_ALL=$i su -fm man || rc=3
47                         done
48                     fi
49                 fi
50             else
51                 rc=3
52             fi
53         fi;;
54
55     *)  rc=0;;
56 esac
57
58 exit $rc