summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 "${@}"