Giter VIP home page Giter VIP logo

container-tools's Introduction

Container tools

Description

A collection of POSIX compatible shell scripts used for configuration and process management and logging inside Linux containers.

All scripts have been tested with Busybox, Debian and Alpine Linux inside of a Docker container environment, but should work with other container environments and non-containerized Linux machines.

Tools

envconfig

envconfig.sh is a wrapper script to write environment variables in config files.
It replaces placeholders and creates files, then starts the given command.
It supports multiline variables and base64 encoded data.

Usage

./envconfig.sh [-f config_file] [command] [args...]

Configuration

The default envconfig configuration file is /usr/local/etc/envconfig.conf.
An alternate configuration file can be provided via -f option.

Each line of the configuration for envconfig must have the following format:

VARIABLE_NAME /absolute/path/to/config/file

Each mapped variable will be unset before the command given to envconfig is run, unless the variable name is prefixed with an exclamation mark:

!VARIABLE_NAME /absolute/path/to/config/file

Empty lines and lines starting with a hash (#) will be ignored.
Multiple mappings of the same VARIABLE_NAME or path are possible.

Placeholders in config files must have the following format:

{{VARIABLE_NAME}}

Variable content can be provided in base64 encoded form, given the following:
The base64 data must be provided in a variable with B64_ prefix.
The decoded data will then be used for the variable without the prefix.
For example, the content of $B64_DATA will be decoded and used as $DATA.

log

log.sh executes the given command and logs the output.
A datetime prefix is added in front of each output line.

Usage

./log.sh command [args...]

Configuration

The location of the log output can be defined with the following environment variable:

LOGFILE="/dev/stdout"

The date output formatting can be defined with the following environment variable:

DATECMD="date -u +%Y-%m-%dT%H:%M:%SZ"

superd

superd.sh is a supervisor daemon to manage long running processes as a group.
All remaining child processes are terminated as soon as one child exits.
Written as entrypoint service for multi-process docker containers.

Usage

./superd.sh [config_file]

Configuration

The default superd configuration file is /usr/local/etc/superd.conf.
An alternate configuration file can be provided as first argument.

Each line of the superd configuration file must have the following format:

command [args...]

Each command will be run by superd as a background process.
If one command terminates, all commands will be terminated.
Empty lines and lines starting with a hash (#) will be ignored.

wait-for

wait-for.sh is a script to wait for the given host(s) to be available via TCP before executing a given command.
It accepts a number of host:port combinations to connect to via netcat.
The command to execute after each host is reachable can be supplied after the -- argument.
The default timeout of 10 seconds can be changed via -t timeout argument.

Usage

./wait.sh [-t timeout] host:port [host:port] [...] [-- command args...]

License

Released under the MIT license.

Author

Sebastian Tschan

container-tools's People

Contributors

blueimp avatar

Watchers

 avatar

Forkers

xakutara

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.