diff options
author | Roy Marples <roy@marples.name> | 2008-03-03 10:33:42 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-03-03 10:33:42 +0000 |
commit | 0aedc0286040b595119b4523d38ffd35b0018d6c (patch) | |
tree | 32ab5aca002067f07bbc45fcd34a3fd769c73468 /src | |
parent | 5971d14afd7e67b088307cd589f84491e99625ed (diff) |
Introduce LOCAL_PREFIX for a user maintained script location.
Diffstat (limited to 'src')
-rw-r--r-- | src/includes/rc-misc.h | 9 | ||||
-rw-r--r-- | src/librc/librc-depend.c | 6 | ||||
-rw-r--r-- | src/librc/librc.c | 26 |
3 files changed, 36 insertions, 5 deletions
diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h index 1294ed28..2f4b3643 100644 --- a/src/includes/rc-misc.h +++ b/src/includes/rc-misc.h @@ -62,7 +62,14 @@ * /usr/pkg. */ #ifdef PKG_PREFIX # define RC_PKG_INITDIR PKG_PREFIX "/etc/init.d" -# define RC_PKG_CONFDIR PKG_PREFIX "/usr/local/etc/conf.d" +# define RC_PKG_CONFDIR PKG_PREFIX "/etc/conf.d" +#endif + +/* LOCAL_PREFIX is for user written stuff, which the base OS and package + * manger don't touch. */ +#ifdef LOCAL_PREFIX +# define RC_LOCAL_INITDIR LOCAL_PREFIX "/etc/init.d" +# define RC_LOCAL_CONFDIR LOCAL_PREFIX "/etc/conf.d" #endif #define RC_KSOFTLEVEL RC_SVCDIR "/ksoftlevel" diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c index 1ab2b604..1718e22d 100644 --- a/src/librc/librc-depend.c +++ b/src/librc/librc-depend.c @@ -702,6 +702,12 @@ bool rc_deptree_update_needed (void) #ifdef RC_PKG_CONFDIR ! rc_newer_than (RC_DEPTREE, RC_PKG_CONFDIR) || #endif +#ifdef RC_LOCAL_INITDIR + ! rc_newer_than (RC_DEPTREE, RC_LOCAL_INITDIR) || +#endif +#ifdef RC_LOCAL_CONFDIR + ! rc_newer_than (RC_DEPTREE, RC_LOCAL_CONFDIR) || +#endif ! rc_newer_than (RC_DEPTREE, "/etc/rc.conf")) return (true); diff --git a/src/librc/librc.c b/src/librc/librc.c index d292e856..e023efbe 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -313,6 +313,7 @@ char *rc_service_resolve (const char *service) if (service[0] == '/') return (xstrdup (service)); + /* First check started services */ file = rc_strcatpaths (RC_SVCDIR, "started", service, (char *) NULL); if (lstat (file, &buf) || ! S_ISLNK (buf.st_mode)) { free (file); @@ -324,6 +325,14 @@ char *rc_service_resolve (const char *service) } memset (buffer, 0, sizeof (buffer)); + + /* Nope, so lets see if the user has written it */ +#ifdef RC_LOCAL_INITDIR + snprintf (buffer, sizeof (buffer), RC_LOCAL_INITDIR "/%s", service); + if (stat (buffer, &buf) == 0) + return (xstrdup (buffer)); +#endif + if (file) { r = readlink (file, buffer, sizeof (buffer)); free (file); @@ -332,7 +341,7 @@ char *rc_service_resolve (const char *service) } snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service); - /* So we don't exist in /etc/init.d - check /usr/local/etc/init.d */ + /* So we don't exist in /etc/init.d - check RC_PKG_INITDIR */ #ifdef RC_PKG_INITDIR if (stat (buffer, &buf) != 0) { snprintf (buffer, sizeof (buffer), RC_PKG_INITDIR "/%s", service); @@ -787,19 +796,28 @@ char **rc_services_in_runlevel (const char *runlevel) char **list = NULL; if (! runlevel) { -#ifdef RC_PKG_INITDIR +#if defined(RC_PKG_INITDIR) || defined(RC_LOCAL_INITDIR) int i; - char **local = ls_dir (RC_PKG_INITDIR, LS_INITD); +#endif +#ifdef RC_PKG_INITDIR + char **pkg = ls_dir (RC_PKG_INITDIR, LS_INITD); +#endif +#ifdef RC_LOCAL_INITDIR + char **local = ls_dir (RC_LOCAL_INITDIR, LS_INITD); #endif list = ls_dir (RC_INITDIR, LS_INITD); #ifdef RC_PKG_INITDIR + STRLIST_FOREACH (pkg, dir, i) + rc_strlist_addsortu (&list, dir); + rc_strlist_free (pkg); +#endif +#ifdef RC_LOCAL_DIR STRLIST_FOREACH (local, dir, i) rc_strlist_addsortu (&list, dir); rc_strlist_free (local); #endif - return (list); } |