author | Olivier Brunel
<jjk@jjacky.com> 2015-07-15 16:59:30 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2015-07-15 16:59:30 UTC |
parent | 2811b4e237c82c60d583d4898a41e8c3d2178de4 |
doc/aa-enable.pod | +3 | -0 |
doc/aa-start.pod | +3 | -0 |
src/anopa/aa-enable.c | +6 | -1 |
src/anopa/aa-start.c | +6 | -1 |
src/anopa/common.h | +28 | -0 |
diff --git a/doc/aa-enable.pod b/doc/aa-enable.pod index 224b436..8fec95d 100644 --- a/doc/aa-enable.pod +++ b/doc/aa-enable.pod @@ -50,6 +50,9 @@ The directory will be read, and names of files/directories within be used as service name to enable. For directories, their content will be merged/copied into the servicedir; See below for more. +If I<LISTDIR> doesn't start with a slash or dot, it will be prefixed with +I</etc/anopa/listdirs/> + =item B<-n, --no-needs> Don't auto-enable any services listed under directory I<needs> of a service diff --git a/doc/aa-start.pod b/doc/aa-start.pod index 3b541f6..2c3be07 100644 --- a/doc/aa-start.pod +++ b/doc/aa-start.pod @@ -27,6 +27,9 @@ Show help screen and exit. Use I<dir> to list services to start. Only one can be set, if specified more than once the last one will be used. +If I<dir> doesn't start with a slash or dot, it will be prefixed with +I</etc/anopa/listdirs/> + =item B<-r, --repodir> I<dir> Use I<dir> as repository directory. This is where servicedirs will be looked diff --git a/src/anopa/aa-enable.c b/src/anopa/aa-enable.c index 8dc1cfc..908f40e 100644 --- a/src/anopa/aa-enable.c +++ b/src/anopa/aa-enable.c @@ -48,6 +48,7 @@ #include <anopa/stats.h> #include <anopa/err.h> #include "util.h" +#include "common.h" #define SVSCANDIR ".scandir/.s6-svscan" @@ -310,10 +311,14 @@ main (int argc, char * const argv[]) * the one with (potentially) a config dir */ if (path_list) { + if (*path_list != '/' && *path_list != '.') + stralloc_cats (&sa_pl, LISTDIR_PREFIX); stralloc_catb (&sa_pl, path_list, strlen (path_list) + 1); r = aa_scan_dir (&sa_pl, 0, it_list, NULL); if (r < 0) - strerr_diefu2sys (-r, "read list directory ", path_list); + strerr_diefu3sys (-r, "read list directory ", + (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, + (*path_list != '/' && *path_list != '.') ? path_list : ""); } for (i = 0; i < argc; ++i) diff --git a/src/anopa/aa-start.c b/src/anopa/aa-start.c index 7117e09..baed8a9 100644 --- a/src/anopa/aa-start.c +++ b/src/anopa/aa-start.c @@ -56,6 +56,7 @@ #include <anopa/stats.h> #include "start-stop.h" #include "util.h" +#include "common.h" #define ESSENTIAL_FILENAME "essential" @@ -306,11 +307,15 @@ main (int argc, char * const argv[]) stralloc sa = STRALLOC_ZERO; int r; + if (*path_list != '/' && *path_list != '.') + stralloc_cats (&sa, LISTDIR_PREFIX); stralloc_catb (&sa, path_list, strlen (path_list) + 1); r = aa_scan_dir (&sa, 1, it_start, NULL); stralloc_free (&sa); if (r < 0) - strerr_diefu2sys (-r, "read list directory ", path_list); + strerr_diefu3sys (-r, "read list directory ", + (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, + (*path_list != '/' && *path_list != '.') ? path_list : ""); } tain_now_g (); diff --git a/src/anopa/common.h b/src/anopa/common.h new file mode 100644 index 0000000..6ccdc0b --- /dev/null +++ b/src/anopa/common.h @@ -0,0 +1,28 @@ +/* + * anopa - Copyright (C) 2015 Olivier Brunel + * + * common.h + * Copyright (C) 2015 Olivier Brunel <jjk@jjacky.com> + * + * This file is part of anopa. + * + * anopa is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * anopa is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * anopa. If not, see http://www.gnu.org/licenses/ + */ + +#ifndef _AA_COMMON_H +#define _AA_COMMON_H + +#define LISTDIR_PREFIX "/etc/anopa/listdirs/" + +#endif /* _AA_COMMON_H */