2002-06-21 19:07:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2003-04-24 08:20:47 +00:00
|
|
|
# $FreeBSD$
|
2002-06-21 19:07:21 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ipfs
|
2003-04-24 08:20:47 +00:00
|
|
|
# REQUIRE: ipnat
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail shutdown
|
2002-06-21 19:07:21 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="ipfs"
|
2012-01-14 02:18:41 +00:00
|
|
|
rcvar="ipfs_enable"
|
2002-06-21 19:07:21 +00:00
|
|
|
start_cmd="ipfs_start"
|
|
|
|
stop_cmd="ipfs_stop"
|
2004-01-17 10:40:45 +00:00
|
|
|
start_precmd="ipfs_prestart"
|
2003-04-24 08:20:47 +00:00
|
|
|
|
|
|
|
ipfs_prestart()
|
|
|
|
{
|
|
|
|
# Do not continue if either ipnat or ipfilter is not enabled or
|
|
|
|
# if the ipfilter module is not loaded.
|
|
|
|
#
|
|
|
|
if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then
|
|
|
|
err 1 "${name} requires either ipfilter or ipnat enabled"
|
|
|
|
fi
|
2013-09-10 13:48:33 +00:00
|
|
|
if ! ${ipfilter_program:-/sbin/ipf} -V | grep -q 'Running: yes' >/dev/null 2>&1; then
|
2003-04-24 08:20:47 +00:00
|
|
|
err 1 "ipfilter module is not loaded"
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
2002-06-21 19:07:21 +00:00
|
|
|
|
|
|
|
ipfs_start()
|
|
|
|
{
|
|
|
|
if [ -r /var/db/ipf/ipstate.ipf -a -r /var/db/ipf/ipnat.ipf ]; then
|
2003-04-24 08:20:47 +00:00
|
|
|
${ipfs_program} -R ${rc_flags}
|
2002-06-21 19:07:21 +00:00
|
|
|
rm -f /var/db/ipf/ipstate.ipf /var/db/ipf/ipnat.ipf
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
ipfs_stop()
|
|
|
|
{
|
|
|
|
if [ ! -d /var/db/ipf ]; then
|
|
|
|
mkdir /var/db/ipf
|
|
|
|
chmod 700 /var/db/ipf
|
|
|
|
chown root:wheel /var/db/ipf
|
|
|
|
fi
|
2003-04-24 08:20:47 +00:00
|
|
|
${ipfs_program} -W ${rc_flags}
|
2002-06-21 19:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|