author | Olivier Brunel
<jjk@jjacky.com> 2015-10-16 12:55:09 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2015-10-16 12:55:09 UTC |
parent | 52dfae6940f71f6a93eb625b975ad2f9c62b899c |
doc/aa-command.pod | +26 | -0 |
package/modes | +1 | -0 |
package/targets.mak | +2 | -0 |
src/scripts/aa-command | +49 | -0 |
diff --git a/doc/aa-command.pod b/doc/aa-command.pod new file mode 100644 index 0000000..90eb7ce --- /dev/null +++ b/doc/aa-command.pod @@ -0,0 +1,26 @@ +=head1 NAME + +aa-command - Helper to trigger one of anopa's commands + +=head1 SYNOPSIS + +B<aa-command> I<COMMAND> [I<ARG..>] + +=head1 DESCRIPTION + +B<aa-command>(1) is a simple B<execline> script that can be used to run one of +anopa's command, ensuring proper environment and logging the output. + +That is, instead of running e.g. `aa-start -W foo bar` to start those two +services (but not auto-start any "wants"), one could do: + + aa-command start -W foo bar + +This would simply reset the environment to load it from I</etc/anopa/env> (much +like what happens on boot, i.e. in the B<aa-stage*> scripts), set up a pipe on +stderr to log things (timestamped via B<s6-tai64n>) by appending into +I</var/log/boot/current>; then execute `B<aa-I<COMMAND>> -D I<ARG..>` + +As a result, the command runs with a clean/predictable environment, and in +addition to the output showing on the terminal, it gets added to the log of the +current boot (again, as per the B<aa-stage*> scripts). diff --git a/package/modes b/package/modes index 5837c9c..c81dc93 100644 --- a/package/modes +++ b/package/modes @@ -1,4 +1,5 @@ aa-chroot 0755 +aa-command 0755 aa-ctty 0755 aa-echo 0755 aa-enable 0755 diff --git a/package/targets.mak b/package/targets.mak index 134d1ea..3ffe31b 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -22,6 +22,7 @@ aa-tty \ aa-umount BIN_SCRIPTS_TARGET := \ +aa-command \ aa-shutdown LIBEXEC_SCRIPTS_TARGET := \ @@ -34,6 +35,7 @@ aa-stage4 DOC_TARGETS := \ anopa.1 \ aa-chroot.1 \ +aa-command.1 \ aa-ctty.1 \ aa-echo.1 \ aa-enable.1 \ diff --git a/src/scripts/aa-command b/src/scripts/aa-command new file mode 100644 index 0000000..bc2a6c8 --- /dev/null +++ b/src/scripts/aa-command @@ -0,0 +1,49 @@ +#!@BINDIR@/execlineb +# +# anopa - Copyright (C) 2015 Olivier Brunel +# +# aa-command +# 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/ +# + +importas CMD 1 +shift +elgetpositionals + +emptyenv s6-envdir /etc/anopa/env exec + +# Set up a pipe to log messages +piperw 3 4 +background +{ + fdclose 4 fdmove 0 3 + redirfd -a 1 /var/log/boot/current + fdmove -c 2 1 + s6-tai64n +} +fdclose 3 +fdmove 2 4 + +# log what we do +foreground +{ + fdmove -c 1 2 + aa-echo -B -- "Running: aa-${CMD}" " ${@}" +} + +aa-${CMD} -D ${@}