summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-07-08 01:31:11 +0000
committerDevaev Maxim <[email protected]>2018-07-08 01:31:11 +0000
commit09cccf0ffba8483923843352f855cf30ea68b550 (patch)
treed44c998a11acaba71ab6e4601ab414999962d11e /kvmd
parent8c9441e0a3e676b4f7e36b48da8589dd15b8d125 (diff)
moved main configs to kvmd package
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/Makefile5
-rw-r--r--kvmd/PKGBUILD3
-rw-r--r--kvmd/configs/kvmd/v1.yaml73
-rw-r--r--kvmd/configs/nginx/nginx.conf76
l---------kvmd/kvmd.yaml1
-rw-r--r--kvmd/web/index.html66
6 files changed, 218 insertions, 6 deletions
diff --git a/kvmd/Makefile b/kvmd/Makefile
index fffa74af..5a9737ef 100644
--- a/kvmd/Makefile
+++ b/kvmd/Makefile
@@ -11,7 +11,6 @@ release:
make push
make bump
make push
- make pypi
make clean
tox:
@@ -24,10 +23,6 @@ push:
git push
git push --tags
-pypi:
- python3 setup.py register
- python3 setup.py sdist upload
-
clean:
rm -rf build site dist pkg src *.egg-info kvmd-*.tar.gz
find -name __pycache__ | xargs rm -rf
diff --git a/kvmd/PKGBUILD b/kvmd/PKGBUILD
index 8d4775fa..3756da57 100644
--- a/kvmd/PKGBUILD
+++ b/kvmd/PKGBUILD
@@ -39,4 +39,7 @@ package() {
cd $srcdir/$pkgname-build
python setup.py install --root=$pkgdir
install -Dm644 kvmd.service "$pkgdir"/usr/lib/systemd/system/kvmd.service
+ mkdir -p "$pkgdir"/usr/share/kvmd
+ cp -r web "$pkgdir"/usr/share/kvmd
+ cp -r configs "$pkgdir"/usr/share/kvmd
}
diff --git a/kvmd/configs/kvmd/v1.yaml b/kvmd/configs/kvmd/v1.yaml
new file mode 100644
index 00000000..52890551
--- /dev/null
+++ b/kvmd/configs/kvmd/v1.yaml
@@ -0,0 +1,73 @@
+kvmd:
+ server:
+ host: localhost
+ port: 8081
+ heartbeat: 3.0
+
+ keyboard:
+ pinout:
+ clock: 17
+ data: 4
+
+ pulse: 0.0002
+
+ atx:
+ pinout:
+ power_led: 16
+ hdd_led: 12
+ power_switch: 26
+ reset_switch: 20
+
+ click_delay: 0.1
+ long_click_delay: 5.5
+
+ state_poll: 0.1
+
+ msd:
+ device: "/dev/kvmd-msd"
+ init_delay: 2.0
+ write_meta: true
+ chunk_size: 8192
+
+ streamer:
+ pinout:
+ cap: 21
+ conv: 25
+
+ sync_delay: 1.0
+ init_delay: 1.0
+ shutdown_delay: 10.0
+
+ size:
+ width: 720
+ height: 576
+
+ cmd:
+ - "/usr/bin/mjpg_streamer"
+ - "-i"
+ - "input_uvc.so -d /dev/kvmd-streamer -e 2 -y -n -r {width}x{height}"
+ - "-o"
+ - "output_http.so -l localhost -p 8082"
+
+logging:
+ version: 1
+ disable_existing_loggers: false
+
+ formatters:
+ console:
+ (): logging.Formatter
+ style: "{"
+ datefmt: "%H:%M:%S"
+ format: "[{asctime}] {name:20.20} {levelname:>7} --- {message}"
+
+ handlers:
+ console:
+ level: DEBUG
+ class: logging.StreamHandler
+ stream: ext://sys.stdout
+ formatter: console
+
+ root:
+ level: INFO
+ handlers:
+ - console
diff --git a/kvmd/configs/nginx/nginx.conf b/kvmd/configs/nginx/nginx.conf
new file mode 100644
index 00000000..05e07047
--- /dev/null
+++ b/kvmd/configs/nginx/nginx.conf
@@ -0,0 +1,76 @@
+user http;
+worker_processes 4;
+
+# error_log /tmp/nginx.error.log;
+error_log /dev/null crit;
+
+events {
+ worker_connections 64;
+ use epoll;
+}
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+ charset utf-8;
+
+ sendfile on;
+ keepalive_timeout 10;
+ # gzip on;
+
+ upstream kvmd {
+ server localhost:8081 fail_timeout=0s max_fails=0;
+ }
+
+ upstream mjpg_streamer {
+ server localhost:8082 fail_timeout=0s max_fails=0;
+ }
+
+ server {
+ # access_log /tmp/nginx.access.log;
+ access_log off;
+
+ listen 80;
+ server_name localhost;
+
+ client_body_temp_path /tmp/nginx.client_body_temp;
+ fastcgi_temp_path /tmp/nginx.fastcgi_temp;
+ proxy_temp_path /tmp/nginx.proxy_temp;
+ scgi_temp_path /tmp/nginx.scgi_temp;
+ uwsgi_temp_path /tmp/nginx.uwsgi_temp;
+
+ location / {
+ root /usr/share/kvmd/web;
+ index index.html;
+ }
+
+ location /kvmd/ws {
+ rewrite /kvmd/ws /ws break;
+ proxy_pass http://kvmd;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_connect_timeout 7d;
+ proxy_send_timeout 7d;
+ proxy_read_timeout 7d;
+ }
+
+ location /kvmd/msd/write {
+ rewrite /kvmd/msd/write /msd/write break;
+ proxy_pass http://kvmd;
+ limit_rate 6250k;
+ limit_rate_after 50k;
+ client_max_body_size 0;
+ proxy_request_buffering off;
+ }
+
+ location /kvmd {
+ rewrite /kvmd/?(.*) /$1 break;
+ proxy_pass http://kvmd;
+ }
+
+ location /streamer {
+ rewrite /streamer/?(.*) /$1 break;
+ proxy_pass http://mjpg_streamer;
+ }
+ }
+}
diff --git a/kvmd/kvmd.yaml b/kvmd/kvmd.yaml
deleted file mode 120000
index 19ece673..00000000
--- a/kvmd/kvmd.yaml
+++ /dev/null
@@ -1 +0,0 @@
-../os/platforms/v1/kvmd.yaml \ No newline at end of file
diff --git a/kvmd/web/index.html b/kvmd/web/index.html
new file mode 100644
index 00000000..87281e88
--- /dev/null
+++ b/kvmd/web/index.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>&pi;-kvm</title>
+<style>
+body {
+ text-align: center;
+}
+.screen, .screen * {
+ box-sizing: border-box;
+}
+.screen {
+ display: inline-block;
+ background-color: #e5e5f5;
+ font-family: Arial, Tahoma, Verdana, sans;
+ font-size: 10pt;
+ text-align: center;
+ padding: 1em;
+ text-align: left;
+}
+.screen .screen-image {
+ width: 720px;
+ height: 576px;
+ border: 1px solid #77d;
+ display: inline-block;
+}
+</style>
+</head>
+
+<script>
+function onWsMessage(message) {
+ console.log(message.data);
+ if (message.data == "EVENT mjpg_streamer started") {
+ document.getElementById("stream-image").src = "/streamer/?action=stream&time=" + new Date().getTime();
+ }
+}
+
+function onKeyPress(event) {
+ console.log("key pressed: ", event);
+ let e = event || window.event || arguments.callee.caller.arguments[0];
+// ws.Send("EVENT press " + e.keyCode);
+}
+
+function onKeyRelease(event) {
+ console.log("key released: ", event);
+ let e = event || window.event || arguments.callee.caller.arguments[0];
+// ws.Send("EVENT press " + e.keyCode);
+}
+
+ws = new WebSocket("ws://" + location.host + "/kvmd/ws");
+ws.onmessage = (message) => onWsMessage(message);
+ws.onerror = (error) => console.error(error);
+ws.onclose = () => console.log("closed");
+
+//https://www.codeday.top/2017/05/03/24906.html
+document.onkeydown = onKeyPress;
+document.onkeyup = onKeyRelease;
+</script>
+
+<body>
+<div class="screen">
+ <img src="/streamer/?action=stream" id="stream-image" class="screen-image" alt="" />
+</div>
+</body>
+</html>