ipfs revision 255450
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/ipfs 255450 2013-09-10 13:48:33Z cy $ 4# 5 6# PROVIDE: ipfs 7# REQUIRE: ipnat 8# KEYWORD: nojail shutdown 9 10. /etc/rc.subr 11 12name="ipfs" 13rcvar="ipfs_enable" 14start_cmd="ipfs_start" 15stop_cmd="ipfs_stop" 16start_precmd="ipfs_prestart" 17 18ipfs_prestart() 19{ 20 # Do not continue if either ipnat or ipfilter is not enabled or 21 # if the ipfilter module is not loaded. 22 # 23 if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then 24 err 1 "${name} requires either ipfilter or ipnat enabled" 25 fi 26 if ! ${ipfilter_program:-/sbin/ipf} -V | grep -q 'Running: yes' >/dev/null 2>&1; then 27 err 1 "ipfilter module is not loaded" 28 fi 29 return 0 30} 31 32ipfs_start() 33{ 34 if [ -r /var/db/ipf/ipstate.ipf -a -r /var/db/ipf/ipnat.ipf ]; then 35 ${ipfs_program} -R ${rc_flags} 36 rm -f /var/db/ipf/ipstate.ipf /var/db/ipf/ipnat.ipf 37 fi 38} 39 40ipfs_stop() 41{ 42 if [ ! -d /var/db/ipf ]; then 43 mkdir /var/db/ipf 44 chmod 700 /var/db/ipf 45 chown root:wheel /var/db/ipf 46 fi 47 ${ipfs_program} -W ${rc_flags} 48} 49 50load_rc_config $name 51run_rc_command "$1" 52