author | Olivier Brunel
<jjk@jjacky.com> 2018-01-18 13:26:13 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2018-01-21 19:41:48 UTC |
parent | 7284d29fdb6c177e603e9734aec782ddfe9604dc |
doc/aa-stage1.pod | +7 | -2 |
doc/anopa.pod | +26 | -8 |
src/scripts/aa-stage1 | +10 | -3 |
diff --git a/doc/aa-stage1.pod b/doc/aa-stage1.pod index 61a6237..2cd091d 100644 --- a/doc/aa-stage1.pod +++ b/doc/aa-stage1.pod @@ -20,8 +20,13 @@ It will log its own messages into file I</var/log/boot/current>, prefixing them with a TAI timestamp via B<s6-tai64n>. It doesn't do much in itself, the bulk of the work being done via services. It -will create the runtime repository I</run/services> using B<aa-enable>(1) and -I</etc/anopa/enabled> as listdir. +will create the runtime repository I</run/services> using B<aa-hiercopy>(1) to +copy I</var/lib/repodir/onboot> (unless argument B<aa> was specified on kernel +command line, in which case I</var/lib/repodir/ARGVALUE> is used instead if it +exists.) + +The repodir is intended to have been created ahead of time obviously, usually by +using B<aa-enable>(1). A service I<uncaught-logs> must exist and be a logger that will be used to catch all "uncaught logs" (i.e. anything not redirected to a service logger). A FIFO diff --git a/doc/anopa.pod b/doc/anopa.pod index 28ef7a2..2a7b84a 100644 --- a/doc/anopa.pod +++ b/doc/anopa.pod @@ -328,7 +328,7 @@ Source directory containing available servicedirs. This is where the administrator can define its own servicedirs, either because they're not provided by packages, or to be used instead. Used by B<aa-enable>(1). -=item I</etc/anopa/enabled> +=item I</etc/anopa/enabled/onboot> List directory containing either empty regular files, whose name is the name of a service to enable on boot, or directories, whose name is the name of a service @@ -337,27 +337,41 @@ to enable on boot. In the later case, the content of the folder will also be merged/copied over into the servicedir. -Used by B<aa-enable>(1) from B<aa-stage1>(1). +Must be used manually withy B<aa-enable>(1) to generate +I</var/lib/repodir/onboot> =item I</etc/anopa/listdirs/onboot> List directory containing empty regular files, whose name is the name of a service to start on boot. Used by B<aa-start>(1) from B<aa-stage2>(1). +=item I</var/lib/repodir/onboot> + +Repository directory which will be copied into I</run/services> on boot (using +B<aa-hiercopy>(1)) by B<aa-stage1>(1), thus ensuring its content remains +unchanged whilst the runtime repository lives in memory (I</run> being expected +to be a tmpfs). + +Used by B<aa-stage1>(1). + =item I</run/services> Runtime repository, the service repository for the current system, containing a directory I<.scandir>, with symlinks for all long-run services, used by B<s6-svscan> as its scandir. Used by B<aa-enable>(1), B<aa-start>(1) and -B<aa-stop>(1). +B<aa-stop>(1), copied from I</var/lib/repodir/onboot> by B<aa-stage1>(1). =back -On boot, B<aa-enable>(1) is used to create the runtime repository. To do so, it -reads the content of the listdir, and for each service named there copies the -corresponding servicedir from a source directory into the runtime repository. If -listdir contained a directory, its content is then merged/copied over into the -newlu created servicedir, allowing easy custom service-specific configuration. +Ahead of time, the repository directory I</var/lib/repodir/onboot> needs to be +created. This is expected to be done with B<aa-enable>(1), using +I</etc/anopa/enabled/onboot> as listdir. + +To do so, it reads the content of the listdir, and for each service named there +copies the corresponding servicedir from a source directory into the runtime +repository. If listdir contained a directory, its content is then merged/copied +over into the newly created servicedir, allowing easy custom service-specific +configuration. Source directories are looked up in order, thus allowing the administrator to provide not only its own servicedirs, but its own version of a given servicedir. @@ -365,6 +379,10 @@ provide not only its own servicedirs, but its own version of a given servicedir. Refer to B<aa-enable>(1) for more on how it works and how the copy operation takes place. + +On boot, B<aa-hiercopy>(1) is used to copy the repository directory as runtime +repository I</run/services> + Then, B<aa-start>(1) is used to start all services in order, getting the system up & ready. Refer to B<aa-start>(1) for more on how it works; Refer to B<aa-stage1>(1) and B<aa-stage2>(1) for more on this init process on boot works. diff --git a/src/scripts/aa-stage1 b/src/scripts/aa-stage1 index 98d53a0..8d51898 100755 --- a/src/scripts/aa-stage1 +++ b/src/scripts/aa-stage1 @@ -3,7 +3,7 @@ # anopa - Copyright (C) 2015-2017 Olivier Brunel # # aa-stage1 -# Copyright (C) 2015 Olivier Brunel <jjk@jjacky.com> +# Copyright (C) 2015-2018 Olivier Brunel <jjk@jjacky.com> # # This file is part of anopa. # @@ -49,9 +49,16 @@ cd / umask 022 # Create the repository -foreground { emptyenv -c -aa-enable -Dql /etc/anopa/enabled -k uncaught-logs -f @LIBEXECDIR@/aa-stage3 } +backtick -n -D onboot REPODIR { aa-incmdline -Drs aa } +backtick -n -D onboot REPODIR { + importas -u REPODIR REPODIR + if { aa-test -e /var/lib/repodir/$REPODIR } echo $REPODIR +} +importas -u REPODIR REPODIR +foreground { aa-echo -Dt "Copying ${REPODIR} repodir as /run/services..." } +foreground { emptyenv -c aa-hiercopy -D /var/lib/repodir/$REPODIR /run/services } +foreground { aa-echo -Dt "Starting s6-svscan..." } # Make sure the FIFO needed for the switch to stage 2 is there ifelse -X -n { aa-test -Dp /run/services/.scandir/uncaught-logs/fifo } {