diff options
author | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
commit | 7400e108286a0fceacdac63b125fdc924c2dd50c (patch) | |
tree | 4849176606778477ead8a9ded4c9ff43bf4a8feb /aux/lib.sh | |
parent | servers/nixvps/configuration.nix: Serve Git repositories from NGINX, remove G... (diff) | |
download | server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.gz server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.xz |
aux/: Update
Diffstat (limited to 'aux/lib.sh')
-rwxr-xr-x | aux/lib.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/aux/lib.sh b/aux/lib.sh new file mode 100755 index 0000000..c31c4fb --- /dev/null +++ b/aux/lib.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# +# Generally, utilities that I expected to exist in POSIX, but don't. +# + +uuid() { + # Taken from: + # https://serverfault.com/a/799198 + od -xN20 /dev/urandom | \ + head -1 | \ + awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}' +} + +tmpname() { + echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname." +} + +mkstemp() { + name="$(tmpname)" + touch "$name" + echo "$name" +} + +mkdtemp() { + name="$(tmpname)" + rm -f "$name" + mkdir "$name" + echo "$name" +} |