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