#!/bin/sh
#
# Author: Emanuel Haupt <ehaupt@FreeBSD.org>
#
# $FreeBSD$
#

# PROVIDE: socat
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable socat:
# socat_enable="YES"
# socat_flags="<set as needed>"

. /etc/rc.subr

name="socat"
rcvar=socat_enable

load_rc_config $name

: ${socat_enable="NO"}

start_precmd="socat_prestart"
pidfile=/var/run/socat.pid
procname="/usr/local/bin/socat"
command=/usr/sbin/daemon
command_args=" -f -p ${pidfile} ${procname} ${socat_flags}"

socat_prestart()
{
	# socat_flags gets applied too early if we don't do this.
	# I didn't want to force people to update their rc.conf files
	# and change the socat_flags to something else.
	rc_flags=""
}

run_rc_command "$1"
