From 3f42e8b534cd16413d8ec4412c3c00c91145e1cf Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 27 Jul 2013 15:16:18 -0400 Subject: pro-archman: Parse a -b option and load conf file. --- (limited to 'src') diff --git a/src/pro-archman.sh b/src/pro-archman.sh index 692b84c..4b857e4 100644 --- a/src/pro-archman.sh +++ b/src/pro-archman.sh @@ -30,6 +30,10 @@ LF=' # Global variables loading_cmd= +opt_base_dir= +conf_incoming_channel= +conf_incoming_dir= +conf_pool_gc_delay= archive= # use() must be defined inline so it can be used to load other modules. @@ -78,19 +82,53 @@ main() load_locale load_cmds - # FIXME: Make this a command-line option. - archive='archive' - - # FIXME: Read from conf file. - conf_incoming_channel='dev' - conf_incoming_dir='incoming' + opt_base_dir='.' + get_options "${@}" + shift $(($OPTIND - 1)) if [ ${#} -lt 1 ]; then cmd_help_main >&2 exit 1 fi + # FIXME: Remove. + archive="${opt_base_dir}" + + get_conf + run_cmd "${@}" + + return ${?} +} + +get_options() +{ + local opt= + + while getopts 'b:' opt; do + case "${opt}" in + 'b') + opt_base_dir="$(cd "${OPTARG}" && pwd)" + ;; + esac + done + + return 0 +} + +get_conf() +{ + # Set defaults. + conf_incoming_channel='dev' + conf_incoming_dir='../incoming' + conf_pool_gc_delay=86400 + + . "${opt_base_dir}/conf" + + conf_incoming_dir="$(cd "${opt_base_dir}" && \ + cd "${conf_incoming_dir}" && pwd)" + + return 0 } main "${@}" -- cgit v0.9.1