author | Olivier Brunel
<jjk@jjacky.com> 2017-06-25 16:16:16 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2017-06-25 16:16:16 UTC |
parent | 3685c2eb0360837e431887364b86ad12b93a03b9 |
doc/aa-enable.pod | +14 | -0 |
doc/aa-reset.pod | +14 | -0 |
doc/aa-start.pod | +14 | -0 |
doc/aa-status.pod | +14 | -0 |
doc/aa-stop.pod | +14 | -0 |
src/anopa/aa-enable.c | +2 | -1 |
src/anopa/aa-reset.c | +2 | -1 |
src/anopa/aa-start.c | +2 | -1 |
src/anopa/aa-status.c | +2 | -1 |
src/anopa/aa-stop.c | +2 | -1 |
src/include/anopa/get_repodir.h | +28 | -0 |
src/libanopa/deps-lib/anopa | +1 | -0 |
src/libanopa/get_repodir.c | +42 | -0 |
diff --git a/doc/aa-enable.pod b/doc/aa-enable.pod index 8602049..a1f5596 100644 --- a/doc/aa-enable.pod +++ b/doc/aa-enable.pod @@ -265,3 +265,17 @@ that those specified: - If servicedir already exists in repodir, nothing is done - Else, they are enabled as usual (i.e. as if without the B<--upgrade> option) + +=head1 ENVIRONMENT VARIABLES + +The following environment variables are used : + +=over + +=item B<AA_REPODIR> + +The full path to the repository directory, unless specified via B<--repodir> If +neither the environment variable nor the option are used, defaults to +I</run/services> + +=back diff --git a/doc/aa-reset.pod b/doc/aa-reset.pod index aa2c6a5..5d55f32 100644 --- a/doc/aa-reset.pod +++ b/doc/aa-reset.pod @@ -60,3 +60,17 @@ Note that a service either "Starting" or "Stopping" will never be reset. You can use B<-> as service name to read actual service names from stdin, where there must be one name per line. + +=head1 ENVIRONMENT VARIABLES + +The following environment variables are used : + +=over + +=item B<AA_REPODIR> + +The full path to the repository directory, unless specified via B<--repodir> If +neither the environment variable nor the option are used, defaults to +I</run/services> + +=back diff --git a/doc/aa-start.pod b/doc/aa-start.pod index 03cef70..c237114 100644 --- a/doc/aa-start.pod +++ b/doc/aa-start.pod @@ -230,3 +230,17 @@ not that there should be a need for it anyways. Also note that once B<aa-start>(1) received a demand of password input, it will disable the service's timeout, restoring it once it has been processed (e.g. user input has been written to the service's stdin) and resetting its timer. + +=head1 ENVIRONMENT VARIABLES + +The following environment variables are used : + +=over + +=item B<AA_REPODIR> + +The full path to the repository directory, unless specified via B<--repodir> If +neither the environment variable nor the option are used, defaults to +I</run/services> + +=back diff --git a/doc/aa-status.pod b/doc/aa-status.pod index 37b0989..da41546 100644 --- a/doc/aa-status.pod +++ b/doc/aa-status.pod @@ -260,3 +260,17 @@ end-of-finish ('D') are shown, though in list mode (option B<--list>) only the later in shown. =back + +=head1 ENVIRONMENT VARIABLES + +The following environment variables are used : + +=over + +=item B<AA_REPODIR> + +The full path to the repository directory, unless specified via B<--repodir> If +neither the environment variable nor the option are used, defaults to +I</run/services> + +=back diff --git a/doc/aa-stop.pod b/doc/aa-stop.pod index 6bf0755..a97f39d 100644 --- a/doc/aa-stop.pod +++ b/doc/aa-stop.pod @@ -141,3 +141,17 @@ was already (being) done. Obviously, the script used is I<stop> and not I<start>. Other than that, the process is much the same, so you can refer to B<aa-start>(1) for more. + +=head1 ENVIRONMENT VARIABLES + +The following environment variables are used : + +=over + +=item B<AA_REPODIR> + +The full path to the repository directory, unless specified via B<--repodir> If +neither the environment variable nor the option are used, defaults to +I</run/services> + +=back diff --git a/src/anopa/aa-enable.c b/src/anopa/aa-enable.c index d0dd70f..b0863eb 100644 --- a/src/anopa/aa-enable.c +++ b/src/anopa/aa-enable.c @@ -41,6 +41,7 @@ #include <s6/s6-supervise.h> #include <anopa/common.h> #include <anopa/output.h> +#include <anopa/get_repodir.h> #include <anopa/init_repo.h> #include <anopa/scan_dir.h> #include <anopa/enable_service.h> @@ -220,7 +221,7 @@ int main (int argc, char * const argv[]) { PROG = "aa-enable"; - const char *path_repo = "/run/services"; + const char *path_repo = aa_get_repodir (); const char *path_list = NULL; const char *set_crash = NULL; const char *set_finish = NULL; diff --git a/src/anopa/aa-reset.c b/src/anopa/aa-reset.c index 8f31940..0c005bc 100644 --- a/src/anopa/aa-reset.c +++ b/src/anopa/aa-reset.c @@ -31,6 +31,7 @@ #include <skalibs/bytestr.h> #include <anopa/common.h> #include <anopa/output.h> +#include <anopa/get_repodir.h> #include <anopa/init_repo.h> #include <anopa/service.h> #include <anopa/service_status.h> @@ -147,7 +148,7 @@ int main (int argc, char * const argv[]) { PROG = "aa-reset"; - const char *path_repo = "/run/services"; + const char *path_repo = aa_get_repodir (); intptr_t mode = MODE_NONE; int i; int r; diff --git a/src/anopa/aa-start.c b/src/anopa/aa-start.c index d734be5..dd90c60 100644 --- a/src/anopa/aa-start.c +++ b/src/anopa/aa-start.c @@ -44,6 +44,7 @@ #include <skalibs/types.h> #include <anopa/common.h> #include <anopa/err.h> +#include <anopa/get_repodir.h> #include <anopa/init_repo.h> #include <anopa/output.h> #include <anopa/scan_dir.h> @@ -242,7 +243,7 @@ int main (int argc, char * const argv[]) { PROG = "aa-start"; - const char *path_repo = "/run/services"; + const char *path_repo = aa_get_repodir (); const char *path_list = NULL; int i; diff --git a/src/anopa/aa-status.c b/src/anopa/aa-status.c index f116fd5..6366824 100644 --- a/src/anopa/aa-status.c +++ b/src/anopa/aa-status.c @@ -45,6 +45,7 @@ #include <s6/s6-supervise.h> #include <anopa/common.h> #include <anopa/output.h> +#include <anopa/get_repodir.h> #include <anopa/init_repo.h> #include <anopa/scan_dir.h> #include <anopa/service.h> @@ -813,7 +814,7 @@ int main (int argc, char * const argv[]) { PROG = "aa-status"; - const char *path_repo = "/run/services"; + const char *path_repo = aa_get_repodir (); const char *path_list = NULL; struct config cfg = { 0, }; int (*sort_fn) (const void *, const void *) = cmp_serv_stamp; diff --git a/src/anopa/aa-stop.c b/src/anopa/aa-stop.c index 3864dac..457fc67 100644 --- a/src/anopa/aa-stop.c +++ b/src/anopa/aa-stop.c @@ -39,6 +39,7 @@ #include <s6/s6-supervise.h> #include <anopa/common.h> #include <anopa/err.h> +#include <anopa/get_repodir.h> #include <anopa/init_repo.h> #include <anopa/output.h> #include <anopa/scan_dir.h> @@ -308,7 +309,7 @@ int main (int argc, char * const argv[]) { PROG = "aa-stop"; - const char *path_repo = "/run/services"; + const char *path_repo = aa_get_repodir (); const char *path_list = NULL; int all = 0; int i; diff --git a/src/include/anopa/get_repodir.h b/src/include/anopa/get_repodir.h new file mode 100644 index 0000000..126940a --- /dev/null +++ b/src/include/anopa/get_repodir.h @@ -0,0 +1,28 @@ +/* + * anopa - Copyright (C) 2015-2017 Olivier Brunel + * + * get_repodir.h + * Copyright (C) 2017 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_GET_REPODIR_H +#define AA_GET_REPODIR_H + +const char * aa_get_repodir (void); + +#endif /* AA_GET_REPODIR_H */ diff --git a/src/libanopa/deps-lib/anopa b/src/libanopa/deps-lib/anopa index 37bf943..14dc482 100644 --- a/src/libanopa/deps-lib/anopa +++ b/src/libanopa/deps-lib/anopa @@ -7,6 +7,7 @@ eventmsg.o exec_longrun.o exec_oneshot.o ga_list.o +get_repodir.o init_repo.o output.o progress.o diff --git a/src/libanopa/get_repodir.c b/src/libanopa/get_repodir.c new file mode 100644 index 0000000..892a93c --- /dev/null +++ b/src/libanopa/get_repodir.c @@ -0,0 +1,42 @@ +/* + * anopa - Copyright (C) 2015-2017 Olivier Brunel + * + * get_repodir.c + * Copyright (C) 2017 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/ + */ + +#include <stdlib.h> +#include <string.h> +#include <anopa/common.h> +#include <anopa/get_repodir.h> + +#define AA_DEFAULT_REPODIR "/run/services" + +const char * +aa_get_repodir (void) +{ + const char *repodir; + + repodir = getenv ("AA_REPODIR"); + if (repodir) + repodir = strdup (repodir); + else + repodir = AA_DEFAULT_REPODIR; + + return repodir; +}