$bf-e"docs""\e[91m""Hi"[docs] 2021-09-19 18:00:00 |Hi# (in red)$bf-e"docs""\e[92m""Hi""alpine-s6"[docs] 2021-09-19 18:00:00 |alpine-s6:Hi# (in green)
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-echo"Hi"[bf] 2021-09-19 18:00:00 |Hi# (in black / white)$bf-echo"Hi""docs"[bf] 2021-09-19 18:00:00 |docs:Hi# (in black / white)
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-error"Die"[bf] 2021-09-19 18:00:00 |Die# (in red)$bf-error"Die""docs"[bf] 2021-09-19 18:00:00 |docs:Die# (in red)
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-notok"Error"[bf] 2021-09-19 18:00:00 |Error# (in red)$bf-notok"Error""docs"[bf] 2021-09-19 18:00:00 |docs:Error# (in red)
bf-ok
Echoes "$1: $2" to stdout in green with prefix.
Arguments
Text to output
[Optional] Script / executable name
Usage
$bf-ok"Hi"[bf] 2021-09-19 18:00:00 |Hi# (in green)$bf-ok"Hi""docs"[bf] 2021-09-19 18:00:00 |docs:Hi# (in green)
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-adduser"fred"[bf] 2021-09-19 18:00:00 |bf-adduser:Addinguserandgroup'fred'...[bf] 2021-09-19 18:00:00 |bf-adduser:done.'fred'...# (in green)$cat/etc/passwd...fred:x:1000:1000:LinuxUser,,,:/home/fred:/bin/ash$bf-adduser"fred"1001[bf] 2021-09-19 18:00:00 |bf-adduser:Addinguserandgroup'fred'...[bf] 2021-09-19 18:00:00 |bf-adduser:done.'fred'...# (in green)$cat/etc/passwd...fred:x:1001:1001:LinuxUser,,,:/home/fred:/bin/ash$bf-adduser"fred"10021003[bf] 2021-09-19 18:00:00 |bf-adduser:Addinguserandgroup'fred'...[bf] 2021-09-19 18:00:00 |bf-adduser:done.'fred'...# (in green)$cat/etc/passwd...fred:x:1002:1003:LinuxUser,,,:/home/fred:/bin/ash
bf-ch
Changes ownership and/or permissions of file / directory glob.
Arguments
Required (one or both):
-o X use chown to set ownership to "X"
-m Y use chmod to set permissions to "Y"
Optional:
-t f|d apply only to files ("f") or directories ("d")
-rif -t is not specified, applies action recursively to all files and directories
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.
FROM bfren/alpine-s6:alpine3.14
COPY ./overlay /
RUN bf-install
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 /!).