From 40e12f6ba026af9c24d5c3d8e36512719ed5faee Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 11 Mar 2008 15:00:16 +0000 Subject: RC_SERVICE now points to the service file, so daemons can recall us directly. --- sh.NetBSD/ifwatchd-carrier.sh.in | 2 +- sh.NetBSD/ifwatchd-nocarrier.sh.in | 2 +- sh/runscript.sh.in | 3 +++ src/rc/rc.c | 6 ++---- src/rc/start-stop-daemon.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sh.NetBSD/ifwatchd-carrier.sh.in b/sh.NetBSD/ifwatchd-carrier.sh.in index 4537b37..ec9c5ab 100644 --- a/sh.NetBSD/ifwatchd-carrier.sh.in +++ b/sh.NetBSD/ifwatchd-carrier.sh.in @@ -2,4 +2,4 @@ # Wrapper for ifwatchd(8) export IN_BACKGROUND=yes -@PREFIX@@SYSCONFDIR@/init.d/net.$1 --quiet start +${RC_SERVICE} --quiet start diff --git a/sh.NetBSD/ifwatchd-nocarrier.sh.in b/sh.NetBSD/ifwatchd-nocarrier.sh.in index d816868..3ba111c 100644 --- a/sh.NetBSD/ifwatchd-nocarrier.sh.in +++ b/sh.NetBSD/ifwatchd-nocarrier.sh.in @@ -2,4 +2,4 @@ # Wrapper for ifwatchd(8) export IN_BACKGROUND=yes -@PREFIX@@SYSCONFDIR@/init.d/net.$1 --quiet stop +${RC_SERVICE} --quiet stop diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 88e99bd..be69bb9 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -18,6 +18,9 @@ if [ -z "$1" -o -z "$2" ]; then exit 1 fi +# So daemons know where to recall us if needed +export RC_SERVICE="$1" + # Descript the init script to the user describe() { diff --git a/src/rc/rc.c b/src/rc/rc.c index 9aa0a6c..98b44cc 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -560,7 +560,6 @@ static void run_script (const char *script) eerrorx ("%s: failed to exec `%s'", applet, script); } -#ifndef PREFIX static void do_coldplug (void) { size_t s; @@ -661,7 +660,6 @@ static void do_coldplug (void) printf (" %s", service); printf ("%s\n", ecolor (ECOLOR_NORMAL)); } -#endif #include "_usage.h" #define getoptstring "o:" getoptstring_COMMON @@ -869,9 +867,9 @@ int main (int argc, char **argv) } #endif -#ifndef PREFIX + /* Setup our coldplugged services now */ do_coldplug (); -#endif + rc_plugin_run (RC_HOOK_RUNLEVEL_START_OUT, newlevel); hook_out = 0; diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index d0e168a..9ffeba0 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -966,7 +966,8 @@ int start_stop_daemon (int argc, char **argv) /* Clean the environment of any RC_ variables */ STRLIST_FOREACH (environ, env, i) { - if (strncmp (env, "RC_", 3) == 0 || + if ((strncmp (env, "RC_", 3) == 0 && + strncmp (env, "RC_SERVICE=", strlen ("RC_SERVICE=")) != 0) || strncmp (env, "SSD_NICELEVEL=", strlen ("SSD_NICELEVEL=")) == 0) continue; -- cgit v1.2.3