media-sucker/scripts/common.sh

25 lines
485 B
Bash
Executable File

#! /bin/sh
# 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)}
log () {
printf "\033[36m=== [%s] \033[0m %s\n" "$0" "$*"
}
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' \
> env.json.new \
&& mv env.json.new env.json
}