Alpine: Executables
Various helper executables for providing standard output and simplifying common tasks.
Output
bf-debug
Echoes "$1
: $2
" to stdout
in grey with prefix (see bf-e) - but only if environment variable BF_DEBUG
is set to "1".
Arguments
Text to output
[Optional] Script / executable name
Usage
bf-done
Echoes 'done.' to stdout
in green with prefix (see bf-ok).
Arguments
[Optional] Script / executable name
Usage
bf-e
Echoes $3
to stdout
in colour $2
with prefix:
"[$1
] %Y-%m-%d %H:%M:%S".
Arguments
Namespace (default value for other output helper executables is 'bf')
ANSI colour code (see e.g. here)
Text to output
[Optional] Script / executable name
Usage
bf-echo
Echoes "$1
: $2
" to stdout
in default colour with prefix (see bf-e).
Arguments
Text to output
[Optional] Script / executable name
Usage
bf-error
Echoes "$1
: $2
" to stdout
in red with prefix (see bf-e), and returns 1. This will end execution of the calling script if you use, e.g. set -euo pipefail
at the top of your scripts (recommended).
Arguments
Text to output
[Optional] Script / executable name
Usage
bf-notok
Like bf-error echoes "$1
: $2
" to stdout
in red with prefix, but doesn't end execution of calling script.
Arguments
Text to output
[Optional] Script / executable name
Usage
bf-ok
Echoes "$1
: $2
" to stdout
in green with prefix.
Arguments
Text to output
[Optional] Script / executable name
Usage
Helpers
bf-adduser
Create user with id $2
, group with id $3
, both with name $1
, and no password.
Arguments
User and group name
[Optional] User ID (default: 1000)
[Optional] Group ID (default: UID)
Usage
bf-ch
Changes ownership and/or permissions of file / directory glob.
Arguments
Required (one or both):
-o X
usechown
to set ownership to "X"-m Y
usechmod
to set permissions to "Y"
Optional:
-t f|d
apply only to files ("f") or directories ("d")-r
if-t
is not specified, applies action recursively to all files and directories
Usage
bf-clear
Clears contents of /tmp
and apk
cache.
Usage
bf-esh
Calls esh
in a consistent manner.
Arguments
Path to input (template) file
Path to output (generated) file
Usage
bf-image
Display name and version of the current image, and a link to the GitHub repository.
Usage
bf-install
Run install /tmp/install
and then perform cleanup (see bf-clear). Within the ecosystem this would normally be used in a Dockerfile
Usage
This is the basic structure of Dockerfiles based on the Alpine S6 image, copying overlay and then running the standard installation.
bf-rmrf
Runs rm -rf $1
safely: doing nothing if $1
is empty. This is handy if the path you are deleting is contained in a variable (it effectively stops rm -rf /
!).
Arguments
Folder path / file glob to delete.
Usage
bf-rnd
Generates a string of random letters and numbers of length $1
.
Arguments
[Optional] Number of characters to return
Usage
bf-test-url
Uses wget
to test URL $1
.
Arguments
URL to test
Usage
bf-tz
Sets the container's timezone to $1
. (Installs tzdata
package, changes timezone and then removes tzdata
).
Arguments
Valid timezone (e.g. Europe/London)
Usage
Note the change in time on line 12.
Last updated