afm-util/install: use of web socket connection
[src/app-framework-main.git] / scripts / afm-util
1 #!/bin/bash
2
3 send() {
4         afb-client-demo -H -d unix:/run/afm/apis/ws/afm-main "$1" "$2" |
5         awk '$1=="ON-REPLY-FAIL"{$1="ERROR:";$2="";print;exit 1;}NR>1'
6 }
7
8 case "$1" in
9
10   list|runnables)
11     send runnables true
12     ;;
13
14   add|install)
15     f=$(realpath $2)
16     send install '{"wgt":"'"$f"'","force":true}'
17     ;;
18
19   remove|uninstall)
20     i=$2
21     send uninstall "\"$i\""
22     ;;
23
24   info|detail)
25     i=$2
26     send detail "\"$i\""
27     ;;
28
29   ps|runners)
30     send runners true
31     ;;
32
33   run|start)
34     i=$2
35     send start "\"$i\""
36     ;;
37
38   run-remote|start-remote)
39     i=$2
40     send start '{"id":"'"$i"'","mode":"remote"}'
41     ;;
42
43   once)
44     i=$2
45     send once "\"$i\""
46     ;;
47
48   terminate|kill)
49     i=$2
50     send terminate "$i"
51     ;;
52
53   stop|pause)
54     i=$2
55     send pause "$i"
56     ;;
57
58   resume|continue)
59     i=$2
60     send resume "$i"
61     ;;
62
63   state|status)
64     i=$2
65     send state "$i"
66     ;;
67
68   -h|--help|help)
69     cat << EOC
70 usage: $(basename $0) command [arg]
71
72 The commands are:
73
74   list
75   runnables      list the runnable widgets installed
76
77   add wgt
78   install wgt    install the wgt file
79
80   remove id
81   uninstall id   remove the installed widget of id
82
83   info id
84   detail id      print detail about the installed widget of id
85
86   ps
87   runners        list the running instance
88
89   run id
90   start id       start an instance of the widget of id
91
92   once id        run once an instance of the widget of id
93
94   kill rid
95   terminate rid  terminate the running instance rid
96
97   stop rid
98   pause rid      pause the running instance rid
99
100   resume rid
101   continue rid   continue the previously paused rid
102
103   status rid
104   state rid      get status of the running instance rid
105
106 EOC
107     ;;
108
109   *)
110     echo "unknown command $1" >&2
111     exit 1
112     ;;
113 esac
114
115