完善虚拟机连接

This commit is contained in:
2024-07-31 20:45:38 +08:00
parent 9b51368f9c
commit b491db6b60
213 changed files with 43580 additions and 6 deletions

3
VM/novnc/snap/hooks/configure vendored Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/sh -e
snapctl restart novnc.novncsvc

View File

@@ -0,0 +1,29 @@
#!/bin/bash
# `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
# check whether those values are valid
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 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}"
else
# start (and fork with '&') the service using the specified listen port and VNC host:port
$SNAP/novnc_proxy --listen $listen_port --vnc $vnc_host_port &
fi
done

View File

@@ -0,0 +1,61 @@
name: novnc
base: core22 # the base snap is the execution environment for this snap
version: git
summary: Open Source VNC client using HTML5 (WebSockets, Canvas)
description: |
Open Source VNC client using HTML5 (WebSockets, Canvas).
noVNC is both a VNC client JavaScript library as well as an
application built on top of that library. noVNC runs well in any
modern browser including mobile browsers (iOS and Android).
grade: stable
confinement: strict
parts:
novnc:
source: .
plugin: dump
organize:
utils/novnc_proxy: /
stage:
- vnc.html
- app
- core/**/*.js
- vendor/**/*.js
- novnc_proxy
novnc-deps:
plugin: nil
stage-packages:
- bash
svc-script:
source: snap/local
plugin: dump
stage:
- svc_wrapper.sh
svc-script-deps:
plugin: nil
stage-packages:
- bash
- jq
websockify:
source: https://github.com/novnc/websockify/archive/v0.12.0.tar.gz
plugin: python
stage-packages:
- python3-numpy
hooks:
configure:
plugs: [network, network-bind]
apps:
novnc:
command: ./novnc_proxy
plugs: [network, network-bind]
novncsvc:
command: ./svc_wrapper.sh
daemon: forking
plugs: [network, network-bind]