media-sucker/scripts/common.sh

24 lines
456 B
Bash
Raw Normal View History

2022-01-06 12:31:30 -07:00
#! /bin/sh
2022-01-06 17:33:25 -07:00
# If you haven't set OUTDIR, set it to the default
: ${OUTDIR:=/incoming}
export OUTDIR
# This gets set to the directory containing what's currently running
: ${SCRIPTS:=$(dirname $0)}
2022-01-06 12:31:30 -07:00
log () {
printf "\033[36m=== [%s] \033[0m %s\n" "$0" "$*"
}
2022-01-09 16:26:12 -07:00
getenv () {
jq -r --arg key "$1" '.[$key]' < env.json
}
setenv () {
(cat env.json 2>/dev/null || echo '{}') \
| jq --arg key "$1" --arg val "$2" '.[$key] = $val' \
| sponge env.json
2022-01-06 17:33:25 -07:00
}