#!/bin/sh
#
# $NetBSD: sogod.sh,v 1.1.1.1 2011/10/16 05:36:35 manu Exp $
#

# PROVIDE: sogod
# REQUIRE: DAEMON
# BEFORE: apache

$_rc_subr_loaded . /etc/rc.subr

name="sogod"
rcvar=$name
command="/usr/pkg/sbin/${name}"
pidfile="/var/sogo/${name}.pid"
logfile="/var/sogo/${name}.log"
sogouser=sogo
command_args="-WOPidFile ${pidfile} -WOLogFile ${logfile}"
start_precmd="sogod_precmd"
start_cmd="sogod_start"

sogod_precmd()
{
    test -f /usr/pkg/etc/GNUstep.conf || {
        echo "Cannot find /usr/pkg/etc/GNUstep.conf"
        exit 1
    }
    . /usr/pkg/etc/GNUstep.conf

    test -f /usr/pkg/share/GNUstep/Makefiles/GNUstep.sh || {
        echo "Cannot find /usr/pkg/share/GNUstep/Makefiles/GNUstep.sh"
        exit 1
    }
    . /usr/pkg/share/GNUstep/Makefiles/GNUstep.sh
}

sogod_start()
{ 
    echo "Starting $name: "
    su -m ${sogouser} -c "${command} ${command_args}"
} 

load_rc_config $name
run_rc_command "$1"
