]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/dialog/samples/copifuncs/copi.rcnews
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / dialog / samples / copifuncs / copi.rcnews
1 #! /bin/sh
2 ##  $Revision: 1.1 $
3 ##  News boot script.
4
5 ##  =()<. @<_PATH_SHELLVARS>@>()=
6 . /usr/lib/news/innshellvars
7
8 ##  Pick ${INND} or ${INNDSTART}
9 WHAT=${INNDSTART}
10 ##  Set to true or false
11 DOINNWATCH=false
12 MAIL="${MAILCMD} -s 'Boot-time Usenet warning on `hostname`' ${NEWSMASTER}"
13
14 ##  RFLAG is set below; set FLAGS as appropriate.
15 RFLAG=""
16 FLAGS="-i0 -c0"
17
18 ##  Clean shutdown?
19 if [ -f ${SERVERPID} ] ; then
20     ( echo 'INND:  PID file exists -- unclean shutdown!' >/dev/console )
21     RFLAG="-r"
22 fi
23
24 if [ ! -f ${NEWSLIB}/.news.daily ] ; then
25     echo 'No .news.daily file; need to run news.daily?' | eval ${MAIL}
26 else
27     case `find ${NEWSLIB} -name .news.daily -mtime +1 -print 2>/dev/null` in
28     "")
29         ;;
30     *)
31         echo 'Old .news.daily file; need to run news.daily?' | eval ${MAIL}
32         ;;
33     esac
34 fi
35
36 ##  Active file recovery.
37 if [ ! -s ${ACTIVE} ] ; then
38     if [ -s ${NEWACTIVE} ] ; then
39         mv ${NEWACTIVE} ${ACTIVE}
40     else
41         if [ -s ${OLDACTIVE} ] ; then
42             cp ${OLDACTIVE} ${ACTIVE}
43         else
44             ( echo 'INND:   No active file!' >/dev/console )
45             exit 1
46         fi
47     fi
48     RFLAG="-r"
49     # You might want to rebuild the DBZ database, too:
50     #echo "cd ${NEWSLIB} \
51     #           && makehistory -r \
52     #           && mv history.n.dir history.dir \
53     #           && mv history.n.pag history.pag" | su ${NEWSUSER}
54 fi
55
56 ##  Remove temporary batchfiles and lock files.
57 ( cd ${BATCH} && rm -f bch* )
58 ( cd ${LOCKS} && rm -f LOCK* )
59 ( cd ${TEMPSOCKDIR} && rm -f ${TEMPSOCK} )
60 rm -f ${NEWSCONTROL} ${NNTPCONNECT} ${SERVERPID}
61
62 ##  Start the show.
63 ( echo 'Starting innd.' >/dev/console )
64 eval ${WHAT} ${RFLAG} ${FLAGS}
65
66 # Gee, looks like lisp, doesn't it?
67 ${DOINNWATCH} && {
68     echo "( ( sleep 60 ; ${INNWATCH} ) & )" | su ${NEWSUSER}
69 }
70
71 RMFILE=${MOST_LOGS}/expire.rm
72 if [ -s ${MOST_LOGS}/expire.rm ] ; then
73     ( echo "Removing articles from pre-downtime expire run." >/dev/console )
74     (
75         echo 'System shut down during expire.  Unlinking articles listed in'
76         echo ${RMFILE}
77     ) | eval ${MAIL}
78     echo "${NEWSBIN}/expirerm ${RMFILE}" | su ${NEWSUSER} &
79 fi