Attempt to get multiple ports working, just the --vnc option isn't being parsed properly yet

This commit is contained in:
Tim Edwards 2019-05-09 14:05:16 +02:00
parent 24be1cdd8a
commit 9e9cd87659
2 changed files with 19 additions and 11 deletions

View File

@ -15,6 +15,8 @@ parts:
plugin: dump
stage-packages:
- websockify
- bash
- jq
hooks:
install:

View File

@ -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