initial capture of my stuff
[rrq/thttpd.git] / scripts / thttpd.sh
1 #!/bin/sh
2 #
3 # thttpd.sh - startup script for thttpd on FreeBSD
4 #
5 # This should be manually installed as:
6 #   /usr/local/etc/rc.d/thttpd
7 # It gets run at boot-time.
8 #
9 # Variables available:
10 #   thttpd_enable='YES'
11 #   thttpd_program='/usr/local/sbin/thttpd'
12 #   thttpd_pidfile='/var/run/thttpd.pid'
13 #   thttpd_devfs=...
14 #   thttpd_flags=...
15 #
16 # PROVIDE: thttpd
17 # REQUIRE: LOGIN FILESYSTEMS
18 # KEYWORD: shutdown
19
20 . /etc/rc.subr
21
22 name='thttpd'
23 rcvar='thttpd_enable'
24 start_precmd='thttpd_precmd'
25 stop_cmd='thttpd_stop'
26 thttpd_enable_defval='NO'
27
28 load_rc_config "$name"
29 command="${thttpd_program:-/usr/local/sbin/${name}}"
30 pidfile="${thttpd_pidfile:-/var/run/${name}.pid}"
31 command_args="-i ${pidfile}"
32
33 thttpd_precmd ()
34 {
35         if [ -n "$thttpd_devfs" ] ; then
36                 mount -t devfs devfs "$thttpd_devfs"
37                 devfs -m "$thttpd_devfs" rule -s 1 applyset
38                 devfs -m "$thttpd_devfs" rule -s 2 applyset
39         fi
40 }
41
42 thttpd_stop ()
43 {
44         kill -USR1 `cat "$pidfile"`
45 }
46
47 run_rc_command "$1"