initial capture of my stuff
[rrq/thttpd.git] / scripts / thttpd_wrapper
1 #!/bin/sh
2 #
3 # thttpd_wrapper - wrapper script for thttpd on FreeBSD
4 #
5 # This goes in /usr/local/sbin.  It backgrounds itself, and then runs
6 # thttpd in a loop.  If thttpd exits then the script restarts it automatically.
7 #
8 # The -D flag tells thttpd to *not* put itself into the background,
9 # and the -C flag tells it to get the rest of its configuration from
10 # the specified config file.
11
12 (
13     while true ; do
14         /usr/local/sbin/thttpd -D -C /usr/local/www/thttpd_config
15         if [ -f /var/run/nologin ] ; then
16             exit
17         fi
18         sleep 10
19         egrep ' thttpd[:\[]' /var/log/messages |
20           tail -33 |
21           mail -s "thttpd on `hostname` restarted" root
22     done
23 ) &