ports/net-mgmt/devmon/files/devmon.in
John Marino bcbae34226 change command_interpreter from /usr/bin/perl to ${PREFIX}/bin/perl
Several ports had rc.d scripts with hardcoded command_interpreter string
as /usr/bin/perl.  This symlink is not guaranteed to be in place, and it
isn't even an option for perl 5.20.  For affected ports, the interpreter
was changed to localbase.

In one case, the interpreter was correct, but it wasn't surround by
quotes.  Since the rc.d script would break if a space was contained in
${PREFIX}, quotes were added in that case.
2015-01-05 13:18:58 +00:00

87 lines
1.9 KiB
Bash

#!/bin/sh
# $FreeBSD$
# PROVIDE: devmon
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name=devmon
rcvar=devmon_enable
load_rc_config ${name}
: ${devmon_enable:=NO}
: ${devmon_config="%%PREFIX%%/devmon/devmon.cfg"}
: ${devmon_db="%%PREFIX%%/devmon/hosts.db"}
: ${devmon_pid=/var/run/devmon/devmon.pid}
: ${devmon_user="%%USERS%%"}
: ${devmon_group="%%GROUPS%%"}
command="%%PREFIX%%/devmon/devmon"
command_args="-c ${devmon_config} -d ${devmon_db}"
command_interpreter="%%PREFIX%%/bin/perl"
pidfile=${devmon_pid}
start_precmd=devmon_startprecmd
status_cmd=devmon_statuscmd
stop_cmd=devmon_stopcmd
devmon_startprecmd()
{
if [ ! -e ${devmon_config} ];
then
echo "Error: ${devmon_config} does not exist."
exit 1;
fi
TEMPLATESDIR=%%PREFIX%%/devmon/templates
if [ ! -e ${TEMPLATESDIR} ]; then
echo ""
echo " ERROR: no templates exist. Please install device templates"
echo " to: ${TEMPLATESDIR}"
echo " They are available on the devmon SourceForge page via SVN."
echo " Note, the older template tarballs do not work reliably."
echo ""
echo " # svn co svn://svn.code.sf.net/p/devmon/code/trunk/templates ${TEMPLATESDIR}"
echo ""
exit 1;
fi
DEVMONLOG=$(grep "^LOGFILE=" ${devmon_config} | awk -F '=' '{print $2}')
if [ ! -e ${DEVMONLOG} ]; then
install -o devmon -g devmon /dev/null ${DEVMONLOG}
fi
if [ ! -d /var/run/devmon ]; then
install -o devmon -g devmon /dev/null /var/run/devmon
fi
}
devmon_statuscmd()
{
if [ ! -e ${pidfile} ]; then
echo "pidfile does not exist. ${name} is not running?";
exit 1;
fi
if pgrep -F ${pidfile} >/dev/null; then
echo "${name} is running.";
else
echo "${name} is not running.";
exit 1;
fi
}
devmon_stopcmd()
{
if pgrep -F ${pidfile} >/dev/null; then
mypid=`cat ${pidfile}`;
kill ${sig_stop} ${mypid};
wait_for_pids ${mypid};
else
echo "${name} is not running.";
exit 1;
fi
}
run_rc_command "$1"