On pfSense 2.2.4 (FreeBSD 10.1), my custom init script filebeat_wrapper won't start at boot.
According to
The rc script works fine from the command-line, and
If I change the filename of the rc script to end in .sh (/usr/local/etc/rc.d/filebeat_wrapper.sh), then the script starts at boot (since it is interpreted as an old-style script), and everything else is happy -- providing that you include the `.sh` in your commands:
Why does my script need a .sh extension, when other rc scripts apparently do not?
Here is my file listing:
Here are the contents of the file (note that the rc script calls a python script of a similar name in /usr/local/bin)
According to
rcorder
it should start right after boot:
Code:
# rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
(snip)
/etc/rc.d/SERVERS
/etc/rc.d/DAEMON
/etc/rc.d/LOGIN
/usr/local/etc/rc.d/filebeat_wrapper
(snip)
The rc script works fine from the command-line, and
service filebeat_wrapper enabled
has a return code of 0
(meaning enabled, if I understand correctly, since it's a returncode).
Code:
# service filebeat_wrapper status
filebeat_wrapper is not running
# service filebeat_wrapper start
starting filebeat_wrapper
# service filebeat_wrapper status
filebeat_wrapper is running
# ps auxww | grep \[b\]eat
root 80780 75.9 0.3 13212 5536 - R 10:09PM 0:17.91 /usr/local/bin/python /usr/local/bin/filebeat_wrapper (python2.7)
root 81127 42.5 0.7 798488 14816 - S 10:09PM 0:10.12 /usr/local/bin/filebeat-freebsd-386 -c /usr/local/etc/filebeat.yml -e -v
# service filebeat_wrapper stop
stopping filebeat_wrapper
# service filebeat_wrapper status
filebeat_wrapper is not running
# service filebeat_wrapper enabled
# echo $?
0
If I change the filename of the rc script to end in .sh (/usr/local/etc/rc.d/filebeat_wrapper.sh), then the script starts at boot (since it is interpreted as an old-style script), and everything else is happy -- providing that you include the `.sh` in your commands:
Code:
# service filebeat_wrapper.sh status
filebeat_wrapper is running
Why does my script need a .sh extension, when other rc scripts apparently do not?
Here is my file listing:
Code:
# ls -l /usr/local/etc/rc.d/filebeat_wrapper.sh
-rwxr-xr-x 1 root wheel 876 Jul 13 21:48 /usr/local/etc/rc.d/filebeat_wrapper.sh
Here are the contents of the file (note that the rc script calls a python script of a similar name in /usr/local/bin)
Code:
#!/bin/sh
# PROVIDE: filebeat_wrapper
# REQUIRE: NETWORKING LOGIN
# KEYWORD: nojail shutdown
. /etc/rc.subr
name="filebeat_wrapper"
rcvar="filebeat_wrapper_enabled"
pidfile="/var/run/${name}.pid"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
load_rc_config $name
: ${filebeat_wrapper_enabled:="YES"}
filebeat_wrapper_flags="-p ${pidfile} -f"
command="/usr/local/bin/filebeat_wrapper"
filebeat_wrapper_start()
{
echo "starting ${name}"
/usr/sbin/daemon -f -p ${pidfile} /usr/local/bin/python ${command}
}
filebeat_wrapper_stop()
{
echo "stopping ${name}"
kill `cat ${pidfile}`
}
filebeat_wrapper_status()
{
if [ -e ${pidfile} ] ; then
if ps `cat ${pidfile}` > /dev/null ; then
echo "${name} is running"
return
fi
fi
echo "${name} is not running"
}
run_rc_command "$1"