I'm looking at a static OpenWrt firmware. On OpenWrt initialization, procd is supposed to run all the S prefixed scripts in /etc/rc.d which are links to the actual scripts in /etc/init.d. I wonder who triggers those scripts...

I see that on /etc/inittab there's this line ::sysinit:/etc/init.d/rcS S boot but /etc/init.d/rcS file does not exist, so who actually runs the scripts on /etc/rc.d and when does it happen on init?

I tried searching all over their documentation but still could not figure this out... Any ideas?

Thanks.

asked Mar 9, 2021 at 10:05

Gal Shahar's user avatar

Gal ShaharGal Shahar

2,8152 gold badges24 silver badges30 bronze badges

1

You can check details in procd init

procd actually ignores the process specification "/etc/init.d/rcS" (there is no such a script!) in "/etc/inittab".

The implementation is in rcS.c:

int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
{
    runqueue_init(&q);
    q.empty_cb = q_empty;
    q.max_running_tasks = 1;

    return _rc(&q, "/etc/rc.d", pattern, "*", param);
}

which is called by "runrc" function in inittab.c

static void runrc(struct init_action *a)
{
    if (!a->argv[1] || !a->argv[2]) {
        ERROR("valid format is rcS <S|K> <param>\n");
        return;
    }

    /* proceed even if no init or shutdown scripts run */
    if (rcS(a->argv[1], a->argv[2], rcdone))
        rcdone(NULL);
}

answered Sep 11, 2024 at 1:19

joez's user avatar

joezjoez

262 bronze badges

Hi the openwrt using the program procd to run the /etc/init.d/* to init the all system. The boot sequence of openwrt is:

 /init - > /sbin/init -> /etc/preinit -> /sbin/procd -> /etc/rc.d/*

Actually openwrt always support the rcS, but openwrt didn't use this feature.

answered Mar 22, 2021 at 3:13

jack ma's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.