From 2dab36eb25c37d8c6534b3e181e8aea94f72e388 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Sun, 22 Jul 2018 16:15:49 +0200 Subject: Added a way to make 4a-api work on host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bin/lib4a-tools.sh | 17 ++++++++++++++--- 1 file 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() { -- cgit 1.2.3-korg