X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=share%2Fbtr%2Fbtrc.sh;h=a23031859e4c56461fa77bb498c5980a765a43db;hb=refs%2Fheads%2Fmaster;hp=beff3b4992b26a6b531d4981c643cc4c5432d1ae;hpb=03ad57898bb90437b1f3c7e9c0f18e837f06331f;p=m6w6%2Fbtr diff --git a/share/btr/btrc.sh b/share/btr/btrc.sh old mode 100644 new mode 100755 index beff3b4..a230318 --- a/share/btr/btrc.sh +++ b/share/btr/btrc.sh @@ -1,34 +1,7 @@ #!/bin/bash -function btrc-help { - btr-banner - echo - echo "Usage: $(basename $0) [-hyvq] [] [action] " - echo - echo " -h, --help Display this help" - echo " -y, --yes Always assume yes" - echo " -v, --verbose Be more verbose" - echo " -q, --quiet Be more quiet" - echo - echo " Options:" - echo " -D, --directory=" - echo " Use this directory as work root" - echo - echo " Actions:" - echo " s[tatus] Show the status of the build" - echo " r[un] Make a BTR run" - echo " c[ancel] Cancel any currently running BTR job" - echo " t[erminate] Terminate the BTR daemon" - echo - echo " Arguments:" - echo " The build id of the \`btrd\` daemon, usually" - echo " something like \$repository@\$branch[-\$suffix]." - echo - exit -} -export -f btrc-help - -function btrc-parseargs { +function btrc_parseargs { + eval set -- "$BTR_EXTRA_ARGS" while test $# -gt 0 do case "$1" in @@ -57,57 +30,13 @@ function btrc-parseargs { done } -function btrc-parseopts { - local shortoptions="hvqyD:" - local longoptions="help,verbose,quiet,yes,directory:" - local options=$(getopt \ - --options "$shortoptions" \ - --longoptions "$longoptions" \ - -- "$@" \ - ) - - if test $? -ne 0 ; then - btrc-help - fi - - eval set -- "$options" +function btrc_setup { + btrc_parseargs - while test $# -gt 1 - do - case "$1" in - -h|--help) - btrc-help - ;; - -y|--yes) - BTR_FORCEYES=true - ;; - -v|--verbose) - BTR_VERBOSE=true - BTR_QUIET=false - ;; - -q|--quiet) - BTR_QUIET=true - BTR_VERBOSE=false - ;; - # - -D|--directory) - BTR_RUNDIR="$2" - shift - ;; - # - --) - shift - btrc-parseargs "$@" - esac - shift - done -} -export -f btrc-parseopts - -function btrc-setup { if test -z "$BTR_BUILD" then - btrc-help + btr_banner + btr_help fi if test -z "$BTR_ACTION" @@ -115,8 +44,8 @@ function btrc-setup { BTR_ACTION=status fi - btr-setup-rundir - btr-setup-verbosity + btr_setup_rundir + btr_setup_verbosity false BTR_PIDFILE="$BTR_RUNDIR/$BTR_BUILD.pid" BTR_LOGFILE="$BTR_RUNDIR/$BTR_BUILD.log" @@ -131,12 +60,12 @@ function btrc-setup { cat "$BTR_LOGFILE" echo fi - error "Could not find pid file of btr daemon for '$BTR_BUILD' in $BTR_RUNDIR." + error "Could not find btrd pid file of '$BTR_BUILD' in $BTR_RUNDIR." fi } -export -f btrc-setup +export -f btrc_setup -function btrc-signal { +function btrc_signal { local sig=$1 local pid=$(cat "$BTR_PIDFILE") kill -s $sig $pid @@ -153,7 +82,7 @@ function btrc-signal { ;; esac } -export -f btrc-signal +export -f btrc_signal # vim: noet