PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/dialog/samples/copifuncs/copi.rcnews

https://bitbucket.org/freebsd/freebsd-head/
Shell | 79 lines | 52 code | 10 blank | 17 comment | 10 complexity | 6278714adb028cd3c1e42f24af6a9d24 MD5 | raw file
 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}
 9WHAT=${INNDSTART}
10##  Set to true or false
11DOINNWATCH=false
12MAIL="${MAILCMD} -s 'Boot-time Usenet warning on `hostname`' ${NEWSMASTER}"
13
14##  RFLAG is set below; set FLAGS as appropriate.
15RFLAG=""
16FLAGS="-i0 -c0"
17
18##  Clean shutdown?
19if [ -f ${SERVERPID} ] ; then
20    ( echo 'INND:  PID file exists -- unclean shutdown!' >/dev/console )
21    RFLAG="-r"
22fi
23
24if [ ! -f ${NEWSLIB}/.news.daily ] ; then
25    echo 'No .news.daily file; need to run news.daily?' | eval ${MAIL}
26else
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
34fi
35
36##  Active file recovery.
37if [ ! -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}
54fi
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} )
60rm -f ${NEWSCONTROL} ${NNTPCONNECT} ${SERVERPID}
61
62##  Start the show.
63( echo 'Starting innd.' >/dev/console )
64eval ${WHAT} ${RFLAG} ${FLAGS}
65
66# Gee, looks like lisp, doesn't it?
67${DOINNWATCH} && {
68    echo "( ( sleep 60 ; ${INNWATCH} ) & )" | su ${NEWSUSER}
69}
70
71RMFILE=${MOST_LOGS}/expire.rm
72if [ -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} &
79fi