2 # fixscript will replace this line with code to load innshellvars
5 ## News boot script. Runs as "news" user. Requires inndstart be
6 ## setuid root. Run from rc.whatever as:
7 ## su news -c /path/to/rc.news >/dev/console
10 ## su news -c '/path/to/rc.news stop'
17 kill -0 $1 2>/dev/null || break
27 # Stop cnfsstat (if running)
28 if [ -f ${PATHRUN}/cnfsstat.pid ]; then
29 kill `cat ${PATHRUN}/cnfsstat.pid`
30 rm -f ${PATHRUN}/cnfsstat.pid
33 # Stop innwatch (if running)
34 if [ -f $WATCHPID ]; then
39 printf "Stopping innd: "
40 ${PATHBIN}/ctlinnd throttle 'rc.news stop'
41 ${PATHBIN}/ctlinnd shutdown 'rc.news stop'
43 # wait for innd to exit (up to 60 sec)
44 pid=`cat ${SERVERPID} 2>/dev/null`
45 if [ "$pid" != "" ]; then
51 # Turn off ovdb support procs, and close the DB environment
52 if [ "$OVMETHOD" = "ovdb" -a -f ${PATHRUN}/ovdb_server.pid ]; then
53 pid=`cat ${PATHRUN}/ovdb_server.pid 2>/dev/null`
54 if [ "$pid" != "" ]; then
55 printf "Stopping ovdb_server: "
60 if [ "$OVMETHOD" = "ovdb" -a -f ${PATHRUN}/ovdb_monitor.pid ]; then
61 pid=`cat ${PATHRUN}/ovdb_monitor.pid 2>/dev/null`
62 if [ "$pid" != "" ]; then
63 printf "Stopping ovdb_monitor: "
69 if [ -f ${PATHBIN}/rc.news.local ]; then
70 ${PATHBIN}/rc.news.local stop
73 # Delete all of the PID files that we know about to avoid having them
74 # stick around after a fresh start.
75 rm -f ${PATHRUN}/cnfsstat.pid $WATCHPID $SERVERPID
76 rm -f ${PATHRUN}/ovdb_server.pid ${PATHRUN}/ovdb_monitor.pid
82 ## Pick ${INND} or ${INNDSTART}
85 MAIL="${MAILCMD} -s 'Boot-time Usenet warning on `hostname`' ${NEWSMASTER}"
87 ## RFLAG is set below; set INNFLAGS in inn.conf(5)
90 ## Clean shutdown or already running?
91 if [ -f ${SERVERPID} ] ; then
92 if kill -0 `cat ${SERVERPID}` 2>/dev/null; then
93 echo 'INND is running'
96 echo 'INND: PID file exists -- unclean shutdown!'
100 if [ ! -f ${PATHDB}/.news.daily ] ; then
101 case `find ${PATHBIN}/innd -mtime +1 -print 2>/dev/null` in
105 echo 'No .news.daily file; need to run news.daily?' | eval ${MAIL}
109 case `find ${PATHDB}/.news.daily -mtime +1 -print 2>/dev/null` in
113 echo 'Old .news.daily file; need to run news.daily?' | eval ${MAIL}
118 ## Active file recovery.
119 if [ ! -s ${ACTIVE} ] ; then
120 if [ -s ${NEWACTIVE} ] ; then
121 mv ${NEWACTIVE} ${ACTIVE}
123 if [ -s ${OLDACTIVE} ] ; then
124 cp ${OLDACTIVE} ${ACTIVE}
126 echo 'INND: No active file!'
131 # You might want to rebuild the DBZ database, too:
133 # && makehistory -r \
134 # && mv history.n.dir history.dir \
135 # && mv history.n.index history.index \
136 # && mv history.n.hash history.hash
139 ## Remove temporary batchfiles and lock files.
140 ( cd ${BATCH} && rm -f bch* )
141 ( cd ${LOCKS} && rm -f LOCK* )
142 ( cd ${TEMPSOCKDIR} && rm -f ${TEMPSOCK} )
143 rm -f ${NEWSCONTROL} ${NNTPCONNECT} ${SERVERPID}
145 ## Initialize ovdb. Must be done before starting innd.
146 if [ "$OVMETHOD" = "ovdb" ]; then
147 echo 'Starting ovdb.'
149 echo "Can't initialize ovdb (check news.err for OVDB messages)"
156 echo 'Starting innd.'
157 eval ${WHAT} ${RFLAG} ${INNFLAGS}
159 # Gee, looks like lisp, doesn't it?
161 echo "Scheduled start of ${INNWATCH}."
162 ( sleep 60 ; ${INNWATCH} ) > /dev/null &
166 echo "Scheduled start of cnfsstat."
167 ( sleep 60 ; ${PATHBIN}/cnfsstat -s -l -P ) > /dev/null &
170 RMFILE=${MOST_LOGS}/expire.rm
171 for F in ${RMFILE} ${RMFILE}.*; do
172 if [ -f $F -a -s $F ] ; then
173 echo "Removing articles from pre-downtime expire run (${F})."
175 echo 'System shut down during expire.' \
176 'Unlinking articles listed in'
179 ${PATHBIN}/expirerm ${F}
183 # Run any additional local startup commands.
184 if [ -f ${PATHBIN}/rc.news.local ] ; then
185 ${PATHBIN}/rc.news.local start