Skip to content
Snippets Groups Projects
Commit d21aa002 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

pass to markdown for documentation

parent b382579b
No related branches found
No related tags found
No related merge requests found
......@@ -6,3 +6,5 @@ src/66-tools/*.o
*.a.*
/66-*
/execl-*
/doc/html
/doc/man
Copyright (c) 2018-2019 Eric Vidal <eric@obarun.org>
Copyright (c) 2018-2020 Eric Vidal <eric@obarun.org>
All rights reserved.
Permission to use, copy, modify, and/or distribute this software for any
......
Build Instructions
------------------
* Requirements
------------
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- skalibs version 2.9.1.0 or later
- execline version 2.5.3.0 or later
- oblibs version 0.0.6.0 or later
- scdoc version 1.9.4 or later for man pages: https://git.sr.ht/~sircmpwn/scdoc
- If cross-compiling: the sysdeps for your target architecture
(see the "Cross-compilation" section below)
This software will install on any operating system that implements
POSIX.1-2008, available at:
http://pubs.opengroup.org/onlinepubs/9699919799/
* Standard usage
--------------
./configure && make && sudo make install
will work for most users.
It will install the static libraries in /usr/lib/66-tools, the shared
libraries in /lib.
Please note that static libraries in /usr/lib/66-tools *will not*
be found by a default linker invocation: you need -L/usr/lib/66-tools.
Other obarun.org software automatically handles that case if the
default configuration is used, but if you change the configuration,
remember to use the appropriate --with-lib configure option.
You can strip the libraries of their extra symbols via "make strip"
before the "make install" phase. It will shave a few bytes off them.
* Customization
-------------
You can customize the installation process via flags given to configure.
See ./configure --help for a list of all available configure options.
* Environment variables
---------------------
Controlling a build process via environment variables is a big and
dangerous hammer. You should try and pass flags to configure instead;
nevertheless, a few standard environment variables are recognized.
If the CC environment variable is set, its value will override compiler
detection by configure. The --host=HOST option will still add a HOST-
prefix to the value of CC.
The values of CFLAGS, CPPFLAGS and LDFLAGS will be appended to the
default flags set by configure. To override those defaults instead
of appending to them, use the CPPFLAGS, CFLAGS and LDFLAGS
_make variables_ instead of environment variables.
* Make variables
--------------
You can invoke make with a few variables for more configuration.
CC, CFLAGS, CPPFLAGS, LDFLAGS, LDLIBS, AR, RANLIB, STRIP, INSTALL and
CROSS_COMPILE can all be overridden on the make command line. This is
an even bigger hammer than running ./configure with environment
variables, so it is advised to only do this when it is the only way of
obtaining the behaviour you want.
DESTDIR can be given on the "make install" command line in order to
install to a staging directory.
* Static binaries
---------------
By default, binaries are linked against static versions of all the
libraries they depend on, except for the libc. You can enforce
linking against the static libc with --enable-static-libc.
(If you are using a GNU/Linux system, be aware that the GNU libc
behaves badly with static linking and produces huge executables,
which is why it is not the default. Other libcs are better suited
to static linking, for instance musl: http://musl-libc.org/)
* Cross-compilation
-----------------
skarnet.org packages centralize all the difficulty of
cross-compilation in one place: skalibs. Once you have
cross-compiled skalibs, the rest is easy.
* Use the --host=HOST option to configure, HOST being the triplet
for your target.
* Make sure your cross-toolchain binaries (i.e. prefixed with HOST-)
are accessible via your PATH environment variable.
* Make sure to use the correct version of skalibs for your target,
and the correct sysdeps directory, making use of the
--with-include, --with-lib, --with-dynlib and --with-sysdeps
options as necessary.
* The slashpackage convention
---------------------------
The slashpackage convention (http://cr.yp.to/slashpackage.html)
is a package installation scheme that provides a few guarantees
over other conventions such as the FHS, for instance fixed
absolute pathnames. obarun.org packages support it: use the
--enable-slashpackage option to configure, or
--enable-slashpackage=DIR for a prefixed DIR/package tree.
This option will activate slashpackage support during the build
and set slashpackage-compatible installation directories. If
$version is the current 66-tools version number:
--bindir will be set to /package/prog/66-tools-$version/command
--includedir will be set to /package/prog/66-tools-$version/include
--libdir will be set to /package/prog/66-tools-$version/library
--dynlibdir will be set to /package/prog/66-tools-$version/library.so
Note that --datadir will be unchanged, because the data exported
by 66-tools, i.e. the leap second table, is system-wide. You should
manually specify --datadir=... if you want to deviate from the default.
--prefix is pretty much ignored when you use --enable-slashpackage:
it will only impact --datadir. You should probably not use both
--enable-slashpackage and --prefix.
When using slashpackage, two additional Makefile targets are
available after "make install":
- "make -L update" changes the default version of the software to the
freshly installed one. (This is useful when you have several installed
versions of the same software, which slashpackage supports.)
- "make -L global-links" adds links from DIR/command and DIR/library.so
to the default version of the binaries and shared libraries.
The "-L" option to make is necessary because targets are symbolic links,
and the default make behaviour is to check the pointed file's timestamp
and not the symlink's timestamp.
* Out-of-tree builds
------------------
obarun.org packages do not support out-of-tree builds. They
are small, so it does not cost much to duplicate the entire
source tree if parallel builds are needed.
Build Instructions
------------------
## Requirements
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- skalibs version 2.9.1.0 or later
- execline version 2.5.3.0 or later
- oblibs version 0.0.6.0 or later
- lowdown version 0.6.4 or later for man and html pages: https://kristaps.bsd.lv/lowdown/
- If cross-compiling: the sysdeps for your target architecture (see the [Cross-compilation](INSTALL.md#Cross-compilation) section below)
This software will install on any operating system that implements POSIX.1-2008, available at [opengroup](http://pubs.opengroup.org/onlinepubs/9699919799/)
## Standard usage
`./configure && make && sudo make install` will work for most users.
It will install the static libraries in /usr/lib/66-tools, the shared libraries in /lib.
Please note that static libraries in /usr/lib/66-tools *will not* be found by a default linker invocation: you need -L/usr/lib/66-tools.
Other [obarun](https://web.obarun.org) software automatically handles that case if the default configuration is used, but if you change the configuration, remember to use the appropriate *--with-lib* configure option.
You can strip the libraries of their extra symbols via `make strip` before the `make install` phase. It will shave a few bytes off them.
## Customization
You can customize the installation process via flags given to configure. See `./configure --help` for a list of all available configure options.
## Environment variables
Controlling a build process via environment variables is a big and dangerous hammer. You should try and pass flags to configure instead; nevertheless, a few standard environment variables are recognized.
If the CC environment variable is set, its value will override compiler detection by configure. The *--host=HOST* option will still add a HOST- prefix to the value of CC.
The values of *CFLAGS*, *CPPFLAGS* and *LDFLAGS* will be appended to the default flags set by configure. To override those defaults instead of appending to them, use the *CPPFLAGS*, *CFLAGS* and *LDFLAGS* *make variables* instead of environment variables.
## Make variables
You can invoke make with a few variables for more configuration.
*CC*, *CFLAGS*, *CPPFLAGS*, *LDFLAGS*, *LDLIBS*, *AR*, *RANLIB*, *STRIP*, *INSTALL* and *CROSS_COMPILE* can all be overridden on the make command line. This is an even bigger hammer than running `./configure` with environment variables, so it is advised to only do this when it is the only way of obtaining the behaviour you want.
*DESTDIR* can be given on the `make install` command line in order to install to a staging directory.
## Static binaries
By default, binaries are linked against static versions of all the libraries they depend on, except for the libc. You can enforce linking against the static libc with *--enable-static-libc*.
(If you are using a GNU/Linux system, be aware that the GNU libc behaves badly with static linking and produces huge executables, which is why it is not the default. Other libcs are better suited to static linking, for instance [musl](http://musl-libc.org/)
## Cross-compilation
skarnet.org packages centralize all the difficulty of cross-compilation in one place: skalibs. Once you have
cross-compiled skalibs, the rest is easy.
- Use the *--host=HOST* option to configure, *HOST* being the triplet for your target.
- Make sure your cross-toolchain binaries (i.e. prefixed with HOST-) are accessible via your *PATH* environment variable.
- Make sure to use the correct version of skalibs for your target, and the correct sysdeps directory, making use of the *--with-include*, *--with-lib*, *--with-dynlib* and *--with-sysdeps*
options as necessary.
## The slashpackage convention
The [slashpackage convention](http://cr.yp.to/slashpackage.html) is a package installation scheme that provides a few guarantees over other conventions such as the FHS, for instance fixed absolute pathnames. obarun.org packages support it: use the *--enable-slashpackage* option to configure, or *--enable-slashpackage=DIR* for a prefixed DIR/package tree. This option will activate slashpackage support during the build and set slashpackage-compatible installation directories. If
$version is the current 66-tools version number:
- *--bindir* will be set to /package/prog/66-tools-$version/command
- *--includedir* will be set to /package/prog/66-tools-$version/include
- *--libdir* will be set to /package/prog/66-tools-$version/library
- *--dynlibdir* will be set to /package/prog/66-tools-$version/library.so
Note that *--datadir* will be unchanged, because the data exported by 66-tools, i.e. the leap second table, is system-wide. You should manually specify *--datadir=...* if you want to deviate from the default.
*--prefix* is pretty much ignored when you use *--enable-slashpackage*: it will only impact *--datadir*. You should probably not use both *--enable-slashpackage* and *--prefix*.
When using slashpackage, two additional Makefile targets are available after `make install`:
- `make -L update` changes the default version of the software to the freshly installed one. (This is useful when you have several installed versions of the same software, which slashpackage supports.)
- `make -L global-links` adds links from DIR/command and DIR/library.so to the default version of the binaries and shared libraries.
The `-L` option to make is necessary because targets are symbolic links, and the default make behaviour is to check the pointed file's timestamp and not the symlink's timestamp.
## Out-of-tree builds
obarun.org packages do not support out-of-tree builds. They are small, so it does not cost much to duplicate the entire source tree if parallel builds are needed.
......@@ -56,15 +56,16 @@ INSTALL := ./tools/install.sh
ALL_BINS := $(LIBEXEC_TARGETS) $(BIN_TARGETS)
ALL_LIBS := $(SHARED_LIBS) $(STATIC_LIBS) $(INTERNAL_LIBS)
ALL_INCLUDES := $(wildcard src/include/$(package)/*.h)
ALL_MAN := $(wildcard doc/man/*.[1-8].scd)
INSTALL_MAN := $(wildcard doc/man/*.[1-8])
GENERATE_HTML := $(shell doc/make-html.sh)
GENERATE_MAN := $(shell doc/make-man.sh)
INSTALL_HTML := $(wildcard doc/html/*.html)
INSTALL_MAN := $(wildcard doc/man/*/*)
all: $(ALL_LIBS) $(ALL_BINS) $(ALL_INCLUDES)
clean:
@exec rm -f $(ALL_LIBS) $(ALL_BINS) $(wildcard src/*/*.o src/*/*.lo) $(EXTRA_TARGETS) \
$(INSTALL_MAN)
$(INSTALL_HTML) $(INSTALL_MAN)
distclean: clean
@exec rm -f config.mak src/include/$(package)/config.h
......@@ -93,6 +94,8 @@ install-lib: $(STATIC_LIBS:lib%.a.xyzzy=$(DESTDIR)$(libdir)/lib%.a)
install-include: $(ALL_INCLUDES:src/include/$(package)/%.h=$(DESTDIR)$(includedir)/$(package)/%.h)
install-data: $(ALL_DATA:src/etc/%=$(DESTDIR)$(datadir)/%)
install-html: $(INSTALL_HTML:doc/html/%.html=$(DESTDIR)$(datarootdir)/doc/$(package)/%.html)
install-man: install-man1
install-man1: $(INSTALL_MAN:doc/man/man1/%.1=$(DESTDIR)$(mandir)/man1/%.1)
ifneq ($(exthome),)
......@@ -116,7 +119,11 @@ endif
$(DESTDIR)$(datarootdir)/doc/$(package)/%.html: doc/html/%.html
$(INSTALL) -D -m 644 $< $@ && \
sed -e 's,%%service_admconf%%,/etc/66/conf,g' $< > $@
$(DESTDIR)$(mandir)/man1/%.1: doc/man/man1/%.1
$(INSTALL) -D -m 644 $< $@ && \
sed -e 's,%%service_admconf%%,/etc/66/conf,g' $< > $@
$(DESTDIR)$(datadir)/%: src/etc/%
exec $(INSTALL) -D -m 644 $< $@
......@@ -153,17 +160,6 @@ lib%.a.xyzzy:
lib%.so.xyzzy:
exec $(CC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$(patsubst lib%.so.xyzzy,lib%.so.$(version_M),$@) $^ $(EXTRA_LIBS) $(LDLIBS)
man: $(ALL_MAN:%.scd=%)
%: %.scd
scdoc < $< > $@
install-man:
for i in 1 5 ; do \
install -m755 -d $(DESTDIR)$(mandir)/man$$i; \
install -m644 doc/man/*.$$i $(DESTDIR)$(mandir)/man$$i/ ; \
done
.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-lib install-include install-data man install-man install-html
.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-lib install-include install-data install-man install-html
.DELETE_ON_ERROR:
Changelog for 66-tools
In 0.0.4.0
----------
- Minor bugs fix
- Adapt to oblibs v0.0.6.0
- New 66-clock tool:
get and write sytem time to stdout.
In 0.0.3.1
----------
- Adapt to oblibs v0.0.5.0
- Fix parse of double-quote at execl-cmdline
In 0.0.3.0
----------
- Adapt to oblibs v0.0.4.0
- Supports relative path at execl-envfile
- New 66-olexec tool:
- opens, locks a tty and execs a program
In 0.0.2.0
----------
- Remove deprecated 66-enfvile tools
- Adapt to skalibs 2.9.1.0, execline 2.5.3.0, oblibs 0.0.3.1
NEWS.md 0 → 100644
# Changelog for 66-tools
---
# In 0.0.4.0
- Minor bugs fix
- Adapt to oblibs v0.0.6.0
- New 66-clock tool:
* get and write sytem time to stdout.
---
# In 0.0.3.1
- Adapt to oblibs v0.0.5.0
- Fix parse of double-quote at execl-cmdline
---
# In 0.0.3.0
- Adapt to oblibs v0.0.4.0
- Supports relative path at execl-envfile
- New 66-olexec tool:
* opens, locks a tty and execs a program
---
# In 0.0.2.0
- Remove deprecated 66-enfvile tools
- Adapt to skalibs 2.9.1.0, execline 2.5.3.0, oblibs 0.0.3.1
66-tools - Helpers tools to accomplish various and repetitive tasks in service scripts
administration common tasks
--------------------------------
Some utilities are language https://skarnet.org/software/execline
specific (usually named with 'execl-' prefix) where other can
be used on classic shell.
* Installation
------------
See the INSTALL file.
* Contact information
-------------------
Eric Vidal <eric@obarun.org>
https://web.obarun.org/
https://forum.obarun.org/
IRC on freenode : #obarun
![GitLabl Build Status](https://framagit.org/Obarun/66-tools/badges/master/pipeline.svg)
66-tools - Helpers tools to accomplish various and repetitive tasks in service scripts administration common tasks
====
Some utilities are language [execline](https://skarnet.org/software/execline) specific (usually named with `execl-` prefix) where other can be used on classic shell.
Installation
------------
See the INSTALL.md file.
Documentation
-------------
Online [documentation](https://web.obarun.org/software/66-tools/)
Contact information
-------------------
* Email:
Eric Vidal `<eric@obarun.org>`
* Mailing list
https://obarun.org/mailman/listinfo/66_obarun.org/
* Web site:
https://web.obarun.org/
* IRC Channel:
Network: `chat.freenode.net`
Channel : `#obarun`
Supports the project
---------------------
Please consider to make [donation](https://web.obarun.org/index.php?id=18)
title: The 66-tools Suite: 66-clock
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-clock
66-clock gets the system time and writes it with a specific format.
## Interface
```
66-clock [ -h ] [ -m message ] [ -n ] tai|iso
```
66-clock writes the current system time as a *TAIN64* or *ISO* timestamp depending of the argument past to stdout.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-m** *message* : prints *message* after the system time.
- **-n** : output a trailing newline.
title: The 66-tools Suite: 66-getenv
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-getenv
66-getenv gets and displays the environment variables of a process name.
## Interface
```
66-getenv [ -h ] [ -x ] [ -d delim ] process
```
- It find the corresponding pid of the *process* name applying a regex search.
- It open and read /proc/<pid>/environ file and displays its contain.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-x** : match exactly with the process name. It can be a complete command line, in such case its must be double-quoted.
- **-d** *delim* : specify output delimiter. The default is `\n` character.
## Usage example
```
66-getenv -x jwm
66-getenv "ck-launch-session" jwm
```
## Note
The file */proc/<pid>/environ* contains the initial environment that was set when the currently executing program was started via *execve(2)*. If, after an *execve(2)*, the process modifies its environment (e.g., by calling functions such as *putenv(3)* or modifying the *environ(7)* variable directly), this file will *not* reflect those changes—see *proc(5)* for futher informations.
title: The 66-tools Suite: 66-gnwenv
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-gnwenv
66-gnwenv gets and writes the environment variables of a process name at a specific file location.
## Interface
```
66-gnwenv [ -h ] [ -x ] [ -m mode ] process dir file
```
- *66-gnwenv* executes into `66-getenv -x process 66-writenv -m mode dir file`. It does nothing else: it is just a convenience program. [66-getenv](66-getenv.html) read the environment variable of the process, and [66-writenv](66-writenv.html) will write these variables into *dir/file* location.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-x** : match exactly with the process name. It can be a complete command line, in such case its must be double-quoted.
- **-m** *mode* : create *dir* with mode *mode* if it doesn't exist yet. Default is `0755`.
title: The 66-tools Suite: 66-olexec
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-olexec
66-olexec (open,lock and execute) opens the active (or specified) *tty*, locks it and executes a program.
## Interface
```
66-olexec [ -h ] [ -d tty ] program
```
This tool opens the active tty or the one specified by the **-d** modifier, locks it, and executes a program as a child process of that *tty*.
- It determines the active *tty* if the **-d** option is not specified.
- It closes the file descriptor `stdin` and `stdout`.
- It tries to open the *tty* with read/write permissions.
- It reopens `stdout` at the *tty*.
- It closes `stderr` and reopens it at the *tty*.
- It gets an exclusive advisory lock on the *tty*.
- It forks and executes *program* as child and waits until the *program* exits. If *program* crashes or get exited, 66-olexec sends a message to `stderr` with the exit code of the *program*.
- It releases the lock and exits.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-d** *tty* : specifies the *tty* to use in place of the active one. An absolute path is expected.
## Usage example
```
66-olexec -d /dev/tty3 cryptsetup open /dev/sda1 cryptroot
```
title: The 66-tools Suite: 66-which
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-which
*66-which* is a portable which command that checks if a command exists and is executable in `PATH` or at specified path. It behaves slightly different then the `GNU` which command.
## Interface
```
66-which [ -h ] [ -q | -a ] command(s)
```
This tool expect to find valid command name or path, it will check if they exists and are executable by the current user.
- It parse `PATH` for valid entries, applying a substitution of each entry with its realpath and emilinating duplicates.
- It parses that command given checking if it is a path or a name.
- It prints each command found with the first `PATH` entry, otherwise it print an error. By passing the **-a** option, it searches and print command with all the `PATH` entries, even if it been already found.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed or at least one command hasn't been found.
## Options
- **-h** : prints this help.
- **-a** : prints all. Search and print the command using all the `PATH` entries, even after the command has already been found.
- **-q** : quiet. Do not print anything on `stdout`.
## Usage examples
Search for a command by using its name:
```
$ 66-which 66-echo
/usr/bin/66-echo
```
Check for a command by using its path:
```
$ 66-which /usr/bin/66-echo
/usr/bin/66-echo
```
Usage of 66-which in a script:
```
#!/usr/bin/execlineb -P
if { 66-which -q vgchange }
vgchange -ay
```
## Notes
*66-which* need at least one valid entry in `PATH` that exists on the system. *66-which* is often used on critical scripts, like the ones booting the system, so it's important to check if `PATH` contains valid entries for the current system.
*66-which* correctly handle the tilde `~` character for paths. Beware that same shell, like bash, replaces this character with the current user home path. To pass the correct string to *66-which*, containing the tilde character, use quoting like this: `66-which '~/.bin/gvr'`.
title: The 66-tools Suite: 66-writenv
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# 66-writenv
66-writenv stores its environment variables at a specific file location.
## Interface
```
66-writenv [ -h ] [ -m mode ] dir file
```
- This tool write its environment variables into *dir/file* under the classic format `key=value` pair and thoses one per line. *dir* must be an absolute path.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-m** *mode* : create dir with mode *mode* if it doesn't exist yet. Default is `0755`.
title: The 66-tools Suite: execl-cmdline
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# execl-cmdline
This command parses a command line into an [execline](https://skarnet.org/software/execline) script.
## Interface
As [execlineb](https://www.skarnet.org/software/execline/execlineb.html) script:
```
execl-cmdline -s { command }
```
- It reads the command and removes all whitespace or `no word` before executing.
- It exits with the exit code of the command
## Options
- **-s** : splits a command considered by execline scripting language as one word into separate words.
## Note and usage examples
*execl-cmdline* should be used at the end of *execline* scripts. If you want to run another program after the call of execl-cmdline you would need to use an [if](https://skarnet.org/software/execline/if.html) command, [foreground](https://skarnet.org/software/execline/foreground.html), [background](https://skarnet.org/software/execline/background.html) or the likes.
The following command:
```
execl-cmdline { /usr/bin/ntpd -d "" -S }
```
will result in:
```
/usr/bin/ntpd "-d" "-S"
```
This command:
```
execl-cmdline -s { /usr/bin/ntpd "-d -S" }
```
will result in:
```
/usr/bin/ntpd "-d" "-S"
```
To run another program after the call of *execl-cmdline* program:
```
foreground { execl-cmdline { /usr/bin/ntpd -d "" -S } }
```
title: The 66-tools Suite: execl-envfile
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# execl-envfile
A mix of [s6-envdir](https://skarnet.org/software/s6/s6-envdir.html) and [importas](https://skarnet.org/software/execline/importas.html). Reads files containing variable assignments in the given *file/directory*, adds the variables to the environment and then executes a program.
## Interface
```
execl-envfile [ -h ] [ -l ] src prog
```
This tool expects to find a regular file or a directory in *src* containing one or multiple `key=value` pair(s). It will parse that file, import the `key=value` and then exec the given *prog* with the modified environment. In case of directory for each file found it apply the same process. *src* can be an absolute or a relative path.
- It opens and reads a file.
- It parses that file.
- It imports the found `key=value` pair(s).
- It substitutes each corresponding *key* with value from that file.
- It unexports the variable(s) if requested.
- It execs *prog* with the modified environment.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-h** : prints this help.
- **-l** : loose; do nothing and execute *prog* directly if *src* does not contain any regular file(s) or *src* does not exist.
## File syntax
*src* is a text file or a directory containing lines of pairs with the syntax being: `key = value`
Whitespace is permitted before and after *key*, and before or after *value*. Quoting is also possible.
Empty lines or lines containing only whitespace are ignored. Lines beginning with `#` (also after whitespace) are ignored and typically used for comments. Comments are not possible at the end of lines: `key = value # comment` is not a valid comment.
If val begin by a `!` character: `key=!value` the key will be removed from the environment after the substitution.
## Usage example
```
#!/usr/bin/execlineb -P
fdmove -c 2 1
execl-envfile %%service_admconf%%/ntpd
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
```
The equivalent with s6-envdir and importas would be:
```
#!/usr/bin/execlineb -P
fdmove -c 2 1
s6-envdir %%service_admconf%%
importas -u RUNDIR RUNDIR
importas -u CMD_ARGS CMD_ARGS
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
```
where `%%service_admconf%%` contains two named files `RUNDIR` and `CMD_ARGS` written with `/run/openntpd` and `-d -s` respectively.
## Limits
*src* can not exceed more than `100` files. Each file can not contain more than `4095` bytes or more than `50` `key=value` pairs.
title: The 66-tools Suite: execl-subuidgid
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# execl-subuidgid
Substitutes a literal GID UID with the UID GID of the current owner of the process.
## Interface
```
execl-subuidgid [ -o owner ] prog
```
- Substitutes the variable `UID` `GID` on *prog*.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Options
- **-o** *owner* : set `UID` `GID` of *owner* instead of the current one.
## Usage examples
```
execl-subuidgid
if { mkdir -p /run/user }
chown -R $UID:$GID /run/user
```
```
execl-subuidgid -o root
if { mkdir /run }
chmow -R $UID:$GID /run/user
```
title: The 66-tools Suite: execl-toc
author: Eric Vidal <eric@obarun.org>
[66-tools](index.html)
[Software](https://web.obarun.org/software)
[obarun.org](https://web.obarun.org)
# execl-toc
Tests an element and creates it if it does not exist yet with the default or specified options, then executes a program by default.
## Interface
```
execl-toc [ -h ] [ -v verbosity ] [ -D ] [ -X ] [ -d|p|S|m|L|e|b|c|k|n|g|r|s|t|u|w|x|f|z|O|U|N|V|E element ] [ -o opts ] [ -t type ] [ -d device ] [ -g gid ] [ -u uid ] [ -m mode ] [ -s|D|B ] [ -b backlog ] prog...
```
*Execl-toc* (Test Or Create) tests an *element* and creates it if it does not exist yet, where an *element* can be a directory, a fifo, a socket, a mountpoint or a symlink, for testing and creation, and additionally a file and a string for testing only. Then it execs into the rest of its command line.
The options are separated in three parts:
- (1) main_options
- (2) test_options
- (3) create_options
and must ordered at the command line in that sequence.
The creation of an *element* can be controlled with the help of `create_options` options. Some of these `create_options` are specific for a particular *element* where others are general.
## Exit codes
- *0* success
- *100* wrong usage
- *111* system call failed
## Main options
`Main_options` are not mandatory.
- **-h** : prints this help.
- **-v** *verbosity* : increases/decreases the verbosity of the command.
* *1* : only print error messages. This is the default.
* *2* : also print warning messages.
* *3* : also print tracing messages.
* *4* : also print debugging messages.
- **-D** : performs the test without creating the *element* if it does not exist yet.
- **-X** : do not execute *prog*.
## Test_options
`Test_options` are *mandatory* and **must** precede the `create_options`. Parent directories of an *element* will also be created at creation process, if it doesn't exist with `0755` as permissions, if **-m** is not specified.
- Test and create:
* **-d** : true if *element* is a directory.
* **-p** : true if *element* is a fifo.
* **-S** : true if *element* is a socket.
* **-m** : true if *element* is a mountpoint.
* **-L** : true if *element* is a symlink.
- Test only
* **-e** : true if *element* exist.
* **-b** : true if *element* is a block.
* **-c** : true if *element* is a character.
* **-k** : true if sticky bit is set for *element*.
* **-n** : true if the length of *element* is non-zero.
* **-g** : true if *element* is set-group-id.
* **-r** : true if *element* is readable.
* **-s** : true if the size of *element* is greater than zero.
* **-t** : true if *element* is open and refers to a terminal.
* **-u** : true if set-user-id bit is set for *element*.
* **-w** : true if *element* is writable.
* **-x** : true if *element* is executable.
* **-f** : true if *element* is a regular file.
* **-z** : true if the length of *element* is zero.
* **-O** : true if *element* is owned by the effective user id.
* **-U** : true if *element* is owned by the effective group id.
* **-N** : true if *element* has been modified since it was last read.
* **-V** : true if *element* exist on the environment.
* **-E** : true if *element* is an empty directory. The test performs a check of an existing block, character, fifo, regular file, directory or symlink, inside an *element*.
## Create options
Depending on the *element* to create, `create_options` may or may not be mandatory. The following explanation specifies the mandatory ones.
- **-o** *opts* : mount options (correspond to mount -o). **Mandatory** is the case of mountpoint creation. This option has no effect in other cases.
- **-t** *type* : type mount options (correspond to mount -t). This also is used in case of symlink creation as a target option. **Mandatory** is the case of mountpoint or symlink creation. This option has no effect in other cases.
- **-d** *device* : device mount options (correspond to mount -t type device /directory). **Mandatory** is the case of mountpoint creation. This option has no effect in other cases.
- **-u** *uid* : changes *element*'s owner to (numeric) uid after the creation. Default is the uid of the owner of the process. This options is used for directory and fifos creation and it has no effects in other cases.
- **-g** *gid* : changes *element*'s owner to (numeric) gid after the creation. Default is the gid of the owner of the process. This options is used for directory and fifos creation and it has no effects in other cases.
- **-m** *mode* : create *element*'s permissions to (numeric) mode after the creation. Default is `0755`, `0666` and `0777` for a directory, fifo and socket creation respectively. This options is used for directory, fifos and sockets creation and it has no effects in other cases.
- **-s** : element will be `SOCK_DGRAM` where element is a socket. Default `SOCK_STREAM`. This options is used for socket creation and it has no effects in other cases.
- **-D** : disallow instant rebinding of *element* to the same path where an *element* is a socket. Default is allow. This options is used for socket creation and it has no effects in other cases.
- **-B** : the *element* will be blocking where *element* is a socket. Default is unlocked. This options is used for socket creation and it has no effects in other cases.
- **-b** *backlog* : set the maximum of backlog connection on the *element* where an *element* is a socket. Default `SOMAXCONN`. This options is used for socket creation and it has no effects in other cases.
## Usage examples
Test and create a directory if it does not exist yet:
```
#!/usr/bin/execlineb -P
execl-toc -d /run/user/1000 -m 0700
66-echo -- "/run/user was created"
```
Test a directory but do not create it if it does not exist:
```
#!/usr/bin/execlineb -P
execl-toc -D -d /run/user/1000
66-echo -- "/run/user already exist"
```
Test a directory, do not create if it does not exit, and do not execute prog
```
#!/usr/bin/execlineb -P
if -n { execl-toc -X -D -d /run/user/1001 }
66-echo -- "/run/user/1001 doesn't exist"
```
Test a mountpoint and create it if it does not exist
```
#!/usr/bin/execlineb -P
execl-toc -m /dev/hugepage -o noatime,nodev,noexec,nosuid -t hugetlbfs -d hugepages
66-echo -- "/dev/hugepage created and mounted successfully"
```
Test a socket and create it if it doesn't exist
```
#!/usr/bin/execlineb -P
execl-toc -S /run/user/bus
66-echo -- "you can now use the socket"
```
Test if a variable is set on the environment
```
#!/usr/bin/execlineb -P
execl-toc -V PATH
66-echo -- "PATH variable is set"
```
Test if a file exists
```
#!/usr/bin/execlineb -P
execl-toc -e /home/obarun/.xinitrc
66-echo -- ".xinitrc is a regular file"
```
Test if a file is executable
```
#!/usr/bin/execlineb -P
execl-toc -x /home/obarun/.xinitrc
66-echo -- ".xinitrc is executable"
```
Test if a directory is empty
```
#!/usr/bin/execlineb -P
execl-toc -E /mnt
66-echo -- "/mnt is emtpy"
```
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en" />
<title>The 66-tools Suite: 66-clock</title>
<meta name="Description" content="Detailed documentation for the 66-clock command which is part of the 66-tools software suite" />
<meta name="Keywords" content="66 command 66-clock service supervision execute script clock timestamp tai iso" />
<!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
</head>
<body>
<p>
<a href="index.html">66-tools</a><br/>
<a href="//web.obarun.org/software">Software</a><br/>
<a href="//obarun.org/">obarun.org</a>
</p>
<h1>66-clock</h1>
<p>
66-clock gets the system time and writes it with a specific format.
</p>
<h2> Interface </h2>
<pre>
66-clock [ -h ] [ -m <tt>message</tt> ] [ -n ] <em>tai|iso</em>
</pre>
<p>
66-clock writes the current system time as a TAIN64 or ISO timestamp depending of the argument past to stdout.
</p>
<p>It exits 0 on success and 111 on fail.</p>
<h2> Options </h2>
<ul>
<li> <tt>-h&nbsp;</tt>&nbsp;: prints this help. </li>
<li>
<tt>-m&nbsp;</tt><tt>message</tt>&nbsp;: prints <tt>message</tt> after the system time.
</li>
<li>
<tt>-n&nbsp;</tt>&nbsp;: output a trailing newline.
</li>
</ul>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment