Added further functionality to config loader including system-wide and local override
This commit is contained in:
parent
f971df16c7
commit
ca7975f2c1
1 changed files with 22 additions and 8 deletions
|
@ -49,15 +49,29 @@ ca_set_default() {
|
||||||
|
|
||||||
ca_load_conf() {
|
ca_load_conf() {
|
||||||
local varname vartest varerr vardef error ca_name
|
local varname vartest varerr vardef error ca_name
|
||||||
if [ ! -r "$CONFFILE" ]; then
|
if [ -r "$HOME/.ca-scripts.conf" ]; then
|
||||||
error "Unable to find $CONFFILE."
|
# Does a system-wide config exist? If so load it first.
|
||||||
|
if [ -r "$CONFFILE" ]; then
|
||||||
|
source "$CONFFILE"
|
||||||
|
fi
|
||||||
|
# Override system configuration with local values.
|
||||||
|
source "$HOME/.ca-scripts.conf"
|
||||||
|
elif [ -r "$CONFFILE" ]; then
|
||||||
|
source "$CONFFILE"
|
||||||
|
else
|
||||||
|
error "Unable to load $HOME/.ca-scripts.conf or $CONFFILE"
|
||||||
fi
|
fi
|
||||||
# XXX: seems like . <file> doesn't work if it's not relative to a directory
|
|
||||||
# look this up on the internet sometime to work out why...
|
# TODO: Refactored config loader with error fallback, allowing local overrides.
|
||||||
if [ "$CONFFILE" = "$( basename $CONFFILE )" ]; then
|
#if [ ! -r "$CONFFILE" ]; then
|
||||||
CONFFILE="./$CONFFILE"
|
# error "Unable to find $CONFFILE."
|
||||||
fi
|
#fi
|
||||||
. "$CONFFILE"
|
## XXX: seems like . <file> doesn't work if it's not relative to a directory
|
||||||
|
## look this up on the internet sometime to work out why...
|
||||||
|
#if [ "$CONFFILE" = "$( basename $CONFFILE )" ]; then
|
||||||
|
# CONFFILE="./$CONFFILE"
|
||||||
|
#fi
|
||||||
|
#. "$CONFFILE"
|
||||||
|
|
||||||
error=""
|
error=""
|
||||||
while read vartest varname; do
|
while read vartest varname; do
|
||||||
|
|
Loading…
Reference in a new issue