#!/bin/sh # Frank Reppin # (work in progress) # PROVIDE: ogo-xmlrpcd # REQUIRE: postgresql # KEYWORD: FreeBSD shutdown # may be configured using the following # rc.conf vars: # # ogo_xmlrpcd_enable (bool): either YES or NO (default: NO) # ogo_xmlrpcd_user (string): the user (default: ogo) # ogo_xmlrpcd_args (string): some defaults (default: none, virtually everything # can/and should be set in the configfiles) # ogo_xmlrpcd_version (string): the version (default: currently %%OGO_VERSION%%) # ogo_xmlrpcd_delayedrestart (int): delay in seconds (default: 3) . /etc/rc.subr name="ogo_xmlrpcd" rcvar=`set_rcvar` load_rc_config ${name} prefix="%%PREFIX%%" ogo_xmlrpcd_enable=${ogo_xmlrpcd_enable:-"NO"} ogo_xmlrpcd_user=${ogo_xmlrpcd_user:-"ogo"} ogo_xmlrpcd_args=${ogo_xmlrpcd_args:-""} ogo_xmlrpcd_version=${ogo_xmlrpcd_version:-"%%OGO_VERSION%%"} ogo_xmlrpcd_delayedrestart=${ogo_xmlrpcd_delayedrestart:-"3"} procname="ogo-xmlrpcd-${ogo_xmlrpcd_version}" pidfile="/var/lib/opengroupware.org/${procname}.pid" command="${prefix}/sbin/ogo-xmlrpcd-${ogo_xmlrpcd_version}" start_cmd="ogo_xmlrpcd_start" stop_cmd="ogo_xmlrpcd_stop" restart_cmd="ogo_xmlrpcd_restart" status_cmd="ogo_xmlrpcd_status" ogo_xmlrpcd_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_xmlrpcd_user} -c \ "daemon ${command} ${ogo_xmlrpcd_args} \ >&/var/log/opengroupware/ogo-xmlrpcd.log " fi } ogo_xmlrpcd_stop() { echo -e "Stopping ${procname}." pkill -9 ${procname} } ogo_xmlrpcd_restart() { ogo_xmlrpcd_stop # wait n seconds for things to settle... echo " ...waiting ${ogo_xmlrpcd_delayedrestart} seconds to settle." sleep ${ogo_xmlrpcd_delayedrestart} ogo_xmlrpcd_start } ogo_xmlrpcd_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"