Added specifying config on cli that user home config does not override.

This commit is contained in:
Eric Renfro 2015-02-18 14:11:16 -05:00
parent ca7975f2c1
commit 15cba346cf
2 changed files with 10 additions and 3 deletions

View File

@ -43,7 +43,7 @@ while :; do
case "$1" in
-h|--help) usage; exit 0;;
-c|--encrypt) CRYPTKEY=""; shift;;
-f|--config) shift; CONFFILE="$1"; shift;;
-f|--config) shift; CONFFILE="$1"; CONFFILECLI=1; shift;;
-d|--days) shift; USER_CA_DAYS="$1"; shift;;
-l|--crl-days) shift; USER_CA_CRL_DAYS="$1"; shift;;
-b|--bits) shift; USER_CA_CRT_BITS="$1"; shift;;

View File

@ -55,11 +55,18 @@ ca_load_conf() {
source "$CONFFILE"
fi
# Override system configuration with local values.
source "$HOME/.ca-scripts.conf"
# If manually set on command-line, don't load.
if [ -n "$CONFFILECLI" ]; then
source "$HOME/.ca-scripts.conf"
fi
elif [ -r "$CONFFILE" ]; then
source "$CONFFILE"
else
error "Unable to load $HOME/.ca-scripts.conf or $CONFFILE"
if [ -n "$CONFFILECLI" ]; then
error "Unable to load $HOME/.ca-scripts.conf or $CONFFILE"
else
error "Unable to load $CONFFILE"
fi
fi
# TODO: Refactored config loader with error fallback, allowing local overrides.