diff options
author | Devaev Maxim <[email protected]> | 2018-06-27 20:39:42 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-06-27 23:21:55 +0300 |
commit | 4804aa53b5f0954d02898ec44e595ea2e08ed9e6 (patch) | |
tree | 6a737a3e07df742f8e7b84ce8850d2a0f9d5563f | |
parent | 4c145f363f33222b948df981d8c936844f2b17dc (diff) |
os building environ
-rw-r--r-- | os/.gitignore | 1 | ||||
-rw-r--r-- | os/Makefile | 25 | ||||
-rw-r--r-- | os/kvm/config.txt | 2 | ||||
-rw-r--r-- | os/kvm/index.html | 50 | ||||
-rw-r--r-- | os/kvm/nginx.conf | 51 | ||||
-rwxr-xr-x | os/kvm/run.sh | 19 |
6 files changed, 148 insertions, 0 deletions
diff --git a/os/.gitignore b/os/.gitignore new file mode 100644 index 00000000..145ea57d --- /dev/null +++ b/os/.gitignore @@ -0,0 +1 @@ +/pi-builder/ diff --git a/os/Makefile b/os/Makefile new file mode 100644 index 00000000..ff43bdeb --- /dev/null +++ b/os/Makefile @@ -0,0 +1,25 @@ +all: + cat Makefile + +pi-builder: + git clone https://github.com/mdevaev/pi-builder --depth=1 + +pi-kvm: pi-builder + rm -rf pi-builder/builder/scripts/kvm + cp -a kvm pi-builder/builder/scripts + cd pi-builder && make _rpi \ + PLATFORM=rpi-2 \ + BUILDER=kvm-builder \ + STAGES="base keys watchdog ro kvm" + +format: pi-builder + cd pi-builder && make format + +install: pi-builder + cd pi-builder && make install + +clean: pi-builder + cd pi-builder && make clean + +clean-all: clean + rm -rf pi-builder diff --git a/os/kvm/config.txt b/os/kvm/config.txt new file mode 100644 index 00000000..494deb58 --- /dev/null +++ b/os/kvm/config.txt @@ -0,0 +1,2 @@ +gpu_mem=16 +dtparam=act_led_gpio=27 diff --git a/os/kvm/index.html b/os/kvm/index.html new file mode 100644 index 00000000..f08c0c12 --- /dev/null +++ b/os/kvm/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/kvm/nginx.conf b/os/kvm/nginx.conf new file mode 100644 index 00000000..b9b1631b --- /dev/null +++ b/os/kvm/nginx.conf @@ -0,0 +1,51 @@ +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; + + 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 /video { + rewrite /video/?(.*) /$1 break; + proxy_pass http://localhost:8082; + } + + location /kvm/ws { + rewrite /kvm/ws/?(.*) /ws break; + proxy_pass http://localhost:8081; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + } +} diff --git a/os/kvm/run.sh b/os/kvm/run.sh new file mode 100755 index 00000000..c2bb8b7d --- /dev/null +++ b/os/kvm/run.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e +set -x + +. ../functions.sh + + +cat config.txt > "$FS/boot/config.txt" +pkg_install \ + python \ + python-pyaml \ + python-aiohttp \ + python-raspberry-gpio \ + mjpg-streamer-pikvm \ + nginx + +cp index.html "$FS/srv/http/" +cp nginx.conf "$FS/etc/nginx/" +rpi systemctl enable nginx |