How to implement a service?

Hi,

could you please give me a hint on how to implement a service that runs automatically on boot?

It depends on bluetoothd having been started and then needs to run two commands:

/usr/bin/rfcomm watch hci0 1 /usr/sbin/agetty --8bits --noclear -L rfcomm0 115200 linux --autologin mh

This command blocks as it waits for incoming bluetooth connections, so you cannot simply wait for it to return.
And after that this needs to run:

sdptool add --channel=1 SP

Can I do that with the procd infrastructure?

Many thanks!

Yes, you will find examples under /etc/init.d/ and/ or the package sources for OpenWrt and its package(s) feeds, afaik the wiki also has some documentation about procd.

3 Likes

Yes. For reference and as noted prior, most of the relevant wiki documentation Can be found here

3 Likes

So as far as I understand it there is no real dependency management right?

So if I depend on bluetoothd running all I can do is to give it a start-number higher than bluetoothd's - is that how it works?

And in my case I need to run 2 commands, so I guess there are 2 ways to do it:

You could put these commands into a script-file and have one service starting this script or you could have 2 services, each running one command.

Is the choice between these options purely a matter of taste or would you prefer one?