[LEDE-DEV] [RFC 1/1] base-files/etc/rc.common: allow services to overwrite PROCD functions

Zefir Kurtisi zefir.kurtisi at neratec.com
Mon Nov 20 05:25:20 PST 2017

On 11/20/2017 01:27 PM, Felix Fietkau wrote:
> On 2017-11-20 11:20, Zefir Kurtisi wrote:
>> PROCD services can't overwrite those functions defined in the
>> USE_PROCD body (like stop()), since the initfile is sourced
>> before.
>> This change moves the sourcing below and with that allows
>> PROCD init scripts to overwrite them.
>> Signed-off-by: Zefir Kurtisi <zefir.kurtisi at neratec.com>
> This seems broken to me. USE_PROCD is defined by the init script, so you
> can't test for it before the script has been sourced.
> - Felix
This was my initial assumption, but in fact it works as expected (for PROCD and
legacy services). Running 'INIT_TRACE=y /etc/init.d/log shows that USE_PROCD is
set correctly during execution.

Why it does I don't understand, since when
* /etc/init.d/log starts with '#!/bin/sh /etc/rc.common'
* in /etc/rc.common, the initscript is sourced again

... I expected this to be a circular dependency, but what it does is:
1. interpreting all the variables set in initscript (including USE_PROCD=1)
2. interpreting all the variables set in rc.common
   (starting with [ -n "$USE_PROCD" ])
3. executing the functions

Could not find enough information about how shebanging a shell-script is executed.

Does somebody know and could please clarify?


More information about the Lede-dev mailing list