diff options
author | Devaev Maxim <[email protected]> | 2018-06-30 05:55:02 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-06-30 06:04:43 +0300 |
commit | c0aee642467655952d701e37f284a7a589d638e2 (patch) | |
tree | 8099740f9a2c28b8354f3d2154fd857aa4d420a3 /os/platforms | |
parent | 0cfb3c5dbc91fa8f4c33114beb36c356965f497f (diff) |
reorganized project structure
Diffstat (limited to 'os/platforms')
-rw-r--r-- | os/platforms/v1/config.txt | 2 | ||||
-rw-r--r-- | os/platforms/v1/index.html | 50 | ||||
-rw-r--r-- | os/platforms/v1/kvmd.yaml | 63 | ||||
-rw-r--r-- | os/platforms/v1/nginx.conf | 59 | ||||
-rwxr-xr-x | os/platforms/v1/run.sh | 18 |
5 files changed, 192 insertions, 0 deletions
diff --git a/os/platforms/v1/config.txt b/os/platforms/v1/config.txt new file mode 100644 index 00000000..494deb58 --- /dev/null +++ b/os/platforms/v1/config.txt @@ -0,0 +1,2 @@ +gpu_mem=16 +dtparam=act_led_gpio=27 diff --git a/os/platforms/v1/index.html b/os/platforms/v1/index.html new file mode 100644 index 00000000..f08c0c12 --- /dev/null +++ b/os/platforms/v1/index.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8" /> +<title>π-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 = "/video/?action=stream&time=" + new Date().getTime(); + } +} + +ws = new WebSocket("ws://" + location.host + "/kvm/ws"); +ws.onmessage = (message) => onWsMessage(message); +ws.onerror = (error) => console.error(error); +ws.onclose = () => console.log("closed"); +</script> + +<body> +<div class="screen"> + <img src="/video/?action=stream" id="stream-image" class="screen-image" alt="" /> +</div> +</body> +</html> diff --git a/os/platforms/v1/kvmd.yaml b/os/platforms/v1/kvmd.yaml new file mode 100644 index 00000000..3dcc8d04 --- /dev/null +++ b/os/platforms/v1/kvmd.yaml @@ -0,0 +1,63 @@ +kvmd: + server: + host: localhost + port: 8081 + heartbeat: 3.0 + + keyboard: + pinout: + clock: 17 + data: 4 + pulse: 0.0002 + + atx: + leds: + pinout: + power: 16 + hdd: 12 + poll: 0.1 + + switches: + pinout: + power: 26 + reset: 20 + click_delay: 0.1 + long_click_delay: 5.5 + + video: + pinout: + cap: 21 + conv: 25 + sync_delay: 1.0 + + shutdown_delay: 10.0 + + cmd: + - "/usr/bin/mjpg_streamer" + - "-i" + - "input_uvc.so -d /dev/video0 -e 2 -y -n -r 720x576" + - "-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/os/platforms/v1/nginx.conf b/os/platforms/v1/nginx.conf new file mode 100644 index 00000000..a236b085 --- /dev/null +++ b/os/platforms/v1/nginx.conf @@ -0,0 +1,59 @@ +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 kvm_ws { + 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 /srv/http; + index index.html; + } + + location /kvm/ws { + rewrite /kvm/ws /ws break; + proxy_pass http://kvm_ws; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /video { + rewrite /video/?(.*) /$1 break; + proxy_pass http://mjpg_streamer; + } + } +} diff --git a/os/platforms/v1/run.sh b/os/platforms/v1/run.sh new file mode 100755 index 00000000..525d7756 --- /dev/null +++ b/os/platforms/v1/run.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e +set -x + +. ../functions.sh + + +cp config.txt "$FS/boot/config.txt" +pkg_install \ + kvmd \ + mjpg-streamer-pikvm \ + nginx + +cp index.html "$FS/srv/http/" +cp kvmd.yaml "$FS/etc/" +cp nginx.conf "$FS/etc/nginx/" +rpi systemctl enable kvmd +rpi systemctl enable nginx |