X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=scripts%2Fafm-util.in;fp=scripts%2Fafm-util.in;h=45946852d7177f1e145fcb6a445acc0c61c2dd9c;hb=275f7f5b9d2b148ae61da39c87f81c75974ab31f;hp=2cc714b8a10aa4b6bcb75da9a615db96f560cf87;hpb=9a0d792982ae637dd32e6939724441fe1b5fb47d;p=src%2Fapp-framework-main.git diff --git a/scripts/afm-util.in b/scripts/afm-util.in index 2cc714b..4594685 100755 --- a/scripts/afm-util.in +++ b/scripts/afm-util.in @@ -1,10 +1,29 @@ #!/bin/bash send() { - afb-client-demo -H -d unix:@afm_platform_rundir@/apis/ws/afm-main "$1" "$2" | - awk '$1=="ON-REPLY" && $3!="success"{$1="ERROR:";$2="";print > "/dev/stderr";exit 1;}NR>1' + local verb="$1" + afb-client-demo -H -d unix:@afm_platform_rundir@/apis/ws/afm-main "$verb" "$2" | + awk '$1=="ON-REPLY" && $3!="success"{$1="ERROR:";$2="";print > "/dev/stderr";exit 1;}NR>1' } +all=false +force=false +uid="$UID" +help=false + +set -- $(getopt -l all,force,help,uid: -s afhu: -n afm-util -- "$@") +while : +do + case "$1" in + -a|--all) all=true; shift;; + -f|--force) force=true; shift;; + -h|--help) help=true; shift;; + -u|--uid) uid="$2"; shift 2;; + --) shift; break;; + *) help=true; break;; + esac +done + getall() { case "$1" in -a|--all) echo -n '{"all":true}';; @@ -15,14 +34,14 @@ getall() { case "$1" in list|runnables) - send runnables $(getall $2) + send runnables "{\"all\":$all,\"uid\":$uid}" ;; add|install) f=$(realpath $2) r=true if [[ "$(basename $0)" = "afm-install" ]]; then r=false; fi - send install '{"wgt":"'"$f"'","force":true,"reload":'"$r"'}' + send install "{\"wgt\":\"$f\",\"force\":$force,\"reload\":$r}" ;; remove|uninstall) @@ -32,36 +51,31 @@ case "$1" in info|detail) i=$2 - send detail "\"$i\"" + send detail "{\"id\":$i,\"uid\":$uid}" ;; ps|runners) - send runners $(getall $2) + send runners "{\"all\":$all,\"uid\":$uid}" ;; run|start) i=$2 - send start "\"$i\"" - ;; - - run-remote|start-remote) - i=$2 - send start '{"id":"'"$i"'","mode":"remote"}' + send start "{\"id\":$i,\"uid\":$uid}" ;; once) i=$2 - send once "\"$i\"" + send once "{\"id\":$i,\"uid\":$uid}" ;; terminate|kill) i=$2 - send terminate "$i" + send terminate "{\"runid\":$i,\"uid\":$uid}" ;; state|status) i=$2 - send state "$i" + send state "{\"runid\":$i,\"uid\":$uid}" ;; -h|--help|help)