diff options
| author | Nora Schiffer | 2026-02-09 23:30:43 +0000 |
|---|---|---|
| committer | Nora Schiffer | 2026-02-20 21:55:59 +0000 |
| commit | 2881a59f304326cf0a71c849738d052ba317b4cb (patch) | |
| tree | e3d4a452eefd3428fe4091512c1697fd9ee7a860 | |
| parent | 4e4a34b1a833505ad274d973b3e86c8b5ebcdd8d (diff) | |
rcS: allow overriding init.d/rc.d paths
Introduce -I and -R arguments which can be used to override the paths
/etc/init.d and /etc/rc.d, allowing for some runlevel-like usecases.
This will be used in Gluon [1] to support a 'config mode', which is
currently realized using a downstream patch.
[1] https://github.com/freifunk-gluon/gluon
Signed-off-by: Nora Schiffer <neocturne@universe-factory.net>
| -rw-r--r-- | procd.c | 10 | ||||
| -rw-r--r-- | procd.h | 3 | ||||
| -rw-r--r-- | rcS.c | 7 |
3 files changed, 17 insertions, 3 deletions
@@ -83,6 +83,8 @@ static int usage(const char *prog) " -s <path> Path to ubus socket\n" " -h <path> run as hotplug daemon\n" " -d <level> Enable debug messages\n" + " -I <path> Path to init.d directory\n" + " -R <path> Path to rc.d directory\n" " -S Print messages to stdout\n" "\n", prog); return 1; @@ -99,7 +101,7 @@ int main(int argc, char **argv) unsetenv("DBGLVL"); } - while ((ch = getopt(argc, argv, "d:s:h:S")) != -1) { + while ((ch = getopt(argc, argv, "d:s:h:I:R:S")) != -1) { switch (ch) { case 'h': return hotplug_run(optarg); @@ -109,6 +111,12 @@ int main(int argc, char **argv) case 'd': debug = atoi(optarg); break; + case 'I': + init_d_path = optarg; + break; + case 'R': + rc_d_path = optarg; + break; case 'S': ulog_channels = ULOG_STDIO; break; @@ -27,6 +27,9 @@ #define __init __attribute__((constructor)) +extern const char *init_d_path; +extern const char *rc_d_path; + extern const char *ubus_socket; void procd_connect_ubus(void); @@ -33,6 +33,9 @@ #include "procd.h" #include "rcS.h" +const char *init_d_path = "/etc/init.d"; +const char *rc_d_path = "/etc/rc.d"; + static struct runqueue q, r; struct initd { @@ -200,12 +203,12 @@ int rcS(const char *pattern, const char *param, void (*q_empty)(struct runqueue q.empty_cb = q_empty; q.max_running_tasks = 1; - return _rc(&q, "/etc/rc.d", pattern, "*", param); + return _rc(&q, rc_d_path, pattern, "*", param); } int rc(const char *file, const char *param) { - return _rc(&r, "/etc/init.d", file, "", param); + return _rc(&r, init_d_path, file, "", param); } static void r_empty(struct runqueue *q) |