#!/bin/sh # $FreeBSD: head/security/sguil-sensor/files/pads_agent.in 312466 2013-02-18 00:56:47Z miwi $ # PROVIDE: pads_agent # REQUIRE: DAEMON # KEYWORD: shutdown # Add the following line to /etc/rc.conf to enable pads_agent: # pads_agent_enable (bool): Set to YES to enable pads_agent # Default: NO # pads_agent_conf (str): Pads_agent configuration file # Default: %%PREFIX%%/etc/%%SGUILDIR%%/pads_agent.conf # pads_agent_flags (str): Default: -D # . /etc/rc.subr name="pads_agent" rcvar=${name}_enable load_rc_config ${name} #set defaults : ${pads_agent_enable:="NO"} : ${pads_agent_conf:="%%PREFIX%%/etc/%%SGUILDIR%%/pads_agent.conf"} : ${pads_agent_flags:="-D -c ${pads_agent_conf}"} command="%%PREFIX%%/bin/%%SGUILDIR%%/pads_agent.tcl" procname="%%PREFIX%%/bin/%%TCLSH%%" pidfile="/var/run/${name}.pid" start_precmd="pads_agent_ck4fifo" stop_postcmd="pads_agent_rmfifo" pads_agent_ck4fifo() { LOG_DIR=`grep "LOG_DIR " ${pads_agent_conf} | awk '{print $3}'` HOSTNAME=`grep "HOSTNAME " ${pads_agent_conf} | awk '{print $3}'` PADS_FIFO=${LOG_DIR}/${HOSTNAME}/pads.fifo if [ ! -p ${PADS_FIFO} ]; then echo "${PADS_FIFO} does not exist. Creating now....." /usr/bin/mkfifo ${PADS_FIFO} fi echo "Checking for ${PADS_FIFO}...." if [ -p ${PADS_FIFO} ]; then echo "Confirmed! ${PADS_FIFO} exists." else echo "I tried to create ${PADS_FIFO} and failed." echo "You will need to create it manually before starting ${name}." fi } pads_agent_rmfifo() { LOG_DIR=`grep "LOG_DIR " ${pads_agent_conf} | awk '{print $3}'` HOSTNAME=`grep "HOSTNAME " ${pads_agent_conf} | awk '{print $3}'` PADS_FIFO=${LOG_DIR}/${HOSTNAME}/pads.fifo if [ -p ${PADS_FIFO} ]; then /bin/rm ${PADS_FIFO} echo "Removing ${PADS_FIFO}...." fi } run_rc_command "$1"