[provisioning] Support running recipes from arbitrary locations

This commit is contained in:
Correl Roush 2018-02-28 00:09:33 -05:00
parent 88cf84c5c4
commit 79d0fc0447

View file

@ -52,11 +52,24 @@ function _run {
} }
function _recipe { function _recipe {
local recipe
local path
if [ -f "$1" ]; then
recipe="$(basename $1)"
path=$(dirname "$1")
elif [ -f "${RECIPE_PATH}/$1" ]; then
recipe="$1"
path="${RECIPE_PATH}"
else
echo "Could not load recipe '$1'" >&2
exit 1
fi
STACK+=("$1") STACK+=("$1")
pushd "$path"
echo "-- Recipe '${STACK[@]}' --" echo "-- Recipe '${STACK[@]}' --"
source ${HOME}/dotfiles/recipes/$1 source "./${recipe}"
unset STACK[${#STACK[@]}-1]
echo "-- Recipe '${STACK[@]}' --" echo "-- Recipe '${STACK[@]}' --"
popd
} }
USER=${USER:-$(whoami)} USER=${USER:-$(whoami)}