66
www.obarun.org

The 66-scandir program

66-scandir handle a scandir for a specific given user. It is designed to be either the root or a branch of a supervision tree.

Interface

     66-scandir [ -h help ] [ -v verbosity ] [ -b boot ] [ -l live ] [ -t rescan ]  [ -f finish command ] [ -e environment ] [ -c create ] [ -r remove ] [ -u up ] [ -d signal ] owner

66-scandir will handle or create the scandir at live for a specific owner depending of the options given. The owner can be any valid user on the system. However, the owner must have sufficient permissions to create the necessary directories at live. If the owner is not set, the user of the current process will be took.

Options

Signals

The options -s to send a signal to the scandir is builded around the s6-svscanctl program and act with exactly the same behaviour. Any signal accepted by s6-svscanctl program can be passed but need to be done without the '-' character at the begin of the signal. If, for example, you want to send a -t signal you need to use: 66-scandir -s t. Series of command is also accepted in the same manner: 66-scandir -s st.
Also some convenient sentence was added to avoid to remember basic and usefull series of command like :

Signal usage examples

 66-scandir -s reload 

Updates the process supervision tree to exactly match the services listed in scandir.

This command is strictly equal to :

s6-svscanctl -an /service

Scandir creation process

When you ask for a creation of the scandir various files and directories will be created at live directory for the given owner. If you run the 66-scandir with the user root, you will find in /run/66 (default directory is took for the example) :

If you ask for the creation of the scandir with normal user you will find /run/66/scandir/1000 where 1000 is the corresponding uid for the user, and /run/66/tree/1000. The log directory is not set due of the missing permissions to create the scandir for the boot process, instead it will be found by default at /var/log/scandir-1000. Default log directory can be changed at compile-time by giving the --with-system-logpath=DIR option for root permissions and --with-user-logpath=DIR options for user permissions to ./configure.

An existing scandir directory will be used as it and the creation will be skipped. If you want to create a fresh scandir directory for the same owner, use the -r options before.

.s6-svscan control directory

s6-svscan program expect to find some control file when it receive a signal. Thoses files are not mandatory and are not created by any s6 program but are usefull to control the e.g shutdown process. The 66-scandir program will care of it and create those files at /run/66/scandir/0/.s6-svscan directory. Depending if the -b options is passed or not to the command line, the files will change.

crash file

With the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
redirfd -r 0 /dev/console
redirfd -w 1 /dev/console
fdmove -c 2 1
s6-echo -- "scandir /run/66/scandir/0 crashed...

without the -b option

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-all -v3 -l /run/66/ down }
s6-echo -- "scandir /run/66/scandir/0 crashed..."
finish file

With the -b options the file will be:

#!/usr/local/bin/execlineb -S0
fdmove -c 2 1
s6-envdir .env
cd /
redirfd -w 2 /dev/console
fdmove -c 1 2
foreground { s6-svc -X -- /run/66/scandir/0/scandir-log }
unexport ?
wait r -- { }
/etc/66/stage3 $@

The last command (in our example /etc/66/stage3 @) is set by the -f finish command options given on the command line. If your e.g finish command is /usr/bin/true your finish file will be:

#!/usr/local/bin/execlineb -S0
fdmove -c 2 1
s6-envdir .env
cd /
redirfd -w 2 /dev/console
fdmove -c 1 2
foreground { s6-svc -X -- /run/66/scandir/0/scandir-log }
unexport ?
wait r -- { }
/usr/bin/true

without the -b option

#!/usr/local/bin/execlineb -S0
fdmove -c 2 1
s6-envdir .env
s6-echo -- "scandir /run/66/scandir/0 shutted down..."
SIGHUP file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-dbctl -v3 -l /run/66/ -d Master }
s6-svscanctl -h .
SIGINT file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-all -v3 -l /run/66/ down }
s6-svscanctl -6 .
SIGQUIT file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-all -v3 -l /run/66/ down }
s6-svscanctl -7 .
SIGTERM file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-all -v3 -l /run/66/ down }
s6-svscanctl -t .
SIGUSR1 file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
s6-svscanctl -an .
SIGUSR2 file

With or without the -b options the file will be:

#!/usr/local/bin/execlineb -P
fdmove -c 2 1
s6-envdir .env
foreground { 66-all -v3 -l /run/66/ down }
s6-svscanctl -0 .

Environment configuration

You can modify the environment variable at the start of the scandir with the -e options. This option expect to find a valid absolute path for a directory which contain files where the format of the file is :

Environment file example

name of the file: /etc/66/env/TZ

contain of the file:

Pacific/Noumea

Every daemon launched on the scandir should inherit of the environment variable of the scandir. So if you want to have a specific key=value pair for every daemon, use this option.

Scandir remove process

When you use the -r options some directories of the scandir will be removed but not all the componments of the directory. In our previous example:

The root live (a.k.a /run/66) directory will be not removed because an another user can still use it. In fact the 66-scandir will only remove the componment of the corresponding uid of the owner.

An running scandir can not be removed. You must stop the scandir before to be able to remove it.