66
www.obarun.org

66-scandir

This command handles the scandir for a given user. It is designed to be either root or a branch of the supervision tree.

Interface

	66-scandir [ -h help ] [ -v verbosity ] [ -b boot ] [ -l live ] [ -t rescan ] [ -2 stage2.tini ] [ -3 stage3 ] [ -e environment ] [ -c create ] [ -r remove ] [ -u up ] [ -s signal ] owner
	

66-scandir will handle or create the scandir for the given owner depending on the provided options. Note that owner can be any valid user on the system. However, the given user must have sufficient permissions to create the necessary directories at its location. That is /run/66 by default or the resulting path provided by the -l option. If owner is ommited, the user of the current process will be used instead.

Options

Signals

The -s option sends a signal to the scandir and is built around the s6-svscanctl. It therefore acts in the same way. Any signal accepted by s6-svscanctl can be passed just without the '-' character. If, for example, you want to send a -t signal, you need to use: 66‑scandir ‑s t. A series of commands is also accepted in the same way: 66‑scandir ‑s st. A few convenient keywords were added to avoid having to remember basic and useful series of commands 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 creating the scandir with the ‑c option various files and directories will be created at the live directory for the given owner.

If created with the user root, you will find the following in /run/66 (the directory created by default if ‑l is not passed and 0 being the corresponding UID for the root user):

If created with any normal user you will find the following in /run/66 (the directory created by default if -l is not passed and 1000 being the UID for the user):

For regular users the log directory can not be set due to missing permissions. Instead the default location at /var/log/scandir‑1000 will be used. The default log directory can be changed at compile time by passing the following options to ./configure:

If a scandir already exists for the given user it will prevent the creation when issuing 66‑scandir ‑c. If you want to create a different scandir for the same owner you must delete it first with ‑r.

.s6‑svscan control directory

s6‑svscan expects to find one or more control files when it receives a signal. Those files are not mandatory and are not created by any s6 program but are useful to control several processes like shutdown for example. 66‑scandir will take care of this and create the following files at /run/66/scandir/0/.s6‑svscan. Depending on whether the -b option is passed or not the files will change as outlined below.

The path of the scandir in the control file is automatically adjusted when altered with the -l live option.

crash file

With or without the -b option the file will look like this:

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

finish file

With -b set:

   #!/usr/bin/execlineb -S0
   /etc/66/stage3 $@
    

The last command depends on the -3 stage3 option given on the command line. If your stage3 argument is /usr/bin/true for example then your finish file will be:

   #!/usr/bin/execlineb -S0
   /usr/bin/true
    

Without the -b option:

   #!/usr/bin/execlineb -S0
   s6-echo -- "scandir /run/66/scandir/1000 shutted down..."
    

SIGHUP file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -h -- /run/66/scandir/0
    

The command executed before sending a signal to the scandir is set by the -2 stage2.tini option given on the command line.

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -h -- /run/66/scandir/0
    

SIGINT file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -6 -- /run/66/scandir/0
    

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -6 -- /run/66/scandir/0
    

SIGQUIT file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -q -- /run/66/scandir/0
    

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -q -- /run/66/scandir/0
    

SIGTERM file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -t -- /run/66/scandir/0
    

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -t -- /run/66/scandir/0
    

SIGUSR1 file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -7 -- /run/66/scandir/0
    

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -7 -- /run/66/scandir/0
    

SIGUSR2 file

With -b set:

   #!/usr/bin/execlineb -P
   foreground { /etc/66/stage2.tini }
   s6-svscanctl -O -- /run/66/scandir/0
    

Without the -b option:

   #!/usr/bin/execlineb -P
   foreground { 66-all -v3 -l /run/66/ down }
   s6-svscanctl -O -- /run/66/scandir/0
    

Environment configuration

You can modify environment variables when starting the scandir with the ‑e option. This option expects to find a valid absolute path for a directory which contains files where the formatting must follow these rules:

example

  /etc/66/env/TZ 

Content of the file:

   Pacific/Noumea 

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

Scandir remove process

When using the ‑r option to delete the scandir of a given user some directories of the scandir may not be removed if another user accesses them. In our previous example where we created a scandir for root with UID 0 and a regular user with the UID 1000 this would imply the following:

The directory live of the root user (in this example and by default /run/66) will not be removed because another user (the one from our example) can still use it. In fact 66‑scandir will only remove the subdirectories of the corresponding UID of the owner and the live root directory is not touched. As live should be created on a RAM filesystem the deletion happens on the next reboot.

Note: A running scandir can not be removed. You must stop it with e.g. ‑s quit first to be able to remove it.