novnc snap now creates services specified by snap set config settings. Switched to forking daemon type to handle multiple novnc services at a time
This commit is contained in:
parent
9e9cd87659
commit
2e97cc7def
|
|
@ -17,6 +17,8 @@ parts:
|
||||||
- websockify
|
- websockify
|
||||||
- bash
|
- bash
|
||||||
- jq
|
- jq
|
||||||
|
- python-numpy
|
||||||
|
- python3-numpy
|
||||||
|
|
||||||
hooks:
|
hooks:
|
||||||
install:
|
install:
|
||||||
|
|
@ -30,5 +32,5 @@ apps:
|
||||||
plugs: [network, network-bind]
|
plugs: [network, network-bind]
|
||||||
novncsvc:
|
novncsvc:
|
||||||
command: utils/svc_wrapper.sh
|
command: utils/svc_wrapper.sh
|
||||||
daemon: simple
|
daemon: forking
|
||||||
plugs: [network, network-bind]
|
plugs: [network, network-bind]
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "snactp get services is: $(snapctl get services)"
|
# `snapctl get services` returns a JSON array, example:
|
||||||
|
#{
|
||||||
|
#"n6801": {
|
||||||
|
# "listen": 6801,
|
||||||
|
# "vnc": "localhost:5901"
|
||||||
|
#},
|
||||||
|
#"n6802": {
|
||||||
|
# "listen": 6802,
|
||||||
|
# "vnc": "localhost:5902"
|
||||||
|
#}
|
||||||
|
#}
|
||||||
|
snapctl get services | jq -c '.[]' | while read service; do # for each service the user sepcified..
|
||||||
|
# get the important data for the service (listen port, VNC host:port)
|
||||||
|
listen_port="$(echo $service | jq --raw-output '.listen')"
|
||||||
|
vnc_host_port="$(echo $service | jq --raw-output '.vnc')" # --raw-output removes any quotation marks from the output
|
||||||
|
|
||||||
#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'
|
# check whether those values are valid
|
||||||
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
|
expr "$listen_port" : '^[0-9]\+$' > /dev/null
|
||||||
listen_port_valid=$?
|
listen_port_valid=$?
|
||||||
if [ ! $listen_port_valid ] || [ -z "$vnc_host_port" ]; then
|
if [ ! $listen_port_valid ] || [ -z "$vnc_host_port" ]; then
|
||||||
# invalid values mean the service is disabled, do nothing
|
# invalid values mean the service is disabled, do nothing except for printing a message (logged in /var/log/system or systemd journal)
|
||||||
echo "novnc: not starting service ${service} with listen_port ${listen_port} and vnc_host_port ${vnc_host_port}"
|
echo "novnc: not starting service ${service} with listen_port ${listen_port} and vnc_host_port ${vnc_host_port}"
|
||||||
else
|
else
|
||||||
$SNAP/utils/launch.sh --listen $listen_port --vnc $vnc_host_port
|
# start (and fork with '&') the service using the specified listen port and VNC host:port
|
||||||
|
$SNAP/utils/launch.sh --listen $listen_port --vnc $vnc_host_port &
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue