#!/bin/sh # Frank Reppin # (work in progress) # PROVIDE: ogo-nhsd # REQUIRE: postgresql # KEYWORD: FreeBSD shutdown # may be configured using the following # rc.conf vars: # # ogo_nhsd_enable (bool): either YES or NO (default: NO) # ogo_nhsd_user (string): the user (default: ogo) # ogo_nhsd_args (string): some defaults (default: none, virtually everything # can/and should be set in the configfiles) # ogo_nhsd_version (string): the version (default: currently %%OGO_VERSION%%) # ogo_nhsd_delayedrestart (int): delay in seconds (default: 3) . /etc/rc.subr name="ogo_nhsd" rcvar=`set_rcvar` load_rc_config ${name} prefix="%%PREFIX%%" ogo_nhsd_enable=${ogo_nhsd_enable:-"NO"} ogo_nhsd_user=${ogo_nhsd_user:-"ogo"} ogo_nhsd_args=${ogo_nhsd_args:-""} ogo_nhsd_version=${ogo_nhsd_version:-"%%OGO_VERSION%%"} ogo_nhsd_delayedrestart=${ogo_nhsd_delayedrestart:-"3"} procname="ogo-nhsd-${ogo_nhsd_version}" pidfile="/var/lib/opengroupware.org/${procname}.pid" command="${prefix}/sbin/ogo-nhsd-${ogo_nhsd_version}" start_cmd="ogo_nhsd_start" stop_cmd="ogo_nhsd_stop" restart_cmd="ogo_nhsd_restart" status_cmd="ogo_nhsd_status" ogo_nhsd_start() { this_pids="`pgrep ${procname}`" if [ -n "${this_pids}" ]; then echo -e "${procname} already running - pids used: `echo ${this_pids}|sed -e 's^\n^ ^g'`" exit 0 else echo -e "Starting ${procname}." su -l ${ogo_nhsd_user} -c \ "daemon ${command} ${ogo_nhsd_args} \ 2>> /var/log/opengroupware/ogo-nhsd-err.log \ 1>> /var/log/opengroupware/ogo-nhsd-out.log \ " fi } ogo_nhsd_stop() { echo -e "Stopping ${procname}." pkill -9 ${procname} } ogo_nhsd_restart() { ogo_nhsd_stop # wait n seconds for things to settle... echo " ...waiting ${ogo_nhsd_delayedrestart} seconds to settle." sleep ${ogo_nhsd_delayedrestart} ogo_nhsd_start } ogo_nhsd_status() { this_pids="`pgrep ${procname}`" if [ -n "${this_pids}" ]; then echo -e "${procname} is running - pids used: `echo ${this_pids}|sed -e 's^\n^ ^g'`" else echo -e "${procname} not running." fi } run_rc_command "$1"