修复 HTTP H.264 模式

其他修改
This commit is contained in:
mofeng-git 2025-02-01 08:31:27 +00:00
parent 7b3335ea94
commit 9da06d3f58
12 changed files with 264 additions and 145 deletions

View File

@ -280,37 +280,21 @@ clean-all: testenv clean
.PHONY: testenv .PHONY: testenv
run-stage-0: run-stage-0:
$(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd-stage-0 \ $(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd-stage-0 -t silentwind0/kvmd-stage-0 \
--allow security.insecure --progress plain \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-f build/Dockerfile-stage-0 . \
--push
$(DOCKER) buildx build -t silentwind0/kvmd-stage-0 \
--allow security.insecure --progress plain \ --allow security.insecure --progress plain \
--platform linux/amd64,linux/arm64,linux/arm/v7 \ --platform linux/amd64,linux/arm64,linux/arm/v7 \
-f build/Dockerfile-stage-0 . \ -f build/Dockerfile-stage-0 . \
--push --push
run-build-dev: run-build-dev:
$(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd:dev \ $(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd:dev -t silentwind0/kvmd:dev \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg CACHEBUST=$(date +%s) \
-f build/Dockerfile . \
--push
$(DOCKER) buildx build -t silentwind0/kvmd:dev \
--platform linux/amd64,linux/arm64,linux/arm/v7 \ --platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg CACHEBUST=$(date +%s) \ --build-arg CACHEBUST=$(date +%s) \
-f build/Dockerfile . \ -f build/Dockerfile . \
--push --push
run-build-release: run-build-release:
$(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd \ $(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd -t silentwind0/kvmd:dev \
--progress plain \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg CACHEBUST=$(date +%s) \
-f build/Dockerfile . \
--push
$(DOCKER) buildx build -t silentwind0/kvmd \
--progress plain \ --progress plain \
--platform linux/amd64,linux/arm64,linux/arm/v7 \ --platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg CACHEBUST=$(date +%s) \ --build-arg CACHEBUST=$(date +%s) \

View File

@ -1,6 +1,6 @@
FROM silentwind0/kvmd-stage-0 AS builder FROM registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd-stage-0 AS builder
FROM python:3.12.0rc2-slim-bookworm FROM python:3.11.11-slim-bookworm
LABEL maintainer="mofeng654321@hotmail.com" LABEL maintainer="mofeng654321@hotmail.com"
@ -12,29 +12,58 @@ COPY --from=builder /usr/lib/janus/transports/* /usr/lib/janus/transports/
ARG TARGETARCH ARG TARGETARCH
ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE=1 \
ENV PYTHONUNBUFFERED=1 PYTHONUNBUFFERED=1 \
ENV TZ=Asia/Shanghai TZ=Asia/Shanghai
RUN cp /tmp/lib/* /lib/*-linux-*/ \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check /tmp/wheel/*.whl \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check pyfatfs \
&& rm -rf /tmp/lib /tmp/wheel
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update \ && apt-get update \
&& apt-get install -y --no-install-recommends libxkbcommon-x11-0 nginx tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim iptables sudo curl kmod \ && apt-get install -y --no-install-recommends \
libmicrohttpd12 libjansson4 libssl3 libsofia-sip-ua0 libglib2.0-0 libopus0 libogg0 libcurl4 libconfig9 libusrsctp2 libwebsockets17 libnss3 libasound2 nano \ libxkbcommon-x11-0 \
&& rm -rf /var/lib/apt/lists/* nginx \
tesseract-ocr \
RUN if [ ${TARGETARCH} = arm ]; then ARCH=armhf; elif [ ${TARGETARCH} = arm64 ]; then ARCH=aarch64; elif [ ${TARGETARCH} = amd64 ]; then ARCH=x86_64; fi \ tesseract-ocr-eng \
tesseract-ocr-chi-sim \
iptables \
sudo \
curl \
kmod \
libmicrohttpd12 \
libjansson4 \
libssl3 \
libsofia-sip-ua0 \
libglib2.0-0 \
libopus0 \
libogg0 \
libcurl4 \
libconfig9 \
libusrsctp2 \
libwebsockets17 \
libnss3 \
libasound2 \
nano \
&& cp /tmp/lib/* /lib/*-linux-*/ \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check /tmp/wheel/*.whl \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check pyfatfs \
&& if [ ${TARGETARCH} = arm ]; then ARCH=armhf; \
elif [ ${TARGETARCH} = arm64 ]; then ARCH=aarch64; \
elif [ ${TARGETARCH} = amd64 ]; then ARCH=x86_64; \
fi \
&& curl https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.$ARCH -L -o /usr/local/bin/ttyd \ && curl https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.$ARCH -L -o /usr/local/bin/ttyd \
&& chmod +x /usr/local/bin/ttyd \ && chmod +x /usr/local/bin/ttyd \
&& adduser kvmd --gecos "" --disabled-password \ && adduser kvmd --gecos "" --disabled-password \
&& ln -sf /usr/share/tesseract-ocr/*/tessdata /usr/share/tessdata \ && ln -sf /usr/share/tesseract-ocr/*/tessdata /usr/share/tessdata \
&& mkdir -p /etc/kvmd_backup/override.d /var/lib/kvmd/msd/images /var/lib/kvmd/msd/meta /var/lib/kvmd/pst/data /var/lib/kvmd/msd/NormalFiles /opt/vc/bin /run/kvmd /tmp/kvmd-nginx \ && mkdir -p /etc/kvmd_backup/override.d \
&& touch /run/kvmd/ustreamer.sock /var/lib/kvmd/msd/images \
/var/lib/kvmd/msd/meta \
/var/lib/kvmd/pst/data \
/var/lib/kvmd/msd/NormalFiles \
/opt/vc/bin \
/run/kvmd \
/tmp/kvmd-nginx \
&& touch /run/kvmd/ustreamer.sock \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/lib /tmp/wheel
COPY testenv/fakes/vcgencmd scripts/kvmd* /usr/bin/ COPY testenv/fakes/vcgencmd scripts/kvmd* /usr/bin/
COPY extras/ /usr/share/kvmd/extras/ COPY extras/ /usr/share/kvmd/extras/

View File

@ -1,70 +1,118 @@
# syntax = docker/dockerfile:experimental # syntax = docker/dockerfile:experimental
FROM python:3.12.0rc2-slim-bookworm AS builder FROM debian:bookworm-slim AS builder
ARG TARGETARCH ARG TARGETARCH
# 设置环境变量
ENV DEBIAN_FRONTEND=noninteractive \
PIP_NO_CACHE_DIR=1 \
RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"
# 更新源并安装依赖
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update \ && apt-get update \
&& apt-get install -y --no-install-recommends build-essential libssl-dev libffi-dev python3-dev libevent-dev libjpeg-dev \ && apt-get install -y --no-install-recommends \
libbsd-dev libudev-dev git pkg-config wget curl libmicrohttpd-dev libjansson-dev libssl-dev libsofia-sip-ua-dev libglib2.0-dev \ python3-full \
libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev libconfig-dev libopus-dev libtool automake autoconf meson cmake \ python3-pip \
libx264-dev libyuv-dev libasound2-dev libspeex-dev libspeexdsp-dev libopus-dev \ python3-dev \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
libevent-dev \
libjpeg-dev \
libbsd-dev \
libudev-dev \
git \
pkg-config \
wget \
curl \
libmicrohttpd-dev \
libjansson-dev \
libsofia-sip-ua-dev \
libglib2.0-dev \
libopus-dev \
libogg-dev \
libcurl4-openssl-dev \
liblua5.3-dev \
libconfig-dev \
libtool \
automake \
autoconf \
meson \
cmake \
libx264-dev \
libyuv-dev \
libasound2-dev \
libspeex-dev \
libspeexdsp-dev \
libusb-1.0-0-dev \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY build/cargo_config /tmp/config COPY build/cargo_config /tmp/config
# 配置 pip 源并安装 Python 依赖
RUN --security=insecure pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \ RUN --security=insecure pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& if [ ${TARGETARCH} = arm ]; then \ && if [ ${TARGETARCH} = arm ]; then \
mkdir -p /root/.cargo \ mkdir -p /root/.cargo \
&& chmod 777 /root/.cargo && mount -t tmpfs none /root/.cargo \ && chmod 777 /root/.cargo && mount -t tmpfs none /root/.cargo \
&& export RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup" \
#&& export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup" \
&& wget https://sh.rustup.rs -O /root/rustup-init.sh \ && wget https://sh.rustup.rs -O /root/rustup-init.sh \
&& sh /root/rustup-init.sh -y \ && sh /root/rustup-init.sh -y \
&& export PATH=$PATH:/root/.cargo/bin \ && export PATH=$PATH:/root/.cargo/bin \
&& cp /tmp/config /root/.cargo/config.toml; \ && cp /tmp/config /root/.cargo/config.toml; \
fi \ fi \
&& pip wheel --wheel-dir=/tmp/wheel/ cryptography && pip install --root-user-action=ignore --disable-pip-version-check --upgrade --break-system-packages build setuptools pip \
&& pip wheel --wheel-dir=/tmp/wheel/ cryptography \
RUN pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check build \ && pip wheel --wheel-dir=/tmp/wheel/ \
&& pip wheel --wheel-dir=/tmp/wheel/ aiofiles aiohttp appdirs asn1crypto async_lru async-timeout bottle cffi chardet click colorama \ aiofiles aiohttp appdirs asn1crypto async_lru async-timeout bottle cffi \
dbus_next gpiod hidapi idna mako marshmallow more-itertools multidict netifaces packaging passlib pillow ply psutil pycparser \ chardet click colorama dbus_next gpiod hidapi idna mako marshmallow \
pyelftools pyghmi pygments pyparsing pyotp qrcode requests semantic-version setproctitle setuptools six spidev \ more-itertools multidict netifaces packaging passlib pillow ply psutil \
tabulate urllib3 wrapt xlib yarl pyserial pyyaml zstandard supervisor pycparser pyelftools pyghmi pygments pyparsing pyotp qrcode requests \
semantic-version setproctitle six spidev tabulate urllib3 wrapt xlib \
yarl pyserial pyyaml zstandard supervisor
# 编译安装 libnice、libsrtp、libwebsockets 和 janus-gateway
RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libnice \ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libnice \
&& cd /tmp/libnice \ && cd /tmp/libnice \
&& meson --prefix=/usr build && ninja -C build && ninja -C build install && meson --prefix=/usr build && ninja -C build && ninja -C build install \
&& rm -rf /tmp/libnice \
RUN curl https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz -L -o /tmp/libsrtp-2.2.0.tar.gz \ && curl https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz -L -o /tmp/libsrtp-2.2.0.tar.gz \
&& cd /tmp \ && cd /tmp \
&& tar xfv libsrtp-2.2.0.tar.gz \ && tar xf libsrtp-2.2.0.tar.gz \
&& cd libsrtp-2.2.0 \ && cd libsrtp-2.2.0 \
&& ./configure --prefix=/usr --enable-openssl \ && ./configure --prefix=/usr --enable-openssl \
&& make shared_library && make install && make shared_library && make install \
&& cd /tmp \
RUN git clone --depth=1 https://libwebsockets.org/repo/libwebsockets /tmp/libwebsockets \ && rm -rf /tmp/libsrtp* \
&& git clone --depth=1 https://libwebsockets.org/repo/libwebsockets /tmp/libwebsockets \
&& cd /tmp/libwebsockets \ && cd /tmp/libwebsockets \
&& mkdir build && cd build \ && mkdir build && cd build \
&& cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. \ && cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. \
&& make && make install && make && make install \
&& cd /tmp \
RUN git clone --depth=1 https://github.com/meetecho/janus-gateway.git /tmp/janus-gateway \ && rm -rf /tmp/libwebsockets \
&& git clone --depth=1 https://github.com/meetecho/janus-gateway.git /tmp/janus-gateway \
&& cd /tmp/janus-gateway \ && cd /tmp/janus-gateway \
&& sh autogen.sh \ && sh autogen.sh \
&& ./configure --enable-static --enable-websockets --enable-plugin-audiobridge \ && ./configure --enable-static --enable-websockets --enable-plugin-audiobridge \
--disable-data-channels --disable-rabbitmq --disable-mqtt --disable-all-plugins --disable-all-loggers \ --disable-data-channels --disable-rabbitmq --disable-mqtt --disable-all-plugins \
--prefix=/usr \ --disable-all-loggers --prefix=/usr \
&& make && make install && make && make install \
&& cd /tmp \
&& rm -rf /tmp/janus-gateway
# 编译 ustreamer
RUN sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \ RUN sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \
&& git clone --depth=1 https://github.com/mofeng-git/ustreamer /tmp/ustreamer \ && git clone --depth=1 https://github.com/mofeng-git/ustreamer /tmp/ustreamer \
&& sed -i '68s/-Wl,-Bstatic//' /tmp/ustreamer/src/Makefile \
&& make -j WITH_PYTHON=1 WITH_JANUS=1 WITH_LIBX264=1 -C /tmp/ustreamer \ && make -j WITH_PYTHON=1 WITH_JANUS=1 WITH_LIBX264=1 -C /tmp/ustreamer \
&& /tmp/ustreamer/ustreamer -v && /tmp/ustreamer/ustreamer -v \
&& cp /tmp/ustreamer/python/dist/*.whl /tmp/wheel/
# 复制必要的库文件
RUN mkdir /tmp/lib \ RUN mkdir /tmp/lib \
&& cd /lib/*-linux-*/ \ && cd /lib/*-linux-*/ \
&& cp libevent_core-*.so.7 libbsd.so.0 libevent_pthreads-*.so.7 libspeexdsp.so.1 libevent-*.so.7 libjpeg.so.62 libx264.so.164 libyuv.so.0 \ && cp libevent_core-*.so.7 libbsd.so.0 libevent_pthreads-*.so.7 libspeexdsp.so.1 \
libnice.so.10 /usr/lib/libsrtp2.so.1 /usr/lib/libwebsockets.so.19 \ libevent-*.so.7 libjpeg.so.62 libx264.so.164 libyuv.so.0 libnice.so.10 \
/tmp/lib/ \ /usr/lib/libsrtp2.so.1 /usr/lib/libwebsockets.so.19 \
&& cp /tmp/ustreamer/python/dist/*.whl /tmp/wheel/ /tmp/lib/

View File

@ -1,41 +1,74 @@
#!/bin/bash #!/bin/bash
# 定义颜色代码
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[0;33m' YELLOW='\033[0;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
NC='\033[0m' NC='\033[0m'
echo -e "${GREEN}One-KVM pre-starting...${NC}" # 输出日志的函数
log_info() {
echo -e "${GREEN}[INFO] $1${NC}"
}
log_warn() {
echo -e "${YELLOW}[WARN] $1${NC}"
}
log_error() {
echo -e "${RED}[ERROR] $1${NC}"
}
# 初始化检查
log_info "One-KVM 正在启动..."
# 首次初始化配置
if [ ! -f /etc/kvmd/.init_flag ]; then if [ ! -f /etc/kvmd/.init_flag ]; then
echo -e "${GREEN}One-KVM is initializing first...${NC}" \ log_info "首次初始化配置..."
&& mkdir -p /etc/kvmd/ \
&& mv /etc/kvmd_backup/* /etc/kvmd/ \
&& touch /etc/kvmd/.docker_flag \
&& sed -i 's/localhost.localdomain/docker/g' /etc/kvmd/meta.yaml \
&& sed -i 's/localhost/localhost:4430/g' /etc/kvmd/kvm_input.sh \
&& /usr/share/kvmd/kvmd-gencert --do-the-thing \
&& /usr/share/kvmd/kvmd-gencert --do-the-thing --vnc \
|| echo -e "${RED}One-KVM config moving and self-signed SSL certificates init failed.${NC}"
if [ "$NOSSL" == 1 ]; then # 创建必要目录并移动配置文件
echo -e "${GREEN}One-KVM self-signed SSL is disabled.${NC}" \ if mkdir -p /etc/kvmd/ && \
&& python -m kvmd.apps.ngxmkconf /etc/kvmd/nginx/nginx.conf.mako /etc/kvmd/nginx/nginx.conf -o nginx/https/enabled=false \ mv /etc/kvmd_backup/* /etc/kvmd/ && \
|| echo -e "${RED}One-KVM nginx config init failed.${NC}" touch /etc/kvmd/.docker_flag && \
sed -i 's/localhost.localdomain/docker/g' /etc/kvmd/meta.yaml && \
sed -i 's/localhost/localhost:4430/g' /etc/kvmd/kvm_input.sh; then
log_info "基础配置完成"
else else
python -m kvmd.apps.ngxmkconf /etc/kvmd/nginx/nginx.conf.mako /etc/kvmd/nginx/nginx.conf \ log_error "基础配置失败"
|| echo -e "${RED}One-KVM nginx config init failed.${NC}" exit 1
fi fi
# SSL证书配置
if ! /usr/share/kvmd/kvmd-gencert --do-the-thing && \
! /usr/share/kvmd/kvmd-gencert --do-the-thing --vnc; then
log_error "SSL 证书生成失败"
exit 1
fi
# SSL开关配置
if [ "$NOSSL" == 1 ]; then
log_info "已禁用SSL"
if ! python -m kvmd.apps.ngxmkconf /etc/kvmd/nginx/nginx.conf.mako /etc/kvmd/nginx/nginx.conf -o nginx/https/enabled=false; then
log_error "Nginx 配置失败"
exit 1
fi
else
if ! python -m kvmd.apps.ngxmkconf /etc/kvmd/nginx/nginx.conf.mako /etc/kvmd/nginx/nginx.conf; then
log_error "Nginx 配置失败"
exit 1
fi
fi
# 认证配置
if [ "$NOAUTH" == "1" ]; then if [ "$NOAUTH" == "1" ]; then
sed -i "s/enabled: true/enabled: false/g" /etc/kvmd/override.yaml \ sed -i "s/enabled: true/enabled: false/g" /etc/kvmd/override.yaml
&& echo -e "${GREEN}One-KVM auth is disabled.${NC}" log_info "已禁用认证"
fi fi
#add supervisord conf #add supervisord conf
if [ "$NOWEBTERM" == "1" ]; then if [ "$NOWEBTERM" == "1" ]; then
echo -e "${GREEN}One-KVM webterm is disabled.${NC}" log_info "已禁用 WebTerm 功能"
rm -r /usr/share/kvmd/extras/webterm rm -r /usr/share/kvmd/extras/webterm
else else
cat >> /etc/kvmd/supervisord.conf << EOF cat >> /etc/kvmd/supervisord.conf << EOF
@ -58,7 +91,7 @@ EOF
fi fi
if [ "$NOVNC" == "1" ]; then if [ "$NOVNC" == "1" ]; then
echo -e "${GREEN}One-KVM VNC is disabled.${NC}" log_info "已禁用 VNC 功能"
rm -r /usr/share/kvmd/extras/vnc rm -r /usr/share/kvmd/extras/vnc
else else
cat >> /etc/kvmd/supervisord.conf << EOF cat >> /etc/kvmd/supervisord.conf << EOF
@ -77,7 +110,7 @@ EOF
fi fi
if [ "$NOIPMI" == "1" ]; then if [ "$NOIPMI" == "1" ]; then
echo -e "${GREEN}One-KVM IPMI is disabled.${NC}" log_info "已禁用IPMI功能"
rm -r /usr/share/kvmd/extras/ipmi rm -r /usr/share/kvmd/extras/ipmi
else else
cat >> /etc/kvmd/supervisord.conf << EOF cat >> /etc/kvmd/supervisord.conf << EOF
@ -97,70 +130,71 @@ EOF
#switch OTG config #switch OTG config
if [ "$OTG" == "1" ]; then if [ "$OTG" == "1" ]; then
echo -e "${GREEN}One-KVM OTG is enabled.${NC}" log_info "已启用 OTG 功能"
sed -i "s/ch9329/otg/g" /etc/kvmd/override.yaml sed -i "s/ch9329/otg/g" /etc/kvmd/override.yaml
sed -i "s/device: \/dev\/ttyUSB0//g" /etc/kvmd/override.yaml sed -i "s/device: \/dev\/ttyUSB0//g" /etc/kvmd/override.yaml
if [ "$NOMSD" == 1 ]; then if [ "$NOMSD" == 1 ]; then
echo -e "${GREEN}One-KVM MSD is disabled.${NC}" log_info "已禁用 MSD 功能"
else else
sed -i "s/#type: otg/type: otg/g" /etc/kvmd/override.yaml sed -i "s/#type: otg/type: otg/g" /etc/kvmd/override.yaml
fi fi
fi fi
#if [ ! -z "$SHUTDOWNPIN" ! -z "$REBOOTPIN" ]; then
if [ ! -z "$VIDEONUM" ]; then if [ ! -z "$VIDEONUM" ]; then
sed -i "s/\/dev\/video0/\/dev\/video$VIDEONUM/g" /etc/kvmd/override.yaml \ if sed -i "s/\/dev\/video0/\/dev\/video$VIDEONUM/g" /etc/kvmd/override.yaml && \
&& sed -i "s/\/dev\/video0/\/dev\/video$VIDEONUM/g" /etc/kvmd/janus/janus.plugin.ustreamer.jcfg \ sed -i "s/\/dev\/video0/\/dev\/video$VIDEONUM/g" /etc/kvmd/janus/janus.plugin.ustreamer.jcfg; then
&& echo -e "${GREEN}One-KVM video device is set to /dev/video$VIDEONUM.${NC}" log_info "视频设备已设置为 /dev/video$VIDEONUM"
fi
fi fi
if [ ! -z "$AUDIONUM" ]; then if [ ! -z "$AUDIONUM" ]; then
sed -i "s/hw:0/hw:$AUDIONUM/g" /etc/kvmd/janus/janus.plugin.ustreamer.jcfg \ if sed -i "s/hw:0/hw:$AUDIONUM/g" /etc/kvmd/janus/janus.plugin.ustreamer.jcfg; then
&& echo -e "${GREEN}One-KVM audio device is set to hw:$VIDEONUM.${NC}" log_info "音频设备已设置为 hw:$AUDIONUM"
fi
fi fi
if [ ! -z "$CH9329SPEED" ]; then if [ ! -z "$CH9329SPEED" ]; then
sed -i "s/speed: 9600/speed: $CH9329SPEED/g" /etc/kvmd/override.yaml \ if sed -i "s/speed: 9600/speed: $CH9329SPEED/g" /etc/kvmd/override.yaml; then
&& echo -e "${GREEN}One-KVM CH9329 serial speed is set to $CH9329SPEED.${NC}" log_info "CH9329 串口速率已设置为 $CH9329SPEED"
fi
fi fi
if [ ! -z "$CH9329TIMEOUT" ]; then if [ ! -z "$CH9329TIMEOUT" ]; then
sed -i "s/read_timeout: 0.3/read_timeout: $CH9329TIMEOUT/g" /etc/kvmd/override.yaml \ if sed -i "s/read_timeout: 0.3/read_timeout: $CH9329TIMEOUT/g" /etc/kvmd/override.yaml; then
&& echo -e "${GREEN}One-KVM CH9329 timeout is set to $CH9329TIMEOUT s.${NC}" log_info "CH9329 超时已设置为 $CH9329TIMEOUT"
fi fi
#set htpasswd
if [ ! -z "$USERNAME" ] && [ ! -z "$PASSWORD" ]; then
python -m kvmd.apps.htpasswd del admin \
&& echo $PASSWORD | python -m kvmd.apps.htpasswd set -i "$USERNAME" \
&& echo "$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/vncpasswd \
&& echo "$USERNAME:$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/ipmipasswd \
|| echo -e "${RED}One-KVM htpasswd init failed.${NC}"
else
echo -e "${YELLOW} USERNAME and PASSWORD environment variables are not set, using defalut(admin/admin).${NC}"
fi fi
if [ ! -z "$VIDEOFORMAT" ]; then if [ ! -z "$VIDEOFORMAT" ]; then
sed -i "s/format=mjpeg/format=$VIDFORMAT/g" /etc/kvmd/override.yaml \ if sed -i "s/format=mjpeg/format=$VIDFORMAT/g" /etc/kvmd/override.yaml; then
&& echo -e "${GREEN}One-KVM input video format is set to $VIDFORMAT.${NC}" log_info "视频输入格式已设置为 $VIDFORMAT"
fi
fi fi
touch /etc/kvmd/.init_flag touch /etc/kvmd/.init_flag
log_info "初始化配置完成"
fi fi
# OTG设备配置
#Trying usb_gadget
if [ "$OTG" == "1" ]; then if [ "$OTG" == "1" ]; then
echo "Trying OTG Port..." log_info "正在配置 OTG 设备..."
rm -r /run/kvmd/otg &> /dev/null rm -r /run/kvmd/otg &> /dev/null
modprobe libcomposite || echo -e "${RED}Linux libcomposite module modprobe failed.${NC}"
python -m kvmd.apps.otg start \ if ! modprobe libcomposite; then
&& ln -s /dev/hidg1 /dev/kvmd-hid-mouse \ log_error "加载 libcomposite 模块失败"
&& ln -s /dev/hidg0 /dev/kvmd-hid-keyboard \ exit 1
|| echo -e "${RED}OTG Port mount failed.${NC}" fi
if python -m kvmd.apps.otg start; then
ln -s /dev/hidg1 /dev/kvmd-hid-mouse
ln -s /dev/hidg0 /dev/kvmd-hid-keyboard
ln -s /dev/hidg2 /dev/kvmd-hid-mouse-alt ln -s /dev/hidg2 /dev/kvmd-hid-mouse-alt
log_info "OTG 设备配置完成"
else
log_error "OTG 设备挂载失败"
exit 1
fi
fi fi
echo -e "${GREEN}One-KVM starting...${NC}" log_info "One-KVM 启动完成,正在启动服务..."
exec supervisord -c /etc/kvmd/supervisord.conf exec supervisord -c /etc/kvmd/supervisord.conf

View File

@ -1,5 +1,5 @@
general: { general: {
debug_level = 4 debug_level = 0
} }
nat: { nat: {
nice_debug = false nice_debug = false

View File

@ -149,6 +149,18 @@ vnc:
h264: h264:
sink: "kvmd::ustreamer::h264" sink: "kvmd::ustreamer::h264"
media:
memsink:
h264:
sink: 'kvmd::ustreamer::h264'
jpeg:
sink: 'kvmd::ustreamer::jpeg'
janus:
stun:
host: stun.cloudflare.com
port: 3478
otgnet: otgnet:
commands: commands:
post_start_cmd: post_start_cmd:

View File

@ -32,6 +32,16 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes = 0 stdout_logfile_maxbytes = 0
redirect_stderr=true redirect_stderr=true
[program:kvmd-media]
command=python -m kvmd.apps.media --run
autostart=true
autorestart=true
priority=13
stopasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes = 0
redirect_stderr=true
[program:kvmd-nginx] [program:kvmd-nginx]
command=nginx -c /etc/kvmd/nginx/nginx.conf -g 'daemon off;user root; error_log stderr;' command=nginx -c /etc/kvmd/nginx/nginx.conf -g 'daemon off;user root; error_log stderr;'
autostart=true autostart=true

3
scripts/kvmd-media Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cd / && python3 -m kvmd.apps.media "$@"

View File

@ -142,7 +142,7 @@
</div> </div>
</li> </li>
</div> </div>
<li class="right" id="system-dropdown"><a class="menu-button" href="#"><img class="led-gray" id="link-led" src="/share/svg/led-link.svg"><img class="led-gray" id="stream-led" src="/share/svg/led-video.svg"><img class="led-gray" id="hid-keyboard-led" src="/share/svg/led-hid-keyboard.svg"><img class="led-gray" id="hid-mouse-led" src="/share/svg/led-hid-mouse.svg"><span>System</span></a> <li class="right" id="system-dropdown"><a class="menu-button" href="#"><img class="led-gray" id="link-led" src="/share/svg/led-link.svg"><img class="led-gray" id="stream-led" src="/share/svg/led-video.svg"><img class="led-gray" id="hid-keyboard-led" src="/share/svg/led-hid-keyboard.svg"><img class="led-gray" id="hid-mouse-led" src="/share/svg/led-hid-mouse.svg"><span i18n="kvm_text3">System</span></a>
<div class="menu" id="system-menu"> <div class="menu" id="system-menu">
<table class="kv"> <table class="kv">
<tr> <tr>
@ -302,7 +302,6 @@
</tr> </tr>
</table> </table>
<details> <details>
<summary>Keyboard &amp; mouse (HID) settings</summary>
<summary i18n="kvm_text25">Keyboard &amp; Mouse (HID) settings</summary> <summary i18n="kvm_text25">Keyboard &amp; Mouse (HID) settings</summary>
<div class="spoiler"> <div class="spoiler">
<table class="kv"> <table class="kv">
@ -448,7 +447,6 @@
</tr> </tr>
<tr> <tr>
<td i18n="hid-mute-switch">Mute HID input events:</td> <td i18n="hid-mute-switch">Mute HID input events:</td>
<td>Mute all input HID events:</td>
<td align="right"> <td align="right">
<div class="switch-box"> <div class="switch-box">
<input type="checkbox" id="hid-mute-switch"> <input type="checkbox" id="hid-mute-switch">
@ -539,8 +537,8 @@
<div class="text"> <div class="text">
<table> <table>
<tr> <tr>
<td rowspan="2"><img class="sign " src="/share/svg/warning.svg"></td> <td rowspan="2"><img class="sign msd-message-too-big-for-dvd" src="/share/svg/warning.svg"></td>
<td style="line-height:1.5"><b>Current image is too big for CD-ROM!</b></td> <td style="line-height:1.5"><b>Current image is too big for DVD!</b></td>
</tr> </tr>
<tr> <tr>
<td><sup style="line-height:1">The maximum is 31.6GiB. Please switch to the Flash mode.</sup></td> <td><sup style="line-height:1">The maximum is 31.6GiB. Please switch to the Flash mode.</sup></td>
@ -787,7 +785,7 @@
</table> </table>
<table class="kv"> <table class="kv">
<tr> <tr>
<td>Slow typing:</td> <td i18n="hid-pak-slow-switch">Slow typing:</td>
<td align="right"> <td align="right">
<div class="switch-box"> <div class="switch-box">
<input type="checkbox" id="hid-pak-slow-switch"> <input type="checkbox" id="hid-pak-slow-switch">
@ -796,7 +794,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Hide input text:</td> <td i18n="hid-pak-secure-switch">Hide input text:</td>
<td align="right"> <td align="right">
<div class="switch-box"> <div class="switch-box">
<input type="checkbox" id="hid-pak-secure-switch"> <input type="checkbox" id="hid-pak-secure-switch">
@ -805,7 +803,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Ask paste confirmation:</td> <td i18n="hid-pak-ask-switch">Ask paste confirmation:</td>
<td align="right"> <td align="right">
<div class="switch-box"> <div class="switch-box">
<input checked type="checkbox" id="hid-pak-ask-switch"> <input checked type="checkbox" id="hid-pak-ask-switch">

View File

@ -17,11 +17,12 @@ li(id="text-dropdown" class="right")
td td
select(id="hid-pak-keymap-selector") select(id="hid-pak-keymap-selector")
table(class="kv") table(class="kv")
tr
+menu_switch_notable("hid-pak-slow-switch", "Slow typing", true, false, "hid-pak-slow-switch") +menu_switch_notable("hid-pak-slow-switch", "Slow typing", true, false, "hid-pak-slow-switch")
tr
+menu_switch_notable("hid-pak-secure-switch", "Hide input text", true, false, "hid-pak-secure-switch")
tr tr
+menu_switch_notable("hid-pak-ask-switch", "Ask paste confirmation", true, true, "hid-pak-ask-switch") +menu_switch_notable("hid-pak-ask-switch", "Ask paste confirmation", true, true, "hid-pak-ask-switch")
tr(id="hid-pak-secure" class="feature-disabled")
+menu_switch_notable("hid-pak-secure-switch", "Hide input text", true, false,"hid-pak-secure-switch")
div(id="stream-ocr" class="feature-disabled") div(id="stream-ocr" class="feature-disabled")
hr hr
br br

View File

@ -86,7 +86,7 @@
<tr> <tr>
<td></td> <td></td>
<td> <td>
<button class="key" id="login-button" i18n="login">Login</button> <button class="key" id="login-button" style="width:100%" i18n="login">Login</button>
</td> </td>
</tr> </tr>
</table> </table>