From 6e2ef07dd32af0a672266401bad550a072ff0443 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 8 Apr 2007 16:03:48 +0000 Subject: LIBDIR -> LIB. When interuppted, ensure service state is restored correctly. When stopping, don't uncoldplug too early. --- src/Makefile | 2 +- src/librc-misc.c | 12 +++++++----- src/rc-misc.h | 6 +++--- src/rc.c | 2 +- src/runscript.c | 21 +++++++++++++-------- src/splash.c | 6 +++--- 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3104626f..4dd0e901 100644 --- a/src/Makefile +++ b/src/Makefile @@ -77,7 +77,7 @@ endif # We also define _BSD_SOURCE so both Linux and the BSDs get a few # handy functions which makes our lives a lot easier -override CFLAGS += -DLIBDIR=\"$(LIB)\" +override CFLAGS += -DLIB=\"$(LIB)\" # IMPORTANT!!! # Remove this when releasing as it's a security risk diff --git a/src/librc-misc.c b/src/librc-misc.c index 9cfd925f..fcb536f2 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -637,15 +637,17 @@ char **rc_config_env (char **env) } rc_strlist_free (config); - i = strlen ("RC_LIBDIR=//rcscripts") + strlen (LIBDIR) + 2; + /* One char less to drop the trailing / */ + i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR); line = rc_xmalloc (sizeof (char *) * i); - snprintf (line, i, "RC_LIBDIR=/" LIBDIR "/rcscripts"); + snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR); env = rc_strlist_add (env, line); free (line); - - i += strlen ("/init.d"); + + /* One char less to drop the trailing / */ + i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR); line = rc_xmalloc (sizeof (char *) * i); - snprintf (line, i, "RC_SVCDIR=/" LIBDIR "/rcscripts/init.d"); + snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR); env = rc_strlist_add (env, line); free (line); diff --git a/src/rc-misc.h b/src/rc-misc.h index 5a4aa55f..20dc74f7 100644 --- a/src/rc-misc.h +++ b/src/rc-misc.h @@ -7,11 +7,11 @@ #ifndef __RC_MISC_H__ #define __RC_MISC_H__ -#ifndef LIBDIR -# define LIBDIR "lib" +#ifndef LIB +# define LIB "lib" #endif -#define RC_LIBDIR "/" LIBDIR "/rcscripts/" +#define RC_LIBDIR "/" LIB "/rcscripts/" #define RC_SVCDIR RC_LIBDIR "init.d/" #define RC_DEPTREE RC_SVCDIR "deptree" #define RC_RUNLEVELDIR "/etc/runlevels/" diff --git a/src/rc.c b/src/rc.c index 9b7d0edb..48fb9089 100644 --- a/src/rc.c +++ b/src/rc.c @@ -1109,7 +1109,7 @@ int main (int argc, char **argv) sulogin (false); } - mkdir (RC_SVCDIR "/softscripts.old", 0755); + mkdir (RC_SVCDIR "softscripts.old", 0755); rc_plugin_run (rc_hook_runlevel_start_in, runlevel); /* Re-add our coldplugged services if they stopped */ diff --git a/src/runscript.c b/src/runscript.c index 9a761482..d87d42f0 100644 --- a/src/runscript.c +++ b/src/runscript.c @@ -231,19 +231,21 @@ static void cleanup (void) { if (rc_service_state (applet, rc_service_wasinactive)) rc_mark_service (applet, rc_service_inactive); - else + else rc_mark_service (applet, rc_service_stopped); } else if (rc_service_state (applet, rc_service_stopping)) { /* If the we're shutting down, do it cleanly */ - if ((softlevel && rc_runlevel_stopping () && + if ((softlevel && + rc_runlevel_stopping () && (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (softlevel, RC_LEVEL_REBOOT) == 0)) || - ! rc_service_state (applet, rc_service_wasinactive)) + strcmp (softlevel, RC_LEVEL_REBOOT) == 0))) rc_mark_service (applet, rc_service_stopped); - else + else if (rc_service_state (applet, rc_service_wasinactive)) rc_mark_service (applet, rc_service_inactive); + else + rc_mark_service (applet, rc_service_started); } if (exclusive && rc_exists (exclusive)) unlink (exclusive); @@ -1049,11 +1051,14 @@ int main (int argc, char **argv) { if (in_background) get_started_services (); - else if (! rc_runlevel_stopping ()) - uncoldplug (applet); svc_stop (service, deps); + if (! in_background && + ! rc_runlevel_stopping () && + rc_service_state (service, rc_service_stopped)) + uncoldplug (applet); + if (in_background && rc_service_state (service, rc_service_inactive)) { @@ -1069,7 +1074,7 @@ int main (int argc, char **argv) einfo ("Manually resetting %s to stopped state", applet); rc_mark_service (applet, rc_service_stopped); uncoldplug (applet); - } + } else if (strcmp (argv[i], "help") == 0) { execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", (char *) NULL); diff --git a/src/splash.c b/src/splash.c index 3a4edfd9..dbea79a2 100644 --- a/src/splash.c +++ b/src/splash.c @@ -22,11 +22,11 @@ #include -#ifndef LIBDIR -# define LIBDIR "lib" +#ifndef LIB +# define LIB "lib" #endif -#define SPLASH_CACHEDIR "/" LIBDIR "/splash/cache" +#define SPLASH_CACHEDIR "/" LIB "/splash/cache" #define SPLASH_CMD "bash -c 'export SOFTLEVEL='%s'; export BOOTLEVEL=${RC_BOOTLEVEL}; export DEFAULTLEVEL=${RC_DEFAULTLEVEL}; export svcdir=${RC_SVCDIR}; add_suffix() { echo \"$@\"; }; . /etc/init.d/functions.sh; . /sbin/splash-functions.sh; splash %s %s %s'" -- cgit v1.2.3