Need help with rc.d script

krad kraduk at gmail.com
Thu Nov 9 15:11:07 UTC 2017


here is an rc script i wrote that handles something similar

#!/bin/sh
#
# $FreeBSD: head/net/lightsg/files/lightsd.in 367807 2014-09-10 09:36:24Z
ehaupt $
#

# PROVIDE: lightsd
# REQUIRE: LOGIN
# BEFORE:  securelevel
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `lightsd':
#
# lightsd_enable="YES"
# lightsd_flags="<set as needed>"
#
# See lightsg(1) for lightsd_flags
#

. /etc/rc.subr

name="lightsd"
rcvar=lightsd_enable

command="/usr/sbin/daemon"
start_precmd="lightsd_precmd"
pidfile="/var/run/lightsd/$name.pid"

# read configuration and set defaults
load_rc_config "$name"
: ${lightsd_enable="NO"}
: ${lightsd_user:="lightsd"}
: ${lightsd_group:="lightsd"}
: ${lightsd_listen:="localhost:23456"}
: ${lightsd_log:="info"}
: ${lightsd_flags:=""}


command_args="-P $pidfile -p ${pidfile}_child -r /usr/local/bin/$name -l
${lightsd_listen} -v $lightsd_log -S $lightsd_flags 2>&1  "
#command_args="-l ${lightsd_listen} -v debug "

lightsd_precmd()
{
  if [ ! -d "/var/run/lightsd/" ] ; then
    mkdir -pv /var/run/lightsd/
    chown ${lightsd_user}:${lightsd_group} /var/run/lightsd/
  fi
}

run_rc_command "$1"


On 7 November 2017 at 14:46, Ernie Luzar <luzar722 at gmail.com> wrote:

> Tried to use the daemon command in the rc.d script with no joy.
>
> this is in the rc.d script
> . /etc/rc.subr
> name=dynip
> rcvar=dynip_enable
> command="/usr/sbin/daemon /usr/local/bin/${name}"
> run_rc_command "$1"
>
> When I use the service command I get this
> /usr/local/etc/rc.d >service dynip onestart
> /usr/local/etc/rc.d/dynip: WARNING: no shebang line in /usr/sbin/daemon
> /usr/local/etc/rc.d/dynip: WARNING: run_rc_command: cannot run
> /usr/sbin/daemon
> /usr/local/bin/dynip
>
> When I run from the command line using this
>
> daemon /usr/local/bin/dynip
>
> ps ax shows it running and has a child task for sleep and it has
> disconnected itself from the terminal that issued the command. But it seems
> to be hung.
>
> Any other suggestions I can try.
>


More information about the freebsd-questions mailing list