Skip to content

Instantly share code, notes, and snippets.

@lewismarshall
Created May 24, 2016 12:17
Show Gist options
  • Save lewismarshall/443336018696f6471f9cb4c61e08354b to your computer and use it in GitHub Desktop.
Save lewismarshall/443336018696f6471f9cb4c61e08354b to your computer and use it in GitHub Desktop.
#!/bin/bash
function get_config() {
conf_name="${1}"
conf_file="${CONFIG_DIR}/${conf_name}"
if [ -f ${conf_file} ]; then
echo "Using config from ${conf_file}"
value="$(cat ${conf_file})"
else
value="${!conf_name}"
fi
if [ ! -z ${value} ]; then
eval "export ${conf_name}=${value}"
fi
}
for file in ${CONFIG_DIR}/* ; do
get_config $(basename ${file})
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment