Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Feb 2024 22:54:33 +0100
From:      Milan Obuch <freebsd-hackers@dino.sk>
To:        freebsd-hackers@freebsd.org
Subject:   Re: rcorder question
Message-ID:  <20240214225433.319d1c2d@zeta.dino.sk>
In-Reply-To: <B9DB6A7C-8412-40EC-B8C4-98A8C731D597@FreeBSD.org>
References:  <20240213121936.2c0fc4c0@zeta.dino.sk> <B9DB6A7C-8412-40EC-B8C4-98A8C731D597@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 13 Feb 2024 11:27:44 +0000
David Chisnall <theraven@FreeBSD.org> wrote:

> A quick look at teh socat RC script suggests that it contains this
> line:
>=20
> # PROVIDE: socat
>=20
> You should be able to simply add:
>=20
> # REQUIRE: socat
>=20
> And your service will start after socat.  But to do that you need to
> not use `rc.local` and instead provide a separate RC script.  There
> are some examples in the man page and the web site:
>=20
> https://man.freebsd.org/cgi/man.cgi?query=3Drc
>=20
> https://docs.freebsd.org/en/articles/rc-scripting/
>=20
> In general, I wouldn=E2=80=99t use rc.local for anything that has
> dependencies outside of rc.local (or, in fact, for anything).  If you
> have a service that needs to be started after something else, then
> put it in etc/rc.d and enable it via rc.conf (or, ideally, something
> in rc.conf.d).  If you want to move it to a different machine, you
> now just need to copy the files across rather than extract bits of
> config files (this also makes it easier to create packages for it, if
> you wish to automate installation). =20
>=20
> David
>=20

Thanks for pointer, I created simple script and it looks like it works
as expected:

--- 8< ---------------------------------

#!/bin/sh

# PROVIDE: scex
# REQUIRE: socat

. /etc/rc.subr

name=3Dscex
rcvar=3Dscex_enable=20

start_cmd=3D"${name}_start"
stop_cmd=3D":"

load_rc_config $name=20
: ${scex_enable:=3Dno}=20

scex_start()
{
        /usr/local/bin/init_program
        /usr/local/bin/main_program /dev/cuaV0 &
}

run_rc_command "$1"

--- 8< ---------------------------------

For it to run, I added to /etc/rc.conf:

scex_enable=3D"YES"

There is no stop instruction, but it is just enough for my purpose at
the moment. Is there anything which would be recommended to change?

Regards,
Milan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20240214225433.319d1c2d>