From 9e9cd87659b9e5084519aaa66a72c317c9a48e17 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 9 May 2019 14:05:16 +0200 Subject: [PATCH] Attempt to get multiple ports working, just the --vnc option isn't being parsed properly yet --- snap/snapcraft.yaml | 2 ++ utils/svc_wrapper.sh | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index ff7e6ea0..b05c8822 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -15,6 +15,8 @@ parts: plugin: dump stage-packages: - websockify + - bash + - jq hooks: install: diff --git a/utils/svc_wrapper.sh b/utils/svc_wrapper.sh index 5564c594..c203fa93 100755 --- a/utils/svc_wrapper.sh +++ b/utils/svc_wrapper.sh @@ -1,13 +1,19 @@ -#!/bin/sh +#!/bin/bash -listen_port="$(snapctl get novncsvc.listen-port)" -vnc_host_port="$(snapctl get novncsvc.vnc-host-port)" +echo "snactp get services is: $(snapctl get services)" -expr "$listen_port" : '^[0-9]\+$' > /dev/null -listen_port_valid=$? -if [ ! $listen_port_valid ] || [ -z "$vnc_host_port" ]; then - # invalid values mean the service is disabled, do nothing - echo "novncsvc disabled" -else - $SNAP/utils/launch.sh --listen $listen_port --vnc $vnc_host_port -fi +#for service in $(snapctl get services | cut -f1 -d' ' |cut -f2 -d".") # the cut calls get only the first column and then change 'service.n6801' to 'n6801' +snapctl get services | jq -c '.[]' | while read service; do + listen_port="$(echo $service | jq '.listen')" + vnc_host_port="$(echo $service | jq '.vnc')" + + # check for valid values + expr "$listen_port" : '^[0-9]\+$' > /dev/null + listen_port_valid=$? + if [ ! $listen_port_valid ] || [ -z "$vnc_host_port" ]; then + # invalid values mean the service is disabled, do nothing + echo "novnc: not starting service ${service} with listen_port ${listen_port} and vnc_host_port ${vnc_host_port}" + else + $SNAP/utils/launch.sh --listen $listen_port --vnc $vnc_host_port + fi +done