summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-12-14 12:23:13 +0000
committerRoy Marples <roy@marples.name>2007-12-14 12:23:13 +0000
commitb73bd04cf3f19b47480c85dd58e63eef5900fa3c (patch)
treeafffd113e089a7f3db06e3ef696499ab0170140f
parentf8db842dd2e93c37a5287beefeb425ae98dcdb4a (diff)
downloadopenrc-b73bd04cf3f19b47480c85dd58e63eef5900fa3c.tar.gz
openrc-b73bd04cf3f19b47480c85dd58e63eef5900fa3c.tar.bz2
openrc-b73bd04cf3f19b47480c85dd58e63eef5900fa3c.tar.xz
If we need to regenrate the deptree in the boot runlevel, remove it afterwards as the dependencies may need programs brought up by localmount. The dependencies will be regenerated correctly in the next runlevel.
-rw-r--r--src/builtins.h2
-rw-r--r--src/rc-depend.c7
-rw-r--r--src/rc.c10
-rw-r--r--src/runscript.c7
4 files changed, 18 insertions, 8 deletions
diff --git a/src/builtins.h b/src/builtins.h
index 9363f9e..1e7a534 100644
--- a/src/builtins.h
+++ b/src/builtins.h
@@ -37,4 +37,4 @@ int runscript (int argc, char **argv);
int start_stop_daemon (int argc, char **argv);
/* Handy function so we can wrap einfo around our deptree */
-rc_depinfo_t *_rc_deptree_load (void);
+rc_depinfo_t *_rc_deptree_load (int *regen);
diff --git a/src/rc-depend.c b/src/rc-depend.c
index d3e319f..de0125f 100644
--- a/src/rc-depend.c
+++ b/src/rc-depend.c
@@ -48,10 +48,13 @@
#include "rc-misc.h"
#include "strlist.h"
-rc_depinfo_t *_rc_deptree_load (void) {
+rc_depinfo_t *_rc_deptree_load (int *regen) {
if (rc_deptree_update_needed ()) {
int retval;
+ if (regen)
+ *regen = 1;
+
ebegin ("Caching service dependencies");
retval = rc_deptree_update ();
eend (retval ? 0 : -1, "Failed to update the dependency tree");
@@ -129,7 +132,7 @@ int rc_depend (int argc, char **argv)
eerrorx ("Failed to update the dependency tree");
}
- if (! (deptree = _rc_deptree_load ()))
+ if (! (deptree = _rc_deptree_load (NULL)))
eerrorx ("failed to load deptree");
if (! runlevel)
diff --git a/src/rc.c b/src/rc.c
index 8da7059..ae463be 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -803,6 +803,7 @@ int main (int argc, char **argv)
DIR *dp;
struct dirent *d;
bool parallel;
+ int regen = 0;
atexit (cleanup);
if (argv[0])
@@ -1105,7 +1106,7 @@ int main (int argc, char **argv)
}
/* Load our deptree now */
- if ((deptree = _rc_deptree_load ()) == NULL)
+ if ((deptree = _rc_deptree_load (&regen)) == NULL)
eerrorx ("failed to load deptree");
/* Clean the failed services state dir now */
@@ -1437,7 +1438,6 @@ int main (int argc, char **argv)
}
#endif
-
STRLIST_FOREACH (start_services, service, i) {
if (rc_service_state (service) & RC_SERVICE_STOPPED) {
pid_t pid;
@@ -1502,6 +1502,12 @@ interactive_option:
unlink (INTERACTIVE);
}
+ /* If we're in the boot runlevel and we regenerated our dependencies
+ * we need to delete them so that they are regenerated again in the
+ * default runlevel as they may depend on things that are now available */
+ if (regen && strcmp (runlevel, bootlevel) == 0)
+ unlink (RC_DEPTREE);
+
return (EXIT_SUCCESS);
}
diff --git a/src/runscript.c b/src/runscript.c
index e4089c2..88ce71b 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -684,7 +684,7 @@ static void svc_start (bool deps)
depoptions |= RC_DEP_START;
if (deps) {
- if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
+ if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (services);
@@ -898,7 +898,7 @@ static void svc_stop (bool deps)
if (rc_runlevel_stopping ())
depoptions |= RC_DEP_STOP;
- if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
+ if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (tmplist);
@@ -1078,6 +1078,7 @@ int runscript (int argc, char **argv)
/* Show help if insufficient args */
if (argc < 3) {
+ setenv ("SVCNAME", applet, 1);
execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
@@ -1259,7 +1260,7 @@ int runscript (int argc, char **argv)
if (rc_conf_yesno ("rc_depend_strict"))
depoptions |= RC_DEP_STRICT;
- if (! deptree && ((deptree = _rc_deptree_load ()) == NULL))
+ if (! deptree && ((deptree = _rc_deptree_load (NULL)) == NULL))
eerrorx ("failed to load deptree");
rc_strlist_free (services);