mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
reorganized project structure
This commit is contained in:
2
os/platforms/v1/config.txt
Normal file
2
os/platforms/v1/config.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
gpu_mem=16
|
||||
dtparam=act_led_gpio=27
|
||||
50
os/platforms/v1/index.html
Normal file
50
os/platforms/v1/index.html
Normal file
@@ -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>
|
||||
63
os/platforms/v1/kvmd.yaml
Normal file
63
os/platforms/v1/kvmd.yaml
Normal file
@@ -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
|
||||
59
os/platforms/v1/nginx.conf
Normal file
59
os/platforms/v1/nginx.conf
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
os/platforms/v1/run.sh
Executable file
18
os/platforms/v1/run.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user