Welcome to little lamb

Code » anopa » commit 0d78e89

Deprecate aa-command

author Olivier Brunel
2017-06-18 12:05:09 UTC
committer Olivier Brunel
2017-06-18 12:42:04 UTC
parent 578d132e90e28c3e57688084f98b242f586a1c7b

Deprecate aa-command

doc/aa-command.pod +31 -0
src/scripts/aa-command +2 -1

diff --git a/doc/aa-command.pod b/doc/aa-command.pod
index 90eb7ce..53363dc 100644
--- a/doc/aa-command.pod
+++ b/doc/aa-command.pod
@@ -6,6 +6,37 @@ aa-command - Helper to trigger one of anopa's commands
 
 B<aa-command> I<COMMAND> [I<ARG..>]
 
+=head1 DEPRECATED
+
+B<aa-command>(1) has been deprecated and will be removed in the next version of
+B<anopa>. A better way to achieve similar results is via a longrun service, thus
+guaranteeing same environment, proper logging, etc
+
+For example, such longrun could be named aa-command and have the following
+I<run> file :
+
+    #!/usr/bin/execlineb -P
+    fdmove -c 2 1
+    fdmove -c 4 1
+    fdmove 1 3
+    s6-ipcserver -1 -- socket
+    s6-ipcserver-access -i rules --
+    fdmove 2 4
+    s6-sudod -2
+    ./aa-command
+
+With the following I<aa-command> file :
+
+    #!/usr/bin/execlineb -s1
+    ifelse -n { test $1 = start -o $1 = stop -o =1 = reset }
+    { if { aa-echo -De "Invalid command: $1" } exit 1 }
+    if { aa-echo -Dn +w "Running: " +b "aa-${1} $@" }
+    exec aa-${1} -D $@
+
+And to e.g. start service foobar, one would simply do something like :
+
+    s6-sudo /run/services/aa-command/socket start foobar
+
 =head1 DESCRIPTION
 
 B<aa-command>(1) is a simple B<execline> script that can be used to run one of
diff --git a/src/scripts/aa-command b/src/scripts/aa-command
index 1d42319..49e3cb6 100644
--- a/src/scripts/aa-command
+++ b/src/scripts/aa-command
@@ -3,7 +3,7 @@
 # anopa - Copyright (C) 2015-2017 Olivier Brunel
 #
 # aa-command
-# Copyright (C) 2015 Olivier Brunel <jjk@jjacky.com>
+# Copyright (C) 2015-2017 Olivier Brunel <jjk@jjacky.com>
 #
 # This file is part of anopa.
 #
@@ -46,4 +46,5 @@ foreground
     aa-echo -B -- "Running: aa-${CMD}" " ${@}"
 }
 
+foreground { aa-echo -w "aa-command has been deprecated, see aa-command(1) for more" }
 aa-${CMD} -D ${@}