diff --git a/metche b/metche index 2549d43..3fd097e 100755 --- a/metche +++ b/metche @@ -66,10 +66,33 @@ " -if [ -f /etc/metche.conf ]; then - . /etc/metche.conf +function display_usage { + ( echo "Usage: $0 [-h HOST] list" + echo " $0 [-h HOST] report [milestone]" + echo " $0 [-h HOST] cron" + echo "If -h is specified, /etc/metche/HOST.conf is used instead of /etc/metche.conf and" + echo "./metche.conf, which are tried in this order before falling back to the hardcoded" + echo "defaults." + ) >&2 +} + +if [ "x$1" == "x-h" ]; then + if [ -f /etc/metche/$2.conf ]; then + . /etc/metche/$2.conf + CMD="$3" + MILESTONE="$4" + else + display_usage + exit 1 + fi else - . metche.conf + if [ -f /etc/metche.conf ]; then + . /etc/metche.conf + elif [ -f metche.conf ]; then + . metche.conf + fi + CMD="$1" + MILESTONE="$2" fi PATH="/bin:/usr/bin" @@ -208,12 +231,12 @@ save_state "testing" fi -case "$1" in +case "$CMD" in report) - if [ "x$2" == "x" ]; then + if [ "x$MILESTONE" == "x" ]; then report_changes "testing-latest" else - report_changes "testing-$2" + report_changes "testing-$MILESTONE" fi exit 0 ;; @@ -252,10 +275,7 @@ fi ;; *) - (echo "Usage: $0 list" - echo " $0 report [milestone]" - echo " $0 cron" - ) >&2 + display_usage exit 1 ;; esac