Date: Thu, 13 Dec 2012 19:52:13 -0600 From: Paul Schmehl <pschmehl_lists@tx.rr.com> To: FreeBSD RC <freebsd-rc@freebsd.org> Subject: rc.subr problems Message-ID: <45B2D630BD52C8D7082E736E@Pauls-MacBook-Pro.local>
next in thread | raw e-mail | index | archive | help
I'm working on updating the sguil ports; security/sguil-server, security/sguil-sensor and security/sguil-client. Right now I'm trying to get the startup script working for sguil-server, and I'm banging my head against the wall. The server is a tcl script that begins like all the other scripts: #!/bin/sh # Run tcl from users PATH \ exec tclsh "$0" "$@" I can start it from the commandline with no problem like this: # sh /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/sguild.pid 2012-12-14 01:45:19 pid(68134) Loading access list: /usr/local/etc/sguild/sguild.access 2012-12-14 01:45:19 pid(68134) Sensor access list set to ALLOW ANY. 2012-12-14 01:45:19 pid(68134) Client access list set to ALLOW ANY. This launches sguild as a daemon and forks two child processes, all running under the user sguil. # ps -auxw | grep sguild sguil 68136 0.0 0.1 28240 8524 1 I 1:45AM 0:00.02 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/ sguil 68140 0.0 0.1 28240 8392 1 S 1:45AM 0:00.00 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/ sguil 68141 0.0 0.1 28240 8396 1 I 1:45AM 0:00.00 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/ If I run the rc script, I get this: # /usr/local/etc/rc.d/sguild start /usr/local/etc/rc.d/sguild: unknown directive '/usr/local/bin/sguild'. Usage: /usr/local/etc/rc.d/sguild [fast|force|one|quiet](start|stop|restart|rcvar|status|poll) Here's the guts of the startup script: . /etc/rc.subr name="sguild" load_rc_config ${name} # set some defaults sguild_enable=${sguild_enable:-"NO"} sguild_conf=${sguild_conf:-"/usr/local/etc/sguild/sguild.conf"} sguild_pid=${sguild_pid:-"/var/run/sguild/sguild.pid"} sguild_flags=${sguild_flags:-"-D -P ${sguild_pid}"} sguild_user=${sguild_user:-"sguil"} command="/usr/local/bin/${name}" command_args="-c ${sguild_conf} ${sguild_flags}" procname="/usr/local/bin/tclsh8.5" start_cmd="sh ${command} ${command_args}" run_rc_command "$1" When I read through the rc.subr script, I gather that unknown directive is the script bailing because it has no idea what to do. Yet when I run stop, it works fine: # /usr/local/etc/rc.d/sguild stop Stopping sguild. SGUILD: killing child procs... SGUILD: Exiting... This makes no sense to me. If I add command_interpreter="/bin/sh" or command_interpreter="/usr/local/bin/tclsh8.5", I get this: # /usr/local/etc/rc.d/sguild start /usr/local/etc/rc.d/sguild: WARNING: no shebang line in /usr/local/bin/tclsh8.5 /usr/local/etc/rc.d/sguild: WARNING: no shebang line in /usr/local/bin/tclsh8.5 /usr/local/etc/rc.d/sguild: unknown directive '/usr/local/bin/sguild'. Usage: /usr/local/etc/rc.d/sguild [fast|force|one|quiet](start|stop|restart|rcvar|status|poll) Clearly I'm missing something, but I have no idea what it is. This same script works fine in the current port version. Paul Schmehl, Senior Infosec Analyst As if it wasn't already obvious, my opinions are my own and not those of my employer. ******************************************* "It is as useless to argue with those who have renounced the use of reason as to administer medication to the dead." Thomas Jefferson "There are some ideas so wrong that only a very intelligent person could believe in them." George Orwell
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45B2D630BD52C8D7082E736E>