#!/bin/sh
#
# $NetBSD: pygopherd.sh,v 1.2 2011/10/31 08:45:08 obache Exp $
#
# PROVIDE: pygopherd
# REQUIRE: DAEMON
#
# To start spread at startup, copy this script to /etc/rc.d and set
# spread=YES in /etc/rc.conf.
#
# Addtionally you may set spread_log to a file where to log stuff.

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

rcd_dir=`/usr/bin/dirname $0`

name="pygopherd"
rcvar=$name
command="/usr/pkg/bin/${name}"
command_interpreter="/usr/pkg/bin/python2.7"
pidfile="/var/run/${name}.pid"
conf_file="/usr/pkg/etc/pygopherd/${name}.conf"
mime_file="/usr/pkg/etc/pygopherd/mime.types"
required_files="${conf_file} ${mime_file}"

start_precmd="${name}_precmd"

pygopherd_precmd()
{
        if [ ! -d /var/gopher ]
        then
                /bin/mkdir -p /var/gopher
                /bin/chmod 0750 /var/gopher
                /usr/sbin/chown @PKG_USERS@ /var/gopher
        fi
}

load_rc_config $name
run_rc_command "$1"
