So I’ve been using vanilla FreeBSD-7.0-Beta2 for a few weeks now. I’ve also been extensively looking into it’s rc system to see what it can do that openrc cannot. The answer is, well not much.

But there is one thing it does have which is very nice - and that’s init script templates. Take this sample ntpd init script from Gentoo (line breaks and comments removed, sadly my blog removes the indents too)

#!/sbin/runscript

depend() {
	need net
	use dns logger
	after ntp-client
}

checkconfig() {
	if [ !-f /etc/ntp.conf ]; then
		eerror "Please create /etc/ntp.conf"
		eerror "Sample conf: /usr/share/ntp/ntp.conf"
		return 1
	fi
	return 0
}

start() {
	checkconfig || return $?
	ebegin "Starting ntpd"
	start-stop-daemon--start--exec /usr/sbin/ntpd 
	    --pidfile /var/run/ntpd.pid 
	    ---p /var/run/ntpd.pid ${NTPD_OPTS}
	eend $? "Failed to start ntpd"
}

stop() {
	ebegin "Stopping ntpd"
	start-stop-daemon--stop 
	    --pidfile /var/run/ntpd.pid 
	    --exec /usr/sbin/ntpd
	eend $? "Failed to stop ntpd"
}

Now, here’s a replacement using the template system.

#!/sbin/runscript

command=/usr/sbin/ntpd
pidfile=/var/run/ntpd.pid
command_args="-p ${pidfile} ${NTPD_OPTS}"

depend() {
	need net
	use dns logger
	after ntp-client
}

start_pre() {
	if [ ! -f /etc/ntp.conf ]; then
		eerror "Please create /etc/ntp.conf"
		eerror "Sample conf: /usr/share/ntp/ntp.conf"
	return 1
	fi
	return 0
}

This should make a fair few init scripts smaller, and remove the headache of using start-stop-daemon which some users find.

On another note, the openrc build system has been revamped so we support both FreeBSD make and GNU make 100%. This means it’s easier to slip into FreeBSD as a potential port, and maybe the other BSD’s too.