diff options
author | Devaev Maxim <[email protected]> | 2019-05-09 20:52:15 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-05-09 20:52:15 +0300 |
commit | def5346b4bb0572f3d35df23f988e79a925dfcd8 (patch) | |
tree | 40e69a45cacc3f4678df4a22c9020295f24bc8bf | |
parent | a972e35f7af8ade0e827a30a7ff84404c0e1a2d4 (diff) |
using unix sockets
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | configs/kvmd/main/v1-hdmi.yaml | 16 | ||||
-rw-r--r-- | configs/kvmd/main/v1-vga.yaml | 16 | ||||
-rw-r--r-- | configs/nginx/nginx.conf | 6 | ||||
-rw-r--r-- | kvmd.install | 6 | ||||
-rw-r--r-- | testenv/Dockerfile | 2 | ||||
-rw-r--r-- | testenv/main.yaml | 16 | ||||
-rw-r--r-- | testenv/run/.gitignore | 0 |
9 files changed, 43 insertions, 34 deletions
@@ -7,6 +7,8 @@ /testenv/.tox/ /testenv/.mypy_cache/ /testenv/.coverage +/testenv/run/*.sock +/testenv/run/*.pid /v*.tar.gz /*.pkg.tar.xz /*.egg-info @@ -50,6 +50,7 @@ tox: testenv run: testenv sudo modprobe loop - docker run --rm --name kvmd \ + --volume `pwd`/testenv/run:/run:rw \ --volume `pwd`/testenv:/testenv:ro \ --volume `pwd`/kvmd:/kvmd:ro \ --volume `pwd`/web:/usr/share/kvmd/web:ro \ @@ -58,8 +59,6 @@ run: testenv --device $(TESTENV_LOOP):/dev/kvmd-msd \ --device $(TESTENV_VIDEO):$(TESTENV_VIDEO) \ --publish 8080:80/tcp \ - --publish 8081:8081/tcp \ - --publish 8082:8082/tcp \ -it $(TESTENV_IMAGE) /bin/bash -c " \ (socat PTY,link=$(TESTENV_HID) PTY,link=/dev/ttyS11 &) \ && cp -r /usr/share/kvmd/configs.default/nginx/* /etc/kvmd/nginx \ @@ -76,7 +75,8 @@ run: testenv run-ipmi: testenv - - docker run --rm --name kvmd-ipmi --link kvmd:kvmd \ + - docker run --rm --name kvmd-ipmi \ + --volume `pwd`/testenv/run:/run:rw \ --volume `pwd`/testenv:/testenv:ro \ --volume `pwd`/kvmd:/kvmd:ro \ --volume `pwd`/configs:/usr/share/kvmd/configs.default:ro \ @@ -117,8 +117,8 @@ push: clean: - rm -rf build site dist pkg src v*.tar.gz *.pkg.tar.xz *.egg-info kvmd-*.tar.gz - find kvmd tests -name __pycache__ | xargs rm -rf + rm -rf testenv/run/*.{pid,sock} build site dist pkg src v*.tar.gz *.pkg.tar.xz *.egg-info kvmd-*.tar.gz + find kvmd testenv/tests -name __pycache__ | xargs rm -rf make -C hid clean @@ -126,3 +126,6 @@ clean-all: testenv clean - docker run --rm \ --volume `pwd`:/src \ -it $(TESTENV_IMAGE) bash -c "cd src && rm -rf testenv/{.tox,.mypy_cache,.coverage}" + + +.PHONY: testenv diff --git a/configs/kvmd/main/v1-hdmi.yaml b/configs/kvmd/main/v1-hdmi.yaml index 7b886167..64dfbffb 100644 --- a/configs/kvmd/main/v1-hdmi.yaml +++ b/configs/kvmd/main/v1-hdmi.yaml @@ -5,8 +5,9 @@ logging: !include logging.yaml kvmd: server: - host: 127.0.0.1 - port: 8081 + unix: /run/kvmd.sock + unix_rm: true + unix_mode: 0660 auth: !include auth.yaml @@ -26,8 +27,7 @@ kvmd: device: /dev/kvmd-msd streamer: - host: 127.0.0.1 - port: 8082 + unix: /run/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -38,11 +38,11 @@ kvmd: - "--workers=3" - "--quality={quality}" - "--desired-fps={desired_fps}" - - "--host={host}" - - "--port={port}" - "--drop-same-frames=30" + - "--unix={unix}" + - "--unix-rm" + - "--unix-mode=0660" ipmi: kvmd: - host: 127.0.0.1 - port: 8081 + unix: /run/kvmd.sock diff --git a/configs/kvmd/main/v1-vga.yaml b/configs/kvmd/main/v1-vga.yaml index 4a9baddc..0ace92e0 100644 --- a/configs/kvmd/main/v1-vga.yaml +++ b/configs/kvmd/main/v1-vga.yaml @@ -5,8 +5,9 @@ logging: !include logging.yaml kvmd: server: - host: 127.0.0.1 - port: 8081 + unix: /run/kvmd.sock + unix_rm: true + unix_mode: 0660 auth: !include auth.yaml @@ -29,8 +30,7 @@ kvmd: cap_pin: 17 conv_pin: 18 init_restart_after: 1 - host: 127.0.0.1 - port: 8082 + unix: /run/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -43,10 +43,10 @@ kvmd: - "--height=576" - "--fake-width=800" - "--fake-height=600" - - "--host={host}" - - "--port={port}" + - "--unix={unix}" + - "--unix-rm" + - "--unix-mode=0660" ipmi: kvmd: - listen: 127.0.0.1 - port: 8081 + unix: /run/kvmd.sock diff --git a/configs/nginx/nginx.conf b/configs/nginx/nginx.conf index 444d5aab..7246f1e3 100644 --- a/configs/nginx/nginx.conf +++ b/configs/nginx/nginx.conf @@ -1,4 +1,4 @@ -user http; +user kvmd-nginx; worker_processes 4; # error_log /tmp/kvmd-nginx.error.log; @@ -35,11 +35,11 @@ http { uwsgi_temp_path /tmp/kvmd-nginx.uwsgi_temp; upstream kvmd { - server 127.0.0.1:8081 fail_timeout=0s max_fails=0; + server unix:/run/kvmd.sock fail_timeout=0s max_fails=0; } upstream ustreamer { - server 127.0.0.1:8082 fail_timeout=0s max_fails=0; + server unix:/run/ustreamer.sock fail_timeout=0s max_fails=0; } include /usr/share/kvmd/extras/*/nginx.ctx-http.conf; diff --git a/kvmd.install b/kvmd.install index 647184d4..3e504d48 100644 --- a/kvmd.install +++ b/kvmd.install @@ -6,14 +6,16 @@ post_install() { } post_upgrade() { - echo "==> Configuring KVMD user and groups ..." + echo "==> Configuring KVMD users and groups ..." id kvmd &>/dev/null || useradd -r -c "The main Pi-KVM daemon" -s /sbin/nologin kvmd - for group in gpio uucp systemd-journal; do (groupmems -l -g "$group" | grep kvmd >/dev/null) || groupmems -g "$group" -a kvmd done + id kvmd-nginx &>/dev/null || useradd -r -c "Pi-KVM Nginx Server" -s /sbin/nologin kvmd-nginx + (groupmems -l -g kvmd | grep kvmd-nginx >/dev/null) || groupmems -g kvmd -a kvmd-nginx + chown root:kvmd \ /usr/share/kvmd/configs.default/kvmd/*passwd \ /etc/kvmd/*passwd diff --git a/testenv/Dockerfile b/testenv/Dockerfile index 4d228f51..99dd8992 100644 --- a/testenv/Dockerfile +++ b/testenv/Dockerfile @@ -27,6 +27,7 @@ RUN pkg-install \ python-systemd \ python-dbus \ python-mako \ + libevent-patched \ nginx-mainline \ ustreamer \ socat \ @@ -36,6 +37,7 @@ RUN pkg-install \ COPY testenv/requirements.txt requirements.txt RUN pip install -r requirements.txt +RUN useradd -r -c "Pi-KVM Nginx Server" -s /sbin/nologin kvmd-nginx RUN mkdir -p /etc/kvmd/nginx CMD /bin/bash diff --git a/testenv/main.yaml b/testenv/main.yaml index c9774f8d..5647d62e 100644 --- a/testenv/main.yaml +++ b/testenv/main.yaml @@ -1,7 +1,8 @@ kvmd: server: - host: 0.0.0.0 - port: 8081 + unix: /run/kvmd.sock + unix_rm: true + unix_mode: 0666 auth: !include auth.yaml @@ -25,8 +26,7 @@ kvmd: cap_pin: 17 conv_pin: 18 init_restart_after: 1 - host: 127.0.0.1 - port: 8082 + unix: /run/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -34,12 +34,12 @@ kvmd: - "--desired-fps={desired_fps}" - "--width=800" - "--height=600" - - "--host=0.0.0.0" - - "--port={port}" + - "--unix={unix}" + - "--unix-rm" + - "--unix-mode=0666" ipmi: kvmd: - host: kvmd - port: 8081 + unix: /run/kvmd.sock logging: !include logging.yaml diff --git a/testenv/run/.gitignore b/testenv/run/.gitignore new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/testenv/run/.gitignore |