diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2018-07-22 16:15:49 +0200 |
---|---|---|
committer | Thierry Bultel <thierry.bultel@iot.bzh> | 2019-04-24 14:18:11 +0200 |
commit | 2dab36eb25c37d8c6534b3e181e8aea94f72e388 (patch) | |
tree | 1be4867d306360383629e308b2871c9644e12ca5 | |
parent | e8b23b37394800332baf1ffc9b9777c67dc664cd (diff) |
Added a way to make 4a-api work on host
On host you can't detect the API port and token based on the systemd
unit file. So when the file is not found, use API_4A_PORT and
API_4A_TOKEN environment variable to allow users to make it work on host
so they can still test 4a.
Change-Id: I6379457c29c9e45db9cce8c78f6d646935b2caa5
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rw-r--r-- | bin/lib4a-tools.sh | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/lib4a-tools.sh b/bin/lib4a-tools.sh index 4029046..ab0ee18 100644 --- a/bin/lib4a-tools.sh +++ b/bin/lib4a-tools.sh @@ -24,10 +24,21 @@ function debug() { [[ "$DEBUG" == 1 ]] && echo "${color_blue}DEBUG:" "$@" "${col function 4a-client() { # get port for audio service - local port=$(grep -sr X-AFM-http /var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service | cut -f2 -d'=') + local port="" + local token="HELLO" - debug "Detected 4A service on port $port" - afb-client-demo -H "localhost:$port/api?token=HELLO&uuid=magic" "$@" + if [ -f "/var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service" ]; then + log "Detected systemd unit file!" + port=$( grep -sr X-AFM-http /var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service | cut -f2 -d'=' ) + log "Port detected: $port" + else + log "No systemd unit file detected, assuming running on host, please set 'API_4A_PORT' and 'API_4A_TOKEN' environment variables to correct values!" + port=${API_4A_PORT:-1234} + token=${API_4A_TOKEN:-"HELLO"} + log "Port: $port, token: $token" + fi + + afb-client-demo -H "localhost:$port/api?token=$token&uuid=magic" "$@" } function 4a-roles() { |