Loading README.md 0 → 100644 +20 −0 Original line number Diff line number Diff line docker-init.sh ============== docker-init.sh is a file of shell helper functions for writing entrypoint scripts for docker images. Install ------- Just ADD the file [`docker-init.sh`][1] (and optionally [`docker-entrypoint.sh`][2] to your docker images like so: ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-entrypoint.sh /bin/entrypoint ``` [1]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-init.md "docker-init.sh documentation" [2]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-entrypoint.md "docker-entrypoint documentation" doc/docker-entrypoint.md 0 → 100644 +20 −0 Original line number Diff line number Diff line `docker-entrypoint.sh` is a reference implementation of a docker entrypoint script using `docker-init.sh`. It is not necessary to use this script to make use of `docker-init.sh`. Installation ============ If you use this script `docker-init.sh` must be installed at `/lib/docker-init.sh`. Both these files can be installed with the following added to a Dockerfile: ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-entrypoint.sh /bin/entrypoint ENTRYPOINT ["/bin/entrypoint"] ``` Any environment variable files can then be installed to `/etc/environment.d/` and init script fragments go into `/etc/init.d/`. doc/docker-init.md 0 → 100644 +72 −0 Original line number Diff line number Diff line Installation ============ `docker-init.sh` can be installed by adding it from a Dockerfile. If using with [`docker-entrypoint.sh`][1] if must be installed to `/lib/docker-init.sh`. ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ``` [1]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-entrypoint.md "docker-entrypoint documentation" Functions ========= die --- Print the exit message prefixed with "CRITICAL" to stderr and exit the script with an error exit code. ### Usage: `die <MESSAGE> [<MESSAGE> ...]` ### Example: `[ 1 -eq 2 ]] || die "condition failed"` ### Variables: EXIT_CODE : An integer greater than 0 to use as the exit code. If unset the exit code of the last command will be used. If invalid the default value of 1 is used. -------------------------------------------------------------------------------- warn ---- Print the warning prefixed with "WARNING" to stderr ### Usage: `warn <MESSAGE> [<MESSAGE> ...]` -------------------------------------------------------------------------------- source_each ----------- Source each file listed (if it exists). ### Usage: `source_each <PATH> [<PATH> ...]` ### Example: `source_each /etc/environment.d/*` -------------------------------------------------------------------------------- exec_each --------- Run each file if it exists and is executable. ### Usage: `exec_each <PATH> [<PATH> ...]` ### Example: `exec_each /etc/init.d/*` docker-init.sh +0 −34 Original line number Diff line number Diff line # Usage: die <MESSAGE> # # Print the exit message prefixed with "CRITICAL" to stderr and exit the script # with and error exit code. # # Args: # $1: Exit error message # # Vars: # EXIT_CODE: # An integer greater than 0 to use as the exit code. If unset the exit # code of the last command will be used. If invalid the default value of 1 # is used. die() { [ ${EXIT_CODE:=$?} -gt 0 ] || EXIT_CODE=1 Loading @@ -20,25 +6,12 @@ die() } # Usage: warn <MESSAGE> # # Print the warning prefixed with "WARNING" to stderr # # Args: # $1: Warning message warn() { echo "WARNING: $*" >&2 } # Usage: source_each <PATH> [<PATH> ...] # # Source each file listed (if it exists). A typical usage is: # source_each /etc/environment.d/* # # Args: # $*: File names source_each() { for file in "$@"; do Loading @@ -47,13 +20,6 @@ source_each() } # Usage: exec_each <PATH> [<PATH> ...] # # Run each file if it exists and is executable. A typical usage is: # exec_each /etc/init.d/* # # Args: # $*: Executable names exec_each() { for file in "$@"; do Loading Loading
README.md 0 → 100644 +20 −0 Original line number Diff line number Diff line docker-init.sh ============== docker-init.sh is a file of shell helper functions for writing entrypoint scripts for docker images. Install ------- Just ADD the file [`docker-init.sh`][1] (and optionally [`docker-entrypoint.sh`][2] to your docker images like so: ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-entrypoint.sh /bin/entrypoint ``` [1]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-init.md "docker-init.sh documentation" [2]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-entrypoint.md "docker-entrypoint documentation"
doc/docker-entrypoint.md 0 → 100644 +20 −0 Original line number Diff line number Diff line `docker-entrypoint.sh` is a reference implementation of a docker entrypoint script using `docker-init.sh`. It is not necessary to use this script to make use of `docker-init.sh`. Installation ============ If you use this script `docker-init.sh` must be installed at `/lib/docker-init.sh`. Both these files can be installed with the following added to a Dockerfile: ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-entrypoint.sh /bin/entrypoint ENTRYPOINT ["/bin/entrypoint"] ``` Any environment variable files can then be installed to `/etc/environment.d/` and init script fragments go into `/etc/init.d/`.
doc/docker-init.md 0 → 100644 +72 −0 Original line number Diff line number Diff line Installation ============ `docker-init.sh` can be installed by adding it from a Dockerfile. If using with [`docker-entrypoint.sh`][1] if must be installed to `/lib/docker-init.sh`. ``` ADD https://code.kodo.org.uk/kodo.org.uk/docker-init/raw/master/docker-init.sh /lib/docker-init.sh ``` [1]: https://code.kodo.org.uk/kodo.org.uk/docker-init/blob/master/doc/docker-entrypoint.md "docker-entrypoint documentation" Functions ========= die --- Print the exit message prefixed with "CRITICAL" to stderr and exit the script with an error exit code. ### Usage: `die <MESSAGE> [<MESSAGE> ...]` ### Example: `[ 1 -eq 2 ]] || die "condition failed"` ### Variables: EXIT_CODE : An integer greater than 0 to use as the exit code. If unset the exit code of the last command will be used. If invalid the default value of 1 is used. -------------------------------------------------------------------------------- warn ---- Print the warning prefixed with "WARNING" to stderr ### Usage: `warn <MESSAGE> [<MESSAGE> ...]` -------------------------------------------------------------------------------- source_each ----------- Source each file listed (if it exists). ### Usage: `source_each <PATH> [<PATH> ...]` ### Example: `source_each /etc/environment.d/*` -------------------------------------------------------------------------------- exec_each --------- Run each file if it exists and is executable. ### Usage: `exec_each <PATH> [<PATH> ...]` ### Example: `exec_each /etc/init.d/*`
docker-init.sh +0 −34 Original line number Diff line number Diff line # Usage: die <MESSAGE> # # Print the exit message prefixed with "CRITICAL" to stderr and exit the script # with and error exit code. # # Args: # $1: Exit error message # # Vars: # EXIT_CODE: # An integer greater than 0 to use as the exit code. If unset the exit # code of the last command will be used. If invalid the default value of 1 # is used. die() { [ ${EXIT_CODE:=$?} -gt 0 ] || EXIT_CODE=1 Loading @@ -20,25 +6,12 @@ die() } # Usage: warn <MESSAGE> # # Print the warning prefixed with "WARNING" to stderr # # Args: # $1: Warning message warn() { echo "WARNING: $*" >&2 } # Usage: source_each <PATH> [<PATH> ...] # # Source each file listed (if it exists). A typical usage is: # source_each /etc/environment.d/* # # Args: # $*: File names source_each() { for file in "$@"; do Loading @@ -47,13 +20,6 @@ source_each() } # Usage: exec_each <PATH> [<PATH> ...] # # Run each file if it exists and is executable. A typical usage is: # exec_each /etc/init.d/* # # Args: # $*: Executable names exec_each() { for file in "$@"; do Loading