tk83
May 1, 2019, 5:42am
1
I’ve created a Snap package for noVNC, which is a web interface and client for VNC. So for example if your VNC server runs on port 5901 on your machine you could run an instance of novnc that listens on port 6081 and connects to that VNC server on port 5901:
/snap/bin/novnc --vnc localhost:5901 --listen 6081
The issue is that I can’t see any good way to make this a ‘service’. I’d like something like systemd’s service templates (https://fedoramagazine.org/systemd-template-unit-files/ ) so that the user can run something like:
systemctl start novnc@localhost5901
But I don’t see a way to do this using Snap?
tk83
May 1, 2019, 5:44am
2
The Snap (including my attempt at creating services, which is just hard coding the most commonly-used port combinations):
name: novnc
base: core18 # the base snap is the execution environment for this snap
version: '1.1.0'
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: https://github.com/novnc/noVNC.git #https://github.com/novnc/noVNC/archive/v$SNAPCRAFT_PROJECT_VERSION.tar.gz
plugin: dump
stage-packages:
- websockify
apps:
novnc:
command: utils/launch.sh
plugs: [network, network-bind]
n5900:
command: utils/launch.sh --vnc localhost:5900 --listen 6080
daemon: simple
plugs: [network, network-bind]
n5901:
command: utils/launch.sh --vnc localhost:5901 --listen 6081
daemon: simple
plugs: [network, network-bind]
n5902:
command: utils/launch.sh --vnc localhost:5902 --listen 6082
daemon: simple
plugs: [network, network-bind]
n5903:
command: utils/launch.sh --vnc localhost:5903 --listen 6083
daemon: simple
plugs: [network, network-bind]
n5904:
command: utils/launch.sh --vnc localhost:5904 --listen 6084
daemon: simple
plugs: [network, network-bind]
n5905:
command: utils/launch.sh --vnc localhost:5905 --listen 6085
daemon: simple
plugs: [network, network-bind]
Hello, to configure a snap service you’ll have to use the snap configuration options and configure hook, check out https://docs.snapcraft.io/configuration-in-snaps/510 and https://docs.snapcraft.io/supported-snap-hooks/3795#heading--the-configure-hook for more details.
You can check out the uhttpd snap for an implementation:
committed 08:27AM - 21 Apr 19 UTC
This patch implements the necessary details to package uhttpd as a snap
that can be installed and run on numerous supported GNU/Linux
distributions...