mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 17:50:29 +08:00
commit
30dd4290ab
@ -4,13 +4,17 @@ FROM python:3.11.11-slim-bookworm
|
|||||||
|
|
||||||
LABEL maintainer="mofeng654321@hotmail.com"
|
LABEL maintainer="mofeng654321@hotmail.com"
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
COPY --from=builder /tmp/lib/* /tmp/lib/
|
COPY --from=builder /tmp/lib/* /tmp/lib/
|
||||||
COPY --from=builder /tmp/ustreamer/ustreamer /tmp/ustreamer/ustreamer-dump /usr/bin/janus /usr/bin/
|
COPY --from=builder /tmp/ustreamer/ustreamer /tmp/ustreamer/ustreamer-dump /usr/bin/janus /usr/bin/
|
||||||
COPY --from=builder /tmp/wheel/*.whl /tmp/wheel/
|
COPY --from=builder /tmp/wheel/*.whl /tmp/wheel/
|
||||||
COPY --from=builder /tmp/ustreamer/libjanus_ustreamer.so /usr/lib/ustreamer/janus/
|
COPY --from=builder /tmp/ustreamer/libjanus_ustreamer.so /usr/lib/ustreamer/janus/
|
||||||
COPY --from=builder /usr/lib/janus/transports/* /usr/lib/janus/transports/
|
COPY --from=builder /usr/lib/janus/transports/* /usr/lib/janus/transports/
|
||||||
|
COPY --from=builder /tmp/arm64-libs.tar.gz* /tmp/
|
||||||
ARG TARGETARCH
|
RUN if [ ${TARGETARCH} = arm64 ] && [ -f /tmp/arm64-libs.tar.gz ]; then \
|
||||||
|
cd / && tar -xzf /tmp/arm64-libs.tar.gz && rm -f /tmp/arm64-libs.tar.gz; \
|
||||||
|
fi
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
@ -41,32 +45,38 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.lis
|
|||||||
libwebsockets17 \
|
libwebsockets17 \
|
||||||
libnss3 \
|
libnss3 \
|
||||||
libasound2 \
|
libasound2 \
|
||||||
|
libdrm2 \
|
||||||
|
libx264-164 \
|
||||||
|
libyuv0 \
|
||||||
nano \
|
nano \
|
||||||
unzip \
|
unzip \
|
||||||
libavcodec59 \
|
&& case ${TARGETARCH} in \
|
||||||
libavformat59 \
|
amd64) \
|
||||||
libavutil57 \
|
|
||||||
libswscale6 \
|
|
||||||
libavfilter8 \
|
|
||||||
libavdevice59 \
|
|
||||||
&& if [ ${TARGETARCH} != arm ] && [ ${TARGETARCH} != arm64 ]; then \
|
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
ffmpeg \
|
libavcodec59 libavformat59 libavutil57 \
|
||||||
vainfo \
|
libswscale6 libavfilter8 libavdevice59 \
|
||||||
libva2 \
|
ffmpeg vainfo \
|
||||||
libva-drm2 \
|
libva2 libva-drm2 libva-x11-2 \
|
||||||
libva-x11-2 \
|
mesa-va-drivers mesa-vdpau-drivers \
|
||||||
libdrm2 \
|
intel-media-va-driver i965-va-driver \
|
||||||
mesa-va-drivers \
|
;; \
|
||||||
mesa-vdpau-drivers \
|
arm) \
|
||||||
intel-media-va-driver \
|
|
||||||
i965-va-driver; \
|
|
||||||
fi \
|
|
||||||
&& if [ ${TARGETARCH} = arm ] || [ ${TARGETARCH} = arm64 ]; then \
|
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
v4l-utils \
|
libavcodec59 libavformat59 libavutil57 \
|
||||||
libv4l-0; \
|
libswscale6 libavfilter8 libavdevice59 \
|
||||||
fi \
|
v4l-utils libv4l-0 \
|
||||||
|
;; \
|
||||||
|
arm64) \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
v4l-utils libv4l-0 \
|
||||||
|
libstdc++6 \
|
||||||
|
libva2 libva-drm2 libva-x11-2 \
|
||||||
|
libvdpau1 ocl-icd-libopencl1 \
|
||||||
|
;; \
|
||||||
|
*) \
|
||||||
|
echo "Unsupported architecture: ${TARGETARCH}" && exit 1 \
|
||||||
|
;; \
|
||||||
|
esac \
|
||||||
&& cp /tmp/lib/* /lib/*-linux-*/ \
|
&& 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 /tmp/wheel/*.whl \
|
||||||
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check pyfatfs \
|
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check pyfatfs \
|
||||||
@ -89,7 +99,8 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.lis
|
|||||||
&& touch /run/kvmd/ustreamer.sock \
|
&& touch /run/kvmd/ustreamer.sock \
|
||||||
&& apt clean \
|
&& apt clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& rm -rf /tmp/lib /tmp/wheel
|
&& rm -rf /tmp/lib /tmp/wheel \
|
||||||
|
&& ustreamer -v
|
||||||
|
|
||||||
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/
|
||||||
|
|||||||
@ -49,27 +49,36 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.lis
|
|||||||
libusb-1.0-0-dev \
|
libusb-1.0-0-dev \
|
||||||
libldap2-dev \
|
libldap2-dev \
|
||||||
libsasl2-dev \
|
libsasl2-dev \
|
||||||
|
libdrm-dev \
|
||||||
|
mesa-va-drivers \
|
||||||
|
mesa-vdpau-drivers \
|
||||||
|
v4l-utils \
|
||||||
|
libv4l-dev \
|
||||||
|
&& if [ ${TARGETARCH} != arm64 ]; then \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
libavcodec-dev \
|
libavcodec-dev \
|
||||||
libavformat-dev \
|
libavformat-dev \
|
||||||
libavutil-dev \
|
libavutil-dev \
|
||||||
libswscale-dev \
|
libswscale-dev \
|
||||||
libavfilter-dev \
|
libavfilter-dev \
|
||||||
libavdevice-dev \
|
libavdevice-dev; \
|
||||||
|
fi \
|
||||||
|
&& if [ ${TARGETARCH} != arm ] && [ ${TARGETARCH} != arm64 ]; then \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
vainfo \
|
vainfo \
|
||||||
libva-dev \
|
libva-dev \
|
||||||
libva-drm2 \
|
libva-drm2 \
|
||||||
libva-x11-2 \
|
libva-x11-2 \
|
||||||
libdrm-dev \
|
|
||||||
mesa-va-drivers \
|
|
||||||
mesa-vdpau-drivers \
|
|
||||||
v4l-utils \
|
|
||||||
libv4l-dev \
|
|
||||||
&& if [ ${TARGETARCH} != arm ] && [ ${TARGETARCH} != arm64 ]; then \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
intel-media-va-driver \
|
intel-media-va-driver \
|
||||||
i965-va-driver; \
|
i965-va-driver; \
|
||||||
fi \
|
fi \
|
||||||
|
&& if [ ${TARGETARCH} = arm64 ]; then \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
ninja-build \
|
||||||
|
zlib1g-dev \
|
||||||
|
libswresample-dev; \
|
||||||
|
fi \
|
||||||
&& apt clean \
|
&& apt clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@ -94,12 +103,18 @@ RUN --security=insecure pip config set global.index-url https://pypi.tuna.tsingh
|
|||||||
pycparser pyelftools pyghmi pygments pyparsing pyotp qrcode requests \
|
pycparser pyelftools pyghmi pygments pyparsing pyotp qrcode requests \
|
||||||
semantic-version setproctitle six spidev tabulate urllib3 wrapt xlib \
|
semantic-version setproctitle six spidev tabulate urllib3 wrapt xlib \
|
||||||
yarl pyserial pyyaml zstandard supervisor pyfatfs pyserial python-periphery \
|
yarl pyserial pyyaml zstandard supervisor pyfatfs pyserial python-periphery \
|
||||||
python-ldap python-pam pyrad pyudev pyusb luma.oled pyserial-asyncio
|
python-ldap python-pam pyrad pyudev pyusb luma.oled pyserial-asyncio \
|
||||||
|
&& rm -rf /root/.cache/pip/* /tmp/pip-* \
|
||||||
|
&& if [ ${TARGETARCH} = arm ]; then \
|
||||||
|
umount /root/.cargo 2>/dev/null || true \
|
||||||
|
&& rm -rf /root/.cargo /root/rustup-init.sh; \
|
||||||
|
fi
|
||||||
|
|
||||||
# 编译 python vedev库
|
# 编译 python evdev库
|
||||||
RUN git clone --depth=1 https://github.com/gvalkov/python-evdev.git /tmp/python-evdev \
|
RUN git clone --depth=1 https://github.com/gvalkov/python-evdev.git /tmp/python-evdev \
|
||||||
&& cd /tmp/python-evdev \
|
&& cd /tmp/python-evdev \
|
||||||
&& python3 setup.py bdist_wheel --dist-dir /tmp/wheel/
|
&& python3 setup.py bdist_wheel --dist-dir /tmp/wheel/ \
|
||||||
|
&& rm -rf /tmp/python-evdev
|
||||||
|
|
||||||
# 编译安装 libnice、libsrtp、libwebsockets 和 janus-gateway
|
# 编译安装 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 \
|
||||||
@ -111,14 +126,14 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn
|
|||||||
&& tar xf 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 -j && make install \
|
&& make shared_library -j$(nproc) && make install \
|
||||||
&& cd /tmp \
|
&& cd /tmp \
|
||||||
&& rm -rf /tmp/libsrtp* \
|
&& rm -rf /tmp/libsrtp* \
|
||||||
&& git clone --depth=1 https://libwebsockets.org/repo/libwebsockets /tmp/libwebsockets \
|
&& git clone --depth=1 https://github.com/warmcat/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 -j && make install \
|
&& make -j$(nproc) && make install \
|
||||||
&& cd /tmp \
|
&& cd /tmp \
|
||||||
&& rm -rf /tmp/libwebsockets \
|
&& rm -rf /tmp/libwebsockets \
|
||||||
&& git clone --depth=1 https://github.com/meetecho/janus-gateway.git /tmp/janus-gateway \
|
&& git clone --depth=1 https://github.com/meetecho/janus-gateway.git /tmp/janus-gateway \
|
||||||
@ -127,19 +142,40 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn
|
|||||||
&& ./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-data-channels --disable-rabbitmq --disable-mqtt --disable-all-plugins \
|
||||||
--disable-all-loggers --prefix=/usr \
|
--disable-all-loggers --prefix=/usr \
|
||||||
&& make -j && make install \
|
&& make -j$(nproc) && make install \
|
||||||
&& cd /tmp \
|
&& cd /tmp \
|
||||||
&& rm -rf /tmp/janus-gateway
|
&& rm -rf /tmp/janus-gateway
|
||||||
|
|
||||||
|
# 编译 Rockchip MPP、RGA 和 FFmpeg(仅 arm64)
|
||||||
|
RUN if [ ${TARGETARCH} = arm64 ]; then \
|
||||||
|
git clone -b jellyfin-mpp --depth=1 https://github.com/nyanmisaka/mpp.git /tmp/rkmpp \
|
||||||
|
&& mkdir -p /tmp/rkmpp/rkmpp_build && cd /tmp/rkmpp/rkmpp_build \
|
||||||
|
&& cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=OFF .. \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install \
|
||||||
|
&& git clone -b jellyfin-rga --depth=1 https://github.com/nyanmisaka/rk-mirrors.git /tmp/rkrga \
|
||||||
|
&& cd /tmp/ \
|
||||||
|
&& meson setup rkrga rkrga_build --prefix=/usr --libdir=lib --buildtype=release -Dcpp_args=-fpermissive -Dlibdrm=false -Dlibrga_demo=false \
|
||||||
|
&& meson configure rkrga_build > /dev/null \
|
||||||
|
&& ninja -C rkrga_build install \
|
||||||
|
&& git clone --depth=1 https://github.com/nyanmisaka/ffmpeg-rockchip.git /tmp/ffmpeg-rockchip \
|
||||||
|
&& cd /tmp/ffmpeg-rockchip \
|
||||||
|
&& ./configure --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga \
|
||||||
|
--enable-libv4l2 --enable-libx264 --enable-shared --disable-programs \
|
||||||
|
--disable-doc --disable-htmlpages --disable-manpages --disable-network --disable-protocols \
|
||||||
|
--disable-decoders --disable-debug --disable-alsa \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install \
|
||||||
|
&& rm -rf /tmp/rkmpp /tmp/rkrga /tmp/ffmpeg-rockchip; \
|
||||||
|
fi
|
||||||
|
|
||||||
# 编译 ustreamer
|
# 编译 ustreamer
|
||||||
RUN echo "Building ustreamer with timestamp cache bust" \
|
RUN sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \
|
||||||
&& 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 \
|
||||||
&& TIMESTAMP=$(date +%s%N) \
|
&& make -j$(nproc) WITH_PYTHON=1 WITH_JANUS=1 WITH_FFMPEG=1 -C /tmp/ustreamer \
|
||||||
&& git clone --depth=1 https://github.com/mofeng-git/ustreamer /tmp/ustreamer-${TIMESTAMP} \
|
&& /tmp/ustreamer/ustreamer -v \
|
||||||
&& make -j WITH_PYTHON=1 WITH_JANUS=1 WITH_FFMPEG=1 -C /tmp/ustreamer-${TIMESTAMP} \
|
&& /tmp/ustreamer/ustreamer-dump -v \
|
||||||
&& /tmp/ustreamer-${TIMESTAMP}/ustreamer -v \
|
&& cp /tmp/ustreamer/python/dist/*.whl /tmp/wheel/
|
||||||
&& cp /tmp/ustreamer-${TIMESTAMP}/python/dist/*.whl /tmp/wheel/ \
|
|
||||||
&& mv /tmp/ustreamer-${TIMESTAMP} /tmp/ustreamer
|
|
||||||
|
|
||||||
# 复制必要的库文件
|
# 复制必要的库文件
|
||||||
RUN mkdir /tmp/lib \
|
RUN mkdir /tmp/lib \
|
||||||
@ -148,4 +184,11 @@ RUN mkdir /tmp/lib \
|
|||||||
libevent-*.so.* libjpeg.so.* libyuv.so.* libnice.so.* \
|
libevent-*.so.* libjpeg.so.* libyuv.so.* libnice.so.* \
|
||||||
/tmp/lib/ \
|
/tmp/lib/ \
|
||||||
&& find /usr/lib -name "libsrtp2.so.*" -exec cp {} /tmp/lib/ \; \
|
&& find /usr/lib -name "libsrtp2.so.*" -exec cp {} /tmp/lib/ \; \
|
||||||
&& find /usr/lib -name "libwebsockets.so.*" -exec cp {} /tmp/lib/ \;
|
&& find /usr/lib -name "libwebsockets.so.*" -exec cp {} /tmp/lib/ \; \
|
||||||
|
&& if [ ${TARGETARCH} = arm64 ]; then \
|
||||||
|
find /usr/lib -name "libav*.so.*" -exec cp {} /tmp/lib/ \; \
|
||||||
|
&& find /usr/lib -name "libsw*.so.*" -exec cp {} /tmp/lib/ \; \
|
||||||
|
&& find /usr/lib -name "libpostproc.so.*" -exec cp {} /tmp/lib/ \; \
|
||||||
|
&& find /usr/lib -name "librockchip*" -exec cp {} /tmp/lib/ \; \
|
||||||
|
&& find /usr/lib -name "librga.so.*" -exec cp {} /tmp/lib/ \; ; \
|
||||||
|
fi
|
||||||
|
|||||||
@ -108,7 +108,7 @@ install_base_packages() {
|
|||||||
iptables network-manager curl kmod libmicrohttpd12 libjansson4 libssl3 \\
|
iptables network-manager curl kmod libmicrohttpd12 libjansson4 libssl3 \\
|
||||||
libsofia-sip-ua0 libglib2.0-0 libopus0 libogg0 libcurl4 libconfig9 \\
|
libsofia-sip-ua0 libglib2.0-0 libopus0 libogg0 libcurl4 libconfig9 \\
|
||||||
python3-pip net-tools libavcodec59 libavformat59 libavutil57 libswscale6 \\
|
python3-pip net-tools libavcodec59 libavformat59 libavutil57 libswscale6 \\
|
||||||
libavfilter8 libavdevice59 v4l-utils libv4l-0 && \\
|
libavfilter8 libavdevice59 v4l-utils libv4l-0 nano unzip && \\
|
||||||
apt clean && \\
|
apt clean && \\
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
"
|
"
|
||||||
@ -180,9 +180,8 @@ configure_system() {
|
|||||||
cat /One-KVM/configs/os/udev/v2-hdmiusb-rpi4.rules > /etc/udev/rules.d/99-kvmd.rules && \\
|
cat /One-KVM/configs/os/udev/v2-hdmiusb-rpi4.rules > /etc/udev/rules.d/99-kvmd.rules && \\
|
||||||
echo 'libcomposite' >> /etc/modules && \\
|
echo 'libcomposite' >> /etc/modules && \\
|
||||||
mv /usr/local/bin/kvmd* /usr/bin/ || echo '信息:/usr/local/bin/kvmd* 未找到或移动失败,可能已在/usr/bin' && \\
|
mv /usr/local/bin/kvmd* /usr/bin/ || echo '信息:/usr/local/bin/kvmd* 未找到或移动失败,可能已在/usr/bin' && \\
|
||||||
cp /One-KVM/configs/os/services/* /etc/systemd/system/ && \\
|
cp -r /One-KVM/configs/os/services/* /etc/systemd/system/ && \\
|
||||||
cp /One-KVM/configs/os/tmpfiles.conf /usr/lib/tmpfiles.d/ && \\
|
cp /One-KVM/configs/os/tmpfiles.conf /usr/lib/tmpfiles.d/ && \\
|
||||||
mv /etc/kvmd/supervisord.conf /etc/supervisord.conf && \\
|
|
||||||
chmod +x /etc/update-motd.d/* || echo '警告:chmod /etc/update-motd.d/* 失败' && \\
|
chmod +x /etc/update-motd.d/* || echo '警告:chmod /etc/update-motd.d/* 失败' && \\
|
||||||
echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/gpio.sh' >> /etc/sudoers && \\
|
echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/gpio.sh' >> /etc/sudoers && \\
|
||||||
echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/usbrelay_hid.sh' >> /etc/sudoers && \\
|
echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/usbrelay_hid.sh' >> /etc/sudoers && \\
|
||||||
@ -203,14 +202,16 @@ install_webterm() {
|
|||||||
local ttyd_arch="$arch"
|
local ttyd_arch="$arch"
|
||||||
|
|
||||||
if [ "$arch" = "armhf" ]; then
|
if [ "$arch" = "armhf" ]; then
|
||||||
ttyd_arch="armv7"
|
ttyd_arch="armhf"
|
||||||
elif [ "$arch" = "amd64" ]; then
|
elif [ "$arch" = "amd64" ]; then
|
||||||
ttyd_arch="x86_64" # ttyd 通常用 x86_64
|
ttyd_arch="x86_64"
|
||||||
|
elif [ "$arch" = "aarch64" ]; then
|
||||||
|
ttyd_arch="aarch64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "信息:在 chroot 环境中下载并安装 ttyd ($ttyd_arch)..."
|
echo "信息:在 chroot 环境中下载并安装 ttyd ($ttyd_arch)..."
|
||||||
run_in_chroot "
|
run_in_chroot "
|
||||||
curl -L https://gh.llkk.cc/https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${ttyd_arch} -o /usr/bin/ttyd && \\
|
curl -L https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${ttyd_arch} -o /usr/bin/ttyd && \\
|
||||||
chmod +x /usr/bin/ttyd && \\
|
chmod +x /usr/bin/ttyd && \\
|
||||||
mkdir -p /home/kvmd-webterm && \\
|
mkdir -p /home/kvmd-webterm && \\
|
||||||
chown kvmd-webterm /home/kvmd-webterm
|
chown kvmd-webterm /home/kvmd-webterm
|
||||||
|
|||||||
@ -71,8 +71,9 @@ if [ ! -f /etc/kvmd/.init_flag ]; then
|
|||||||
|
|
||||||
# 设置用户名和密码
|
# 设置用户名和密码
|
||||||
if [ ! -z "$USERNAME" ] && [ ! -z "$PASSWORD" ]; then
|
if [ ! -z "$USERNAME" ] && [ ! -z "$PASSWORD" ]; then
|
||||||
|
# 设置自定义用户名和密码
|
||||||
if python -m kvmd.apps.htpasswd del admin \
|
if python -m kvmd.apps.htpasswd del admin \
|
||||||
&& echo "$PASSWORD" | python -m kvmd.apps.htpasswd set -i "$USERNAME" \
|
&& echo "$PASSWORD" | python -m kvmd.apps.htpasswd add -i "$USERNAME" \
|
||||||
&& echo "$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/vncpasswd \
|
&& echo "$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/vncpasswd \
|
||||||
&& echo "$USERNAME:$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/ipmipasswd; then
|
&& echo "$USERNAME:$PASSWORD -> $USERNAME:$PASSWORD" > /etc/kvmd/ipmipasswd; then
|
||||||
log_info "用户凭据设置成功"
|
log_info "用户凭据设置成功"
|
||||||
@ -80,6 +81,16 @@ if [ ! -f /etc/kvmd/.init_flag ]; then
|
|||||||
log_error "用户凭据设置失败"
|
log_error "用户凭据设置失败"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
elif [ ! -z "$PASSWORD" ] && [ -z "$USERNAME" ]; then
|
||||||
|
# 只设置密码,保持admin用户名
|
||||||
|
if echo "$PASSWORD" | python -m kvmd.apps.htpasswd set -i "admin" \
|
||||||
|
&& echo "$PASSWORD -> admin:$PASSWORD" > /etc/kvmd/vncpasswd \
|
||||||
|
&& echo "admin:$PASSWORD -> admin:$PASSWORD" > /etc/kvmd/ipmipasswd; then
|
||||||
|
log_info "admin 用户密码设置成功"
|
||||||
|
else
|
||||||
|
log_error "admin 用户密码设置失败"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_warn "未设置 USERNAME 和 PASSWORD 环境变量,使用默认值(admin/admin)"
|
log_warn "未设置 USERNAME 和 PASSWORD 环境变量,使用默认值(admin/admin)"
|
||||||
fi
|
fi
|
||||||
@ -210,8 +221,8 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$VIDEOFORMAT" ]; then
|
if [ ! -z "$VIDEOFORMAT" ]; then
|
||||||
if sed -i "s/format=mjpeg/format=$VIDFORMAT/g" /etc/kvmd/override.yaml; then
|
if sed -i "s/--format=mjpeg/--format=$VIDEOFORMAT/g" /etc/kvmd/override.yaml; then
|
||||||
log_info "视频输入格式已设置为 $VIDFORMAT"
|
log_info "视频输入格式已设置为 $VIDEOFORMAT"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -221,6 +232,19 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 设置WEB端口
|
||||||
|
if [ ! -z "$HTTPPORT" ]; then
|
||||||
|
if sed -i "s/port: 8080/port: $HTTPPORT/g" /etc/kvmd/override.yaml; then
|
||||||
|
log_info "HTTP 端口已设置为 $HTTPPORT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$HTTPSPORT" ]; then
|
||||||
|
if sed -i "s/port: 4430/port: $HTTPSPORT/g" /etc/kvmd/override.yaml; then
|
||||||
|
log_info "HTTPS 端口已设置为 $HTTPSPORT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
touch /etc/kvmd/.init_flag
|
touch /etc/kvmd/.init_flag
|
||||||
log_info "初始化配置完成"
|
log_info "初始化配置完成"
|
||||||
|
|||||||
@ -719,9 +719,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden" id="msd-uploading-sub">
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<div class="hidden" id="msd-uploading-sub">
|
<div class="hidden" id="msd-uploading-sub">
|
||||||
<table class="kv">
|
<table class="kv">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -47,7 +47,7 @@ li.right.feature-disabled#msd-dropdown
|
|||||||
{title: "Flash", value: "0"},
|
{title: "Flash", value: "0"},
|
||||||
]) Drive #[a(target="_blank" href="https://docs.pikvm.org/msd") mode]:
|
]) Drive #[a(target="_blank" href="https://docs.pikvm.org/msd") mode]:
|
||||||
td
|
td
|
||||||
+menu_switch_td2("msd-rw-switch", false, false) Writable:
|
+menu_switch_td2("msd-rw-switch", false, false, "msd-rw-switch") Writable:
|
||||||
tr
|
tr
|
||||||
td(i18n="drive_file_display") Files:
|
td(i18n="drive_file_display") Files:
|
||||||
td
|
td
|
||||||
@ -79,8 +79,6 @@ li.right.feature-disabled#msd-dropdown
|
|||||||
tr.hidden#msd-new-part
|
tr.hidden#msd-new-part
|
||||||
td(i18n="drive_upload_partition") Upload partition:
|
td(i18n="drive_upload_partition") Upload partition:
|
||||||
td(width="100%") #[select#msd-new-part-selector]
|
td(width="100%") #[select#msd-new-part-selector]
|
||||||
div(id="msd-uploading-sub" class="hidden")
|
|
||||||
hr
|
|
||||||
|
|
||||||
.hidden#msd-uploading-sub
|
.hidden#msd-uploading-sub
|
||||||
table.kv
|
table.kv
|
||||||
|
|||||||
@ -122,6 +122,7 @@
|
|||||||
"drive_unpackage_files":"Unpackage files from image",
|
"drive_unpackage_files":"Unpackage files from image",
|
||||||
"drive_image_files":"Image Files",
|
"drive_image_files":"Image Files",
|
||||||
"drive_normal_files":"Normal Files",
|
"drive_normal_files":"Normal Files",
|
||||||
|
"drive_writable":"Writable:",
|
||||||
|
|
||||||
"atx-ask-switch":"Ask click confirmation",
|
"atx-ask-switch":"Ask click confirmation",
|
||||||
"hid-recorder-loop-switch":"Infinite loop playback",
|
"hid-recorder-loop-switch":"Infinite loop playback",
|
||||||
|
|||||||
@ -122,6 +122,7 @@
|
|||||||
"drive_unpackage_files":"从镜像文件解压文件",
|
"drive_unpackage_files":"从镜像文件解压文件",
|
||||||
"drive_image_files":"镜像文件模式",
|
"drive_image_files":"镜像文件模式",
|
||||||
"drive_normal_files":"普通文件模式",
|
"drive_normal_files":"普通文件模式",
|
||||||
|
"drive_writable":"可写:",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,20 +42,34 @@ function getCookie(name)
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var i18nLanguage = "zh";
|
function detectBrowserLanguage() {
|
||||||
|
var browserLang = navigator.language || navigator.userLanguage;
|
||||||
|
if (browserLang.startsWith('zh')) {
|
||||||
|
return 'zh';
|
||||||
|
} else if (browserLang.startsWith('en')) {
|
||||||
|
return 'en';
|
||||||
|
} else {
|
||||||
|
return 'zh';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var i18nLanguage = detectBrowserLanguage();
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if (getCookie('userLanguage')) {
|
if (getCookie('userLanguage')) {
|
||||||
i18nLanguage = getCookie('userLanguage');
|
i18nLanguage = getCookie('userLanguage');
|
||||||
|
}
|
||||||
|
|
||||||
|
var no;
|
||||||
if (i18nLanguage == "zh") {
|
if (i18nLanguage == "zh") {
|
||||||
no = 0;
|
no = 0;
|
||||||
}else if (i18nLanguage == "en") {
|
} else if (i18nLanguage == "en") {
|
||||||
no = 1;
|
no = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#selectLanguage").each(function(){
|
$("#selectLanguage").each(function(){
|
||||||
$(this).find("option").eq(no).prop("selected",true)
|
$(this).find("option").eq(no).prop("selected", true);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
$("[i18n]").i18n({
|
$("[i18n]").i18n({
|
||||||
defaultLang: i18nLanguage,
|
defaultLang: i18nLanguage,
|
||||||
|
|||||||
@ -337,10 +337,10 @@ export function Msd() {
|
|||||||
}
|
}
|
||||||
if (file) {
|
if (file) {
|
||||||
let e_image = encodeURIComponent(file.name);
|
let e_image = encodeURIComponent(file.name);
|
||||||
__http.open("POST", `${ROOT_PREFIX}api/msd/write?prefix=${e_prefix}&image=${e_image}&remove_incomplete=1`, true);
|
__http.open("POST", `${ROOT_PREFIX}api/msd/write?prefix=${prefix}&image=${e_image}&remove_incomplete=1`, true);
|
||||||
} else {
|
} else {
|
||||||
let e_url = encodeURIComponent($("msd-new-url").value);
|
let e_url = encodeURIComponent($("msd-new-url").value);
|
||||||
__http.open("POST", `${ROOT_PREFIX}api/msd/write_remote?prefix=${e_prefix}&url=${e_url}&remove_incomplete=1`, true);
|
__http.open("POST", `${ROOT_PREFIX}api/msd/write_remote?prefix=${prefix}&url=${e_url}&remove_incomplete=1`, true);
|
||||||
}
|
}
|
||||||
__http.upload.timeout = 7 * 24 * 3600;
|
__http.upload.timeout = 7 * 24 * 3600;
|
||||||
__http.onreadystatechange = __uploadStateChange;
|
__http.onreadystatechange = __uploadStateChange;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user