summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-07-27 15:16:18 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-07-27 15:16:18 (EDT)
commit3f42e8b534cd16413d8ec4412c3c00c91145e1cf (patch)
tree9b7853bd732e6a77716be5bf028898117a9f406e /src
parenta964a7eec5ececd1c2fe15281839886b298fb510 (diff)
pro-archman: Parse a -b option and load conf file.
Diffstat (limited to 'src')
-rw-r--r--src/pro-archman.sh50
1 files changed, 44 insertions, 6 deletions
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 "${@}"