diff --git a/README.MD b/README.MD new file mode 100644 index 00000000..16835406 --- /dev/null +++ b/README.MD @@ -0,0 +1,93 @@ +# KVMD-ARMBIAN +This project supports non-Raspberry Pi device to run pikvm on armbian or Raspberry Pi boards on Raspbian Bookworm +- It also supports x86 pikvm with USB uart + ch9329 serial HID if you use the install-x86.sh script and follow the How to Install PiKVM x86.pdf +- As of 04/21/2024, I have left the PiKVM Discord so if you need assistance, please email me: srepac@kvmnerds.com +- You can also try and see if I'm on my own Discord at https://discord.gg/YaJ87sVznc + +# Install +KVMD Install for armbian/raspbian + +It supports Allwinner, Amlogic and Rockchip based tv box, tested on phicomm n1, mxq pro 4k, tqc a01. +Chipset needs to support USB OTG feature, lots of old amglogic chipset does not support otg feature, such as s805 and s905. +You should install armbian with debian jammy as jammy has python 3.10 or python 3.11 (starting with kvmd 3.217) which the newer kvmd code is based on. +Then run this script (2x) to install pikvm. + +This also works on rpi boards running Raspbian Bookworm. + +Install script is a fork from @srepac raspbian pikvm install script. + +**NOTE: all commands need to be run as root user.** + +Original Script [http://148.135.104.55/RPiKVM/install-pikvm-raspbian.sh] + +# Hardware for kvmd-armbian project +* A tv box/arm board that supports otg feature: + - Tests on phicomm n1(Amlogic s905d), mxq pro 4k (rk322x), tqc a01(Allwinner H6). + - If you are using arm board you can remove gpio patch to enable gpio feature. +* Video capture device: + - HDMI to USB dongle (30 RMB On taobao, 10$ on aliexpress.) or USB HDMI loop capture dongle + - cheap hdmi to usb dongle all use physics USB2.0 port, but fake USB3.0(USB 5GBPS, USB3.2GEN1) version supports 720P 60FPS, + usb 2.0 version only supports 720P 30FPS. +* USB-A to USB-A cable or micro-USB to USB-A cable: + - Recommended to cut off usb cable's power line, otherwise it might cause otg disconnect. + +## Step 1 +- Flash armbian debian [Recommended jammy] for your tv box (If kernel not support otg you should build a kernel enable otg features) +- Flash armbian debian jammy for all others + +## Step 2 (skip this step if running on Orange Pi zero and one boards) +- Modify your dtb file to enable otg feature. Change dr_mode from host to peripheral for otg usb port. +- If you use rk322x (rk3228A rk3228B rk3229) series chipset, you can use dtb/4.4/rk332x-box.dtb +- Add the following to your /boot/armbianEnv.txt file +``` +overlays=usbhost0 usbhost1 usbhost2 usbhost3 +``` + +**NOTE: Skip steps 1 and 2 if you are running raspbian bookworm on rpi boards** +## Step 3 - Perform part 1 of install +``` +apt update && apt upgrade -y +apt install -y git vim make python3-dev gcc +git clone https://github.com/srepac/kvmd-armbian.git +cd kvmd-armbian +./install.sh +``` +This will ask you to press ENTER to reboot after part 1 completes. + +## Step 4 - Perform part 2 of install +- run install.sh again after reboot os to perform part 2 of install. **NOTE: May require one more reboot if missing /dev/kvmd-hid-[keyboard|mouse]** +``` +cd kvmd-armbian +./install.sh +``` +- Enjoy + + +# Updating RPiKVM +Update armbian pikvm anytime in order to take advantage of new features/updates. + +- run the update-rpikvm.sh script to perform update +``` +wget -O /usr/local/bin/update-rpikvm.sh http://148.135.104.55/RPiKVM/update-rpikvm.sh +update-rpikvm.sh +``` + + +# Tested device + - Phicomm N1 + - TQC A01 (Ethernet port not working, only support wireless.) + - RK322x based tvbox (MXQ, V88) + - S905L2 based tvbox + - Orange pi zero (tested by @MrSuicideParrot) + - Orange Pi Zero and One (tested by @srepac) + - Nano Pi Neo, Rock64, and Orange Pi Zero Plus (tested by @srepac) + - Libre Computer Le Potato, La Frite 1GB, Renegade ROC-RK3328-CC and ALL-H3-CC H5 2GB (tested by @srepac) + - Inovato Quadra tv box (tested by @srepac) + - Big Tree Tech CB1+Rpi4 board (WIP by @srepac) + - Orange Pi PC+ and orange pi 3 (tested by @ducs4rs) + - RPi4B + PiKVM V3 HAT on Raspberry Pi OS bookworm (tested by @srepac on 10/19/23) + - RPi4B + BliKVM V3 HAT on Raspberry Pi OS bookworm (tested by @srepac) + - RPiCM4 + BliKVM V2 pcie HAT on Raspberry Pi OS bookworm (tested by @srepac) + - RPiCM4 + Geekworm A8 pcie HAT on Raspberry Pi OS bookworm (tested by @srepac) + - RPiCM4 + Geekworm X650 pcie HAT on Raspberry Pi OS bookworm (tested by @srepac) + - RPiCM4 + Geekworm X635 HAT on Raspberry Pi OS bookworm (tested by @srepac) diff --git a/README.md b/README.md index 7ecf0911..a0c8e210 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,6 @@ One-KVM 是基于经济计算机硬件(目前为玩客云和 X64 兼容机)和PiKVM软件的硬件级远程控制项目。KVM over IP 可以远程管理服务器或工作站,实现无侵入式控制,无论被控机为什么操作系统或是否安装了操作系统,具有更广泛的适用性。此项目基于 [PiKVM](https://github.com/pikvm/pikvm),和基于远控软件的远程管理方式不同,无需在被控电脑安装任何软件,实现无侵入式控制。 - -**功能特性** - -主要功能比较,TinyPilot 社区版本、PiKVMv3 版本出现在这里仅做比较目的。 -| 功能 | One-KVM | TinyPilot 社区版本 | PiKVMv3版本 | -| :------------: | :---------------------: | :----------------: | :----------: | -| HTML5界面语言 | 简体中文 | 英文 | 英文 | -| BIOS控制 | √ | √ | √ | -| 视频捕捉 | √ | √ | √ | -| 音频捕捉 | × | √ | √ | -| 鼠键捕获类型 | OTG CH9329 | OTG | OTG CH9329 | -| 从剪贴板粘贴 | √ | √ | √ | -| OCR识别 | √ | × | √ | -| LAN唤醒 | √ | × | √ | -| VNC支持 | √ | × | √ | -| HDMI环出 | √(含HDMI设备初步支持) | × | × | -| 虚拟存储驱动器 | √(仅含OTG设备支持) | × | √ | -| ATX开关机 | √(仅含GPIO设备支持) | × | √ | -| 板载WiFi | × | √ | √ | -| 视频流格式 | MJPEG H.264(软编码) | MJPEG, H.264 | MJPEG, H.264 | -| 最大视频分辨率 | 1920x1080 | 1920x1080 | 1920x1080 | - - ### 快速开始 **方式一:直刷 One-KVM 镜像** @@ -57,6 +34,27 @@ docker run -itd -p443:443 -p80:80 --name pikvm-docker --device=/dev/ttyUSB0:/dev 详细内容可以参照 [One-KVM文档](https://one-kvm.mofeng.run/)。 +### 功能特性 + +主要功能比较,TinyPilot 社区版本、PiKVMv3 版本出现在这里仅做比较目的。 +| 功能 | One-KVM | TinyPilot 社区版本 | PiKVMv3版本 | +| :------------: | :---------------------: | :----------------: | :----------: | +| HTML5界面语言 | 简体中文 | 英文 | 英文 | +| BIOS控制 | √ | √ | √ | +| 视频捕捉 | √ | √ | √ | +| 音频捕捉 | × | √ | √ | +| 鼠键捕获类型 | OTG CH9329 | OTG | OTG CH9329 | +| 从剪贴板粘贴 | √ | √ | √ | +| OCR识别 | √ | × | √ | +| LAN唤醒 | √ | × | √ | +| VNC支持 | √ | × | √ | +| HDMI环出 | √(含HDMI设备初步支持) | × | × | +| 虚拟存储驱动器 | √(仅含OTG设备支持) | × | √ | +| ATX开关机 | √(仅含GPIO设备支持) | × | √ | +| 板载WiFi | × | √ | √ | +| 视频流格式 | MJPEG H.264(软编码) | MJPEG, H.264 | MJPEG, H.264 | +| 最大视频分辨率 | 1920x1080 | 1920x1080 | 1920x1080 | + ### 其他 @@ -101,3 +99,4 @@ Will 1. [pikvm/pikvm: Open and inexpensive DIY IP-KVM based on Raspberry Pi (github.com)](https://github.com/pikvm/pikvm) 2. [hzyitc/armbian-onecloud: Armbian for onecloud. 玩客云用armbian (github.com)](https://github.com/hzyitc/armbian-onecloud/) 3. [jacobbar/fruity-pikvm: Install Pi-KVM on debian SBCs such as Orange Pi, Banana Pi, Mango Pi, etc (github.com)](https://github.com/jacobbar/fruity-pikvm) +4. [kvmd-armbian/install.sh at master · srepac/kvmd-armbian (github.com)](https://github.com/srepac/kvmd-armbian/blob/master/install.sh) \ No newline at end of file diff --git a/aiofiles.tar b/aiofiles.tar new file mode 100644 index 00000000..10e2e1cf Binary files /dev/null and b/aiofiles.tar differ diff --git a/armbian/armbian-motd b/armbian/armbian-motd new file mode 100644 index 00000000..c22df598 --- /dev/null +++ b/armbian/armbian-motd @@ -0,0 +1,24 @@ +#!/bin/sh +if [ -e /etc/update-motd.d/10-armbian-header ]; then /etc/update-motd.d/10-armbian-header; fi +if [ -e /etc/update-motd.d/30-armbian-sysinfo ]; then /etc/update-motd.d/30-armbian-sysinfo; fi +if [ -e /etc/update-motd.d/41-armbian-config ]; then /etc/update-motd.d/41-armbian-config; fi + +printf " 欢迎使用 One-KVM,基于开源程序 PiKVM 的 IP-KVM 应用 + ____________________________________________________________________________ + + 要阻止内核消息输出到终端,可以使用命令\"dmesg -n 1\" + + 要修改默认账户 admin 的密码可使用命令 \"kvmd-htpasswd set admin\" + + 项目链接: + * https://pikvm.org + * https://github.com/srepac/kvmd-armbian + * https://github.com/mofeng-git/One-KVM + + 文档链接: + * https://docs.pikvm.org + * https://one-kvm.mofeng.run + +" + +if [ -e /etc/motd.custom ]; then cat /etc/motd.custom; fi diff --git a/armbian/opt/armbian-sysinfo b/armbian/opt/armbian-sysinfo new file mode 100644 index 00000000..2e1765b2 --- /dev/null +++ b/armbian/opt/armbian-sysinfo @@ -0,0 +1,206 @@ +#!/bin/bash +# +# Copyright (c) Authors: http://www.armbian.com/authors +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. +# + +# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd +# generate system information + +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +THIS_SCRIPT="sysinfo" +MOTD_DISABLE="" +STORAGE=/dev/sda1 +SHOW_IP_PATTERN="^bond.*|^[ewr].*|^br.*|^lt.*|^umts.*|^lan.*" + +CPU_TEMP_LIMIT=60 +HDD_TEMP_LIMIT=60 +AMB_TEMP_LIMIT=40 + +[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd + +for f in $MOTD_DISABLE; do + [[ $f == $THIS_SCRIPT ]] && exit 0 +done + +# don't edit below here + +function display() { + # $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{ + # battery red color is opposite, lower number + if [[ "$1" == "Battery" ]]; then local great="<"; else local great=">"; fi + if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then + printf "%-14s%s" "$1:" + if awk "BEGIN{exit ! ($2 $great $3)}"; then echo -ne "\e[0;91m $2"; else echo -ne "\e[0;92m $2"; fi + printf "%-1s%s\x1B[0m" "$5" + printf "%-11s%s\t" "$6" + return 1 + fi +} # display + +function getboardtemp() { + if [ -f /etc/armbianmonitor/datasources/soctemp ]; then + read raw_temp /dev/null + if [ ! -z $(echo "$raw_temp" | grep -o "^[1-9][0-9]*\.\?[0-9]*$") ] && (( $(echo "${raw_temp} < 200" |bc -l) )); then + # Allwinner legacy kernels output degree C + board_temp=${raw_temp} + else + board_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp}) + fi + elif [ -f /etc/armbianmonitor/datasources/pmictemp ]; then + # fallback to PMIC temperature + board_temp=$(awk '{printf("%d",$1/1000)}' /dev/null + if [[ "$status_battery_connected" == "1" ]]; then + read status_battery_charging < $mainline_dir/charger/charging + read status_ac_connect < $mainline_dir/ac/connected + read battery_percent< $mainline_dir/battery/capacity + # dispay charging / percentage + if [[ "$status_ac_connect" == "1" && "$battery_percent" -lt "100" ]]; then + status_battery_text=" charging" + elif [[ "$status_ac_connect" == "1" && "$battery_percent" -eq "100" ]]; then + status_battery_text=" charged" + else + status_battery_text=" discharging" + fi + fi + elif [[ -e "$legacy_dir/axp813-ac" ]]; then + read status_battery_connected < $legacy_dir/axp20x-battery/present + if [[ "$status_battery_connected" == "1" ]]; then + status_battery_text=" "$(awk '{print tolower($0)}' < $legacy_dir/axp20x-battery/status) + read status_ac_connect < $legacy_dir/axp813-ac/present + read battery_percent< $legacy_dir/axp20x-battery/capacity + fi + elif [[ -e "$legacy_dir/battery" ]]; then + if [[ (("$(cat $legacy_dir/battery/voltage_now)" -gt "5" )) ]]; then + status_battery_text=" "$(awk '{print tolower($0)}' < $legacy_dir/battery/status) + read battery_percent <$legacy_dir/battery/capacity + fi + fi +} # batteryinfo + +function ambienttemp() { + # define where w1 usually shows up + W1_DIR="/sys/devices/w1_bus_master1/" + if [ -f /etc/armbianmonitor/datasources/ambienttemp ]; then + read raw_temp /dev/null + amb_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp}) + echo $amb_temp + elif [[ -d $W1_DIR && $ONE_WIRE == yes ]]; then + device=$(ls -1 $W1_DIR | grep -Eo '^[0-9]{1,4}' | head -1) + if [[ -n $device ]]; then + if [[ -d ${W1_DIR}${device}/hwmon/hwmon0 ]]; then hwmon=0; else hwmon=1; fi + read raw_temp < ${W1_DIR}${device}/hwmon/hwmon${hwmon}/temp1_input 2>/dev/null + amb_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp}) + echo $amb_temp + fi + else + # read ambient temperature from USB device if available + if [[ ! -f /usr/bin/temper ]]; then + echo "" + return + fi + amb_temp=$(temper -c 2>/dev/null) + case ${amb_temp} in + *"find the USB device"*) + echo "" + ;; + *) + amb_temp=$(awk '{print $NF}' <<<$amb_temp | sed 's/C//g') + echo -n "scale=1;${amb_temp}/1" | grep -oE "\-?[[:digit:]]+\.[[:digit:]]" + esac + fi +} # ambienttemp + +function get_ip_addresses() { + local ips=() + for f in /sys/class/net/*; do + local intf=$(basename $f) + # match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra format) + if [[ $intf =~ $SHOW_IP_PATTERN ]]; then + local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1) + # add both name and IP - can be informative but becomes ugly with long persistent/predictable device names + #[[ -n $tmp ]] && ips+=("$intf: $tmp") + # add IP only + [[ -n $tmp ]] && ips+=("$tmp") + fi + done + echo "${ips[@]}" +} # get_ip_addresses + +function storage_info() { + # storage info + RootInfo=$(df -h /) + root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g') + root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo}) + StorageInfo=$(df -h $STORAGE 2>/dev/null | grep $STORAGE) + if [[ -n "${StorageInfo}" && ${RootInfo} != *$STORAGE* ]]; then + storage_usage=$(awk '/\// {print $(NF-1)}' <<<${StorageInfo} | sed 's/%//g') + storage_total=$(awk '/\// {print $(NF-4)}' <<<${StorageInfo}) + if [[ -n "$(command -v smartctl)" ]]; then + DISK="${STORAGE::-1}" + storage_temp+=$(sudo smartctl -A $DISK 2> /dev/null | grep -i temperature | awk '{print $(NF-2)}') + fi + fi +} # storage_info + + + +# query various systems and send some stuff to the background for overall faster execution. +# Works only with ambienttemp and batteryinfo since A20 is slow enough :) +amb_temp=$(ambienttemp &) +ip_address=$(get_ip_addresses &) +batteryinfo +storage_info +getboardtemp +critical_load=80 + +# get uptime, logged in users and load in one take +UPTIME=$(LC_ALL=C uptime) +UPT1=${UPTIME#*'up '} +UPT2=${UPT1%'user'*} +users=${UPT2//*','} +users=${users//' '} +time=${UPT2%','*} +time=${time//','} +time=$(echo $time | xargs) +load=${UPTIME#*'load average: '} +load=${load//','} +load=$(echo $load | cut -d" " -f1) +[[ $load == 0.0* ]] && load=0.10 +cpucount=$(grep -c processor /proc/cpuinfo) + +load=$(awk '{printf("%.0f",($1/$2) * 100)}' <<< "$load $cpucount") + +# memory and swap +mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem") +memory_usage=$(awk '{printf("%.0f",(($2-($4+$6+$7))/$2) * 100)}' <<<${mem_info}) +mem_info=$(echo $mem_info | awk '{print $2}') +memory_total=$(( mem_info / 1024 )) +swap_info=$(LC_ALL=C free -m | grep "^Swap") +swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]') +swap_total=$(awk '{print $(2)}' <<<${swap_info}) +if [[ ${memory_total} -gt 1000 ]]; then + memory_total=$(awk '{printf("%.2f",$1/1024)}' <<<${memory_total})"G" +else + memory_total+="M" +fi + +if [[ ${swap_total} -gt 500 ]]; then + swap_total=$(awk '{printf("%.2f",$1/1024)}' <<<${swap_total})"G" +else + swap_total+="M" +fi + diff --git a/armbian/opt/vcgencmd b/armbian/opt/vcgencmd new file mode 100644 index 00000000..0c58e00b --- /dev/null +++ b/armbian/opt/vcgencmd @@ -0,0 +1,70 @@ +#!/bin/bash +cd `dirname $0` +source armbian-sysinfo + +case $1 in + get_throttled) echo "throttled=0x0";; +# measure_temp) echo "temp=$board_temp'C";; + get_config) + case $2 in + total_mem) + NUM=$( free -m | grep Mem: | awk '{print $2}' ) + if [ -e /var/log/dmesg ]; then + KB=$( sudo grep 'Memory:' /var/log/dmesg | awk '{print $5}' | cut -d'/' -f2 | sed 's/K//g' | head -1 ) + else + KB="" + fi + + if [[ "$KB" == "" ]]; then + GB=`echo "( $NUM + 256 ) / 256" | bc` + MB=$( echo "${GB} * 256" | bc ) + else + GB=$( echo "($KB + 2048) / 1024 / 256" | bc ) + MB=$( echo "${GB} * 256" | bc ) + fi + echo "total_mem=$MB" + ;; + *) + echo "invalid option";; + esac + ;; + measure_clock) + case ${2} in + arm) + # awk is probably overkill.... + value=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq | awk '{print $1 * 1000}'` + echo 'frequency(45)='${value} + exit + ;; + core) + value=0 # TODO / FIXME + echo 'frequency(1)='${value} + exit + ;; + # TODO anything else thrown an error/debug + esac + exit + ;; + measure_temp) + # awk is probably overkill.... + value=`cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1 / 1000}'` + echo 'temp='${value}"'C" + exit + ;; + measure_volts) + case ${2} in + core) + value=1 # TODO / FIXME + echo 'volt='${value}'.0000V' + exit + ;; + # TODO anything else thrown an error/debug + esac + ;; + version) + echo 'Nov 4 2018 16:31:07' + echo 'Copyright (c) 2012 rock64' + echo 'version rock64_TODO (clean) (release)' + exit + ;; +esac diff --git a/armbian/udev/rules.d/99-kvmd.rules b/armbian/udev/rules.d/99-kvmd.rules new file mode 100644 index 00000000..84424180 --- /dev/null +++ b/armbian/udev/rules.d/99-kvmd.rules @@ -0,0 +1,6 @@ +# https://unix.stackexchange.com/questions/66901/how-to-bind-usb-device-under-a-static-name +# https://wiki.archlinux.org/index.php/Udev#Setting_static_device_names +KERNEL=="video[1-9]*", SUBSYSTEM=="video4linux", PROGRAM="/usr/bin/kvmd-udev-hdmiusb-check rpi4 1-1.4:1.0", ATTR{index}=="0", GROUP="kvmd", SYMLINK+="kvmd-video" +KERNEL=="hidg0", GROUP="kvmd", SYMLINK+="kvmd-hid-keyboard" +KERNEL=="hidg1", GROUP="kvmd", SYMLINK+="kvmd-hid-mouse" +KERNEL=="hidg2", GROUP="kvmd", SYMLINK+="kvmd-hid-mouse-alt" diff --git a/config/override.yaml b/conf/override-onecloud.yaml similarity index 89% rename from config/override.yaml rename to conf/override-onecloud.yaml index bf5f6a6e..bfe3f654 100644 --- a/config/override.yaml +++ b/conf/override-onecloud.yaml @@ -16,8 +16,13 @@ vnc: vncauth: enabled: true # Enable auth via /etc/kvmd/vncpasswd kvmd: + hid: + mouse_alt: + device: /dev/kvmd-hid-mouse-alt # allow relative mouse mode msd: type: disabled + atx: + type: disabled gpio: drivers: wol_server1: @@ -47,7 +52,7 @@ kvmd: switch: false view: header: - title: ATX + title: 电源管理 table: - ["#电源管理"] - [] @@ -57,9 +62,11 @@ kvmd: - ["#网络唤醒"] - ["#被控机设备", wol_server1|网络唤醒] streamer: - forever: true + #forever: true cmd_append: [--slowdown] + resolution: + default: 1280x720 desired_fps: default: 30 max: 60 - min: 0 + min: 0 \ No newline at end of file diff --git a/config/main.yaml b/config/main.yaml deleted file mode 100644 index 664a0471..00000000 --- a/config/main.yaml +++ /dev/null @@ -1,62 +0,0 @@ -# Don't touch this file otherwise your device may stop working. -# Use override.yaml to modify required settings. -# You can find a working configuration in /usr/share/kvmd/configs.default/kvmd. - -override: !include [override.d, override.yaml] - -logging: !include logging.yaml - -kvmd: - auth: !include auth.yaml - - hid: - type: otg - mouse_alt: - device: /dev/kvmd-hid-mouse-alt - - atx: - type: disabled - - msd: - type: otg - - streamer: - quality: 0 - resolution: - default: 1280x720 - available: - - 1920x1080 - - 1600x1200 - - 1360x768 - - 1280x1024 - - 1280x960 - - 1280x720 - - 1024x768 - - 800x600 - - 720x576 - - 720x480 - - 640x480 - cmd: - - "/usr/bin/ustreamer" - - "--device=/dev/kvmd-video" - - "--persistent" - - "--format=mjpeg" - - "--resolution={resolution}" - - "--desired-fps={desired_fps}" - - "--drop-same-frames=30" - - "--last-as-blank=0" - - "--unix={unix}" - - "--unix-rm" - - "--unix-mode=0660" - - "--exit-on-parent-death" - - "--process-name-prefix={process_name_prefix}" - - "--notify-parent" - - "--no-log-colors" - - "--sink=kvmd::ustreamer::jpeg" - - "--sink-mode=0660" - - -vnc: - memsink: - jpeg: - sink: "kvmd::ustreamer::jpeg" diff --git a/fruity-pikvm_0.2_armhf.deb b/fruity-pikvm_0.2_armhf.deb deleted file mode 100644 index bfebf0d0..00000000 Binary files a/fruity-pikvm_0.2_armhf.deb and /dev/null differ diff --git a/install-x86.sh b/install-x86.sh new file mode 100644 index 00000000..d01cf27a --- /dev/null +++ b/install-x86.sh @@ -0,0 +1,864 @@ +#!/bin/bash +# https://github.com/srepac/kvmd-armbian +# modified by SilentWind 2024-06-17 +# modified by xe5700 2021-11-04 xe5700@outlook.com +# modified by NewbieOrange 2021-11-04 +# created by @srepac 08/09/2021 srepac@kvmnerds.com +# Scripted Installer of Pi-KVM on x86 (as long as it's running python 3.10 or higher) +# +# *** MSD is disabled by default *** +# +# Mass Storage Device requires the use of a USB thumbdrive or SSD and will need to be added in /etc/fstab +: ' +# SAMPLE /etc/fstab entry for USB drive with only one partition formatted as ext4 for the entire drive: + +/dev/sda1 /var/lib/kvmd/msd ext4 nodev,nosuid,noexec,ro,errors=remount-ro,data=journal,X-kvmd.otgmsd-root=/var/lib/kvmd/msd,X-kvmd.otgmsd-user=kvmd 0 0 + +' +# NOTE: This was tested on a new install of raspbian desktop and lite versions, but should also work on an existing install. +# +# Last change 20240526 2345 PDT +VER=3.4 +set +x +PIKVMREPO="https://files.pikvm.org/repos/arch/rpi4" +KVMDFILE="kvmd-3.291-1-any.pkg.tar.xz" +KVMDCACHE="/var/cache/kvmd"; mkdir -p $KVMDCACHE +PKGINFO="${KVMDCACHE}/packages.txt" +APP_PATH=$(readlink -f $(dirname $0)) +LOGFILE="${KVMDCACHE}/installer.log"; touch $LOGFILE; echo "==== $( date ) ====" >> $LOGFILE + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + echo "usage: $0 [-f] where -f will force re-install new pikvm platform" + exit 1 +fi + +CWD=`pwd` + +WHOAMI=$( whoami ) +if [ "$WHOAMI" != "root" ]; then + echo "$WHOAMI, please run script as root." + exit 1 +fi + +PYTHONVER=$( python3 -V | cut -d' ' -f2 | cut -d'.' -f1,2 ) +case $PYTHONVER in + 3.10|3.11) + echo "Python $PYTHONVER is supported." | tee -a $LOGFILE + ;; + *) + echo "Python $PYTHONVER is NOT supported. Please make sure you have python3.10 or higher installed. Exiting." | tee -a $LOGFILE + exit 1 + ;; +esac + +MAKER=$(tr -d '\0' < /proc/device-tree/model | awk '{print $1}') + + +gen-ssl-certs() { + cd /etc/kvmd/nginx/ssl + openssl ecparam -out server.key -name prime256v1 -genkey + openssl req -new -x509 -sha256 -nodes -key server.key -out server.crt -days 3650 \ + -subj "/C=US/ST=Denial/L=Denial/O=Pi-KVM/OU=Pi-KVM/CN=$(hostname)" + cp server* /etc/kvmd/vnc/ssl/ + cd ${APP_PATH} +} # end gen-ssl-certs + + +create-override() { + if [ $( grep ^kvmd: /etc/kvmd/override.yaml | wc -l ) -eq 0 ]; then + + if [[ $( echo $platform | grep usb | wc -l ) -eq 1 ]]; then + cat <> /etc/kvmd/override.yaml +kvmd: + hid: + ### add entries for use with the ch9329 serial HID + type: ch9329 + speed: 9600 # default speed after loading ch9329 plugin is 9600 + device: /dev/kvmd-hid + msd: + type: disabled + atx: + type: disabled + streamer: + #forever: true + cmd_append: + - "--slowdown" # so target doesn't have to reboot + resolution: + default: 1280x720 +USBOVERRIDE + + else + + cat <> /etc/kvmd/override.yaml +kvmd: + hid: + ### add entries for use with the ch9329 serial HID + type: ch9329 + speed: 9600 # default speed after loading ch9329 plugin is 9600 + device: /dev/kvmd-hid + msd: + type: disabled + streamer: + #forever: true + cmd_append: + - "--slowdown" # so target doesn't have to reboot +CSIOVERRIDE + + fi + + fi +} # end create-override + +install-python-packages() { + echo "apt install -y python3-aiofiles python3-aiohttp python3-appdirs python3-asn1crypto python3-async-timeout + python3-bottle python3-cffi python3-chardet python3-click python3-colorama python3-cryptography python3-dateutil + python3-dbus python3-dev python3-hidapi python3-idna python3-libgpiod python3-mako python3-marshmallow + python3-more-itertools python3-multidict python3-netifaces python3-packaging python3-passlib python3-pillow + python3-ply python3-psutil python3-pycparser python3-pyelftools python3-pyghmi python3-pygments python3-pyparsing + python3-requests python3-semantic-version python3-setproctitle python3-setuptools python3-six python3-spidev + python3-systemd python3-tabulate python3-urllib3 python3-wrapt python3-xlib python3-yaml python3-yarl python3-build + python3-pyotp python3-qrcode python3-serial" + apt install -y python3-aiofiles python3-aiohttp python3-appdirs python3-asn1crypto python3-async-timeout\ + python3-bottle python3-cffi python3-chardet python3-click python3-colorama python3-cryptography python3-dateutil\ + python3-dbus python3-dev python3-hidapi python3-idna python3-libgpiod python3-mako python3-marshmallow\ + python3-more-itertools python3-multidict python3-netifaces python3-packaging python3-passlib python3-pillow\ + python3-ply python3-psutil python3-pycparser python3-pyelftools python3-pyghmi python3-pygments python3-pyparsing\ + python3-requests python3-semantic-version python3-setproctitle python3-setuptools python3-six python3-spidev\ + python3-systemd python3-tabulate python3-urllib3 python3-wrapt python3-xlib python3-yaml python3-yarl python3-build\ + python3-pyotp python3-qrcode python3-serial >> $LOGFILE +} # end install python-packages + +otg-devices() { + modprobe libcomposite + if [ ! -e /sys/kernel/config/usb_gadget/kvmd ]; then + mkdir -p /sys/kernel/config/usb_gadget/kvmd/functions + cd /sys/kernel/config/usb_gadget/kvmd/functions + mkdir hid.usb0 hid.usb1 hid.usb2 mass_storage.usb0 + fi + cd ${APP_PATH} +} # end otg-device creation + +boot-files() { + # Remove OTG serial (Orange pi zero's kernel not support it) + sed -i '/^g_serial/d' /etc/modules + + # /etc/modules required entries for DWC2, HID and I2C + if [[ $( grep -w dwc2 /etc/modules | wc -l ) -eq 0 ]]; then + echo "dwc2" >> /etc/modules + fi + if [[ $( grep -w libcomposite /etc/modules | wc -l ) -eq 0 ]]; then + echo "libcomposite" >> /etc/modules + fi + if [[ $( grep -w i2c-dev /etc/modules | wc -l ) -eq 0 ]]; then + echo "i2c-dev" >> /etc/modules + fi + + printf "\n/etc/modules\n\n" | tee -a $LOGFILE + cat /etc/modules | tee -a $LOGFILE +} # end of necessary boot files + +get-packages() { + printf "\n\n-> Getting Pi-KVM packages from ${PIKVMREPO}\n\n" | tee -a $LOGFILE + cp -f ${APP_PATH}/kvmd-packages/* ${KVMDCACHE} + + } # end get-packages function + +get-platform() { + platform="kvmd-platform-v0-hdmiusb-rpi3"; + echo + echo "Platform selected -> $platform" | tee -a $LOGFILE + echo +} # end get-platform + +install-kvmd-pkgs() { + cd / + + INSTLOG="${KVMDCACHE}/installed_ver.txt"; rm -f $INSTLOG + date > $INSTLOG + +# uncompress platform package first + i=$( ls ${KVMDCACHE}/${platform}*.tar.xz | grep 3.291 ) + + # change the log entry to show 3.291 platform installed as we'll be forcing kvmd-3.291 instead of latest/greatest kvmd + _platformver=$( echo $i | sed -e 's/3\.29[2-9]*/3.291/g' -e 's/3\.3[0-9]*/3.291/g' ) + echo "-> Extracting package $_platformver into /" | tee -a $INSTLOG + tar xfJ $i + +# then uncompress, kvmd-{version}, kvmd-webterm, and janus packages + for i in $( ls ${KVMDCACHE}/*.tar.xz | egrep 'kvmd-[0-9]|webterm' ) + do + case $i in + *kvmd-3.29[2-9]*|*kvmd-3.[3-9]*|*kvmd-[45].[1-9]*) # if latest/greatest is 3.292 and higher, then force 3.291 install + echo "*** Force install kvmd 3.291 ***" | tee -a $LOGFILE + i=$KVMDCACHE/$KVMDFILE + ;; + *) + ;; + esac + + echo "-> Extracting package $i into /" >> $INSTLOG + tar xfJ $i + done + + # uncompress janus package if /usr/bin/janus doesn't exist + if [ ! -e /usr/bin/janus ]; then + i=$( ls ${KVMDCACHE}/*.tar.xz | egrep janus | grep -v 1x ) + echo "-> Extracting package $i into /" >> $INSTLOG + tar xfJ $i + + else # confirm that /usr/bin/janus actually runs properly + /usr/bin/janus --version > /dev/null 2>> $LOGFILE + if [ $? -eq 0 ]; then + echo "You have a working valid janus binary." | tee -a $LOGFILE + else # error status code, so uncompress from REPO package + i=$( ls ${KVMDCACHE}/*.tar.xz | egrep janus ) + echo "-> Extracting package $i into /" >> $INSTLOG + tar xfJ $i + fi + fi + + cd ${APP_PATH} +} # end install-kvmd-pkgs + +fix-udevrules() { + # for hdmiusb, replace %b with 1-1.4:1.0 in /etc/udev/rules.d/99-kvmd.rules + sed -i -e 's+\%b+1-1.4:1.0+g' -e 's+ttyAMA0+ttyUSB[0-2]+g' /etc/udev/rules.d/99-kvmd.rules | tee -a $LOGFILE + echo + cat /etc/udev/rules.d/99-kvmd.rules | tee -a $LOGFILE +} # end fix-udevrules + +enable-kvmd-svcs() { + # enable KVMD services but don't start them + echo "-> Enabling $SERVICES services, but do not start them." | tee -a $LOGFILE + systemctl enable $SERVICES +} # end enable-kvmd-svcs + +build-ustreamer() { + printf "\n\n-> Building ustreamer\n\n" | tee -a $LOGFILE + # Install packages needed for building ustreamer source + echo "apt install -y libevent-dev libjpeg-dev libbsd-dev libgpiod-dev libsystemd-dev janus-dev janus" | tee -a $LOGFILE + apt install -y libevent-dev libjpeg-dev libbsd-dev libgpiod-dev libsystemd-dev janus-dev janus >> $LOGFILE + + # fix refcount.h + sed -i -e 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h + + # Download ustreamer source and build it + cd /tmp + unzip ${APP_PATH}/sources/ustreamer-6.12.zip + cd ustreamer-6.12/ + #添加WITH_PYTHON=1 ,使kvmd-vnc正常工作 + make WITH_GPIO=1 WITH_SYSTEMD=1 WITH_JANUS=1 WITH_PYTHON=1 -j + #删除 --prefix=$(PREFIX) ,修复无法安装pythgon包的问题 + sed -i 's/--prefix=\$(PREFIX)//g' python/Makefile + make install WITH_PYTHON=1 + # kvmd service is looking for /usr/bin/ustreamer + ln -sf /usr/local/bin/ustreamer* /usr/bin/ + + # add janus support + mkdir -p /usr/lib/ustreamer/janus + cp /tmp/ustreamer-6.12/janus/libjanus_ustreamer.so /usr/lib/ustreamer/janus +} # end build-ustreamer + +install-dependencies() { + echo + echo "-> Installing dependencies for pikvm" | tee -a $LOGFILE + + echo "apt install -y make nginx python3 gcc unzip net-tools bc expect v4l-utils iptables vim dos2unix screen tmate nfs-common gpiod ffmpeg dialog iptables dnsmasq git python3-pip tesseract-ocr tesseract-ocr-eng libasound2-dev libsndfile-dev libspeexdsp-dev build-essential libssl-dev libffi-dev lm-sensors" | tee -a $LOGFILE + apt install -y make nginx python3 gcc unzip net-tools bc expect v4l-utils iptables vim dos2unix screen tmate nfs-common gpiod ffmpeg dialog iptables dnsmasq git python3-pip tesseract-ocr tesseract-ocr-eng libasound2-dev libsndfile-dev libspeexdsp-dev build-essential libssl-dev libffi-dev lm-sensors >> $LOGFILE + + sed -i -e 's/#port=5353/port=5353/g' /etc/dnsmasq.conf + + install-python-packages + + + + echo "-> Make tesseract data link" | tee -a $LOGFILE + ln -sf /usr/share/tesseract-ocr/*/tessdata /usr/share/tessdata + + echo "-> Install TTYD" | tee -a $LOGFILE + apt install -y ttyd | tee -a $LOGFILE + /usr/bin/ttyd -v | tee -a $LOGFILE + + if [ ! -e /usr/local/bin/gpio ]; then + printf "\n\n-> Building wiringpi from source\n\n" | tee -a $LOGFILE + cd /tmp; rm -rf WiringPi-3.6 + unzip ${APP_PATH}/sources/WiringPi-3.6.zip + cd WiringPi-3.6 + ./build + else + printf "\n\n-> Wiringpi (gpio) is already installed.\n\n" | tee -a $LOGFILE + fi + gpio -v | tee -a $LOGFILE + + echo "-> Install ustreamer" | tee -a $LOGFILE + if [ ! -e /usr/bin/ustreamer ]; then + cd /tmp + ### required dependent packages for ustreamer ### + build-ustreamer + cd ${APP_PATH} + fi + echo -n "ustreamer version: " | tee -a $LOGFILE + ustreamer -v | tee -a $LOGFILE + ustreamer --features | tee -a $LOGFILE +} # end install-dependencies + +python-pkg-dir() { + # debian system python3 no alias + # create quick python script to show where python packages need to go + cat << MYSCRIPT > /tmp/syspath.py +#!$(which python3) +import sys +print (sys.path) +MYSCRIPT + + chmod +x /tmp/syspath.py + + #PYTHONDIR=$( /tmp/syspath.py | awk -F, '{print $NF}' | cut -d"'" -f2 ) + ### hardcode path for armbian/raspbian + PYTHONDIR="/usr/lib/python3/dist-packages" +} # end python-pkg-dir + +fix-nginx-symlinks() { + # disable default nginx service since we will use kvmd-nginx instead + echo + echo "-> Disabling nginx service, so that we can use kvmd-nginx instead" | tee -a $LOGFILE + systemctl disable --now nginx + + # setup symlinks + echo + echo "-> Creating symlinks for use with kvmd python scripts" | tee -a $LOGFILE + if [ ! -e /usr/bin/nginx ]; then ln -sf /usr/sbin/nginx /usr/bin/; fi + if [ ! -e /usr/sbin/python ]; then ln -sf /usr/bin/python3 /usr/sbin/python; fi + if [ ! -e /usr/bin/iptables ]; then ln -sf /usr/sbin/iptables /usr/bin/iptables; fi + if [ ! -e /usr/bin/vcgencmd ]; then ln -sf /opt/vc/bin/* /usr/bin/; chmod +x /opt/vc/bin/*; fi + + python-pkg-dir + + if [ ! -e $PYTHONDIR/kvmd ]; then + # Debian python版本比 pikvm官方的低一些 + # in case new kvmd packages are now using python 3.11 + ln -sf /usr/lib/python3.1*/site-packages/kvmd* ${PYTHONDIR} + fi +} # end fix-nginx-symlinks + +fix-python-symlinks(){ + python-pkg-dir + + if [ ! -e $PYTHONDIR/kvmd ]; then + # Debian python版本比 pikvm官方的低一些 + ln -sf /usr/lib/python3.1*/site-packages/kvmd* ${PYTHONDIR} + fi +} + +apply-custom-patch(){ + read -p "Do you want apply old kernel msd patch? [y/n]" answer + case $answer in + n|N|no|No) + echo 'You skipped this patch.' + ;; + y|Y|Yes|yes) + ./patches/custom/old-kernel-msd/apply.sh + ;; + *) + echo "Try again.";; + esac +} + + +fix-webterm() { + echo + echo "-> Creating kvmd-webterm homedir" | tee -a $LOGFILE + mkdir -p /home/kvmd-webterm + chown kvmd-webterm /home/kvmd-webterm + ls -ld /home/kvmd-webterm | tee -a $LOGFILE + + # remove -W option since ttyd installed on raspbian/armbian is 1.6.3 (-W option only works with ttyd 1.7.x) + _ttydver=$( /usr/bin/ttyd -v | awk '{print $NF}' ) + case $_ttydver in + 1.6*) + echo "ttyd $_ttydver found. Removing -W from /lib/systemd/system/kvmd-webterm.service" + sed -i -e '/-W \\/d' /lib/systemd/system/kvmd-webterm.service + ;; + 1.7*) + echo "ttyd $_ttydver found. Nothing to do." + ;; + esac + + # add sudoers entry for kvmd-webterm user to be able to run sudo + echo "kvmd-webterm ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/kvmd-webterm; chmod 440 /etc/sudoers.d/kvmd-webterm +} # end fix-webterm + +create-kvmdfix() { + # Create kvmd-fix service and script + cat < /lib/systemd/system/kvmd-fix.service +[Unit] +Description=KVMD Fixes +After=network.target network-online.target nss-lookup.target +Before=kvmd.service + +[Service] +User=root +Type=simple +ExecStart=/usr/bin/kvmd-fix + +[Install] +WantedBy=multi-user.target +ENDSERVICE + + cat < /usr/bin/kvmd-fix +#!/bin/bash +# Written by @srepac +# 1. Properly set group ownership of /dev/gpio* +# 2. fix /dev/kvmd-video symlink to point to /dev/video1 (Amglogic Device video0 is not usb device) +# +### These fixes are required in order for kvmd service to start properly +# +set -x + chgrp gpio /dev/gpio* + chmod 660 /dev/gpio* + ls -l /dev/gpio* + +udevadm trigger +ls -l /dev/kvmd-video + +if [ \$( systemctl | grep kvmd-oled | grep -c activ ) -eq 0 ]; then + echo "kvmd-oled service is not enabled." + exit 0 +else + echo "kvmd-oled service is enabled and activated." +fi + +### kvmd-oled fix: swap i2c-0 <-> i2c-1 (code is looking for I2C oled on i2c-1) +# pins #1 - 3.3v, #3 - SDA, #5 - SCL, and #9 - GND +i2cget -y 0 0x3c +if [ \$? -eq 0 ]; then + echo "-> Found valid I2C OLED at i2c-0. Applying I2C OLED fix." + cd /dev + + # rename i2c-0 -> i2c-9, move i2c-1 to i2c-0, and rename the good i2c-9 to i2c-1 + mv i2c-0 i2c-9 + mv i2c-1 i2c-0 + mv i2c-9 i2c-1 + + # restart kvmd-oled service + systemctl restart kvmd-oled +else + echo "-> I2C OLED fix already applied and OLED should be showing info." +fi +SCRIPTEND + + chmod +x /usr/bin/kvmd-fix + + cat << CHRESET > /root/ch_reset.py +#!/usr/bin/python3 +import serial +import time + +device_path = "/dev/kvmd-hid" + +chip = serial.Serial(device_path, 9600, timeout=1) + +command = [87, 171, 0, 15, 0] +sum = sum(command) % 256 +command.append(sum) + +print("Resetting CH9329") + +chip.write(serial.to_bytes(command)) + +time.sleep(2) + +data = list(chip.read(5)) + +print("Initial data:", data) + +if data[4] : + more_data = list(chip.read(data[4])) + data.extend(more_data) + +print("Output: ", data) + + +chip.close() +CHRESET + + chmod +x /root/ch_reset.py +} # end create-kvmdfix + +set-ownership() { + # set proper ownership of password files and kvmd-webterm homedir + cd /etc/kvmd + chown kvmd:kvmd htpasswd + chown kvmd-ipmi:kvmd-ipmi ipmipasswd + chown kvmd-vnc:kvmd-vnc vncpasswd + chown kvmd-webterm /home/kvmd-webterm + + # add kvmd user to video group (this is required in order to use CSI bridge with OMX and h264 support) + usermod -a -G video kvmd + + # add kvmd user to dialout group (required for xh_hk4401 kvm switch support) + usermod -a -G dialout kvmd +} # end set-ownership + +check-kvmd-works() { + echo "-> Checking kvmd -m works before continuing" | tee -a $LOGFILE + kvmd -m + invalid=1 + ! $NOTCHROOT || while [ $invalid -eq 1 ]; do + #kvmd -m + read -p "Did kvmd -m run properly? [y/n] " answer + case $answer in + n|N|no|No) + echo "Please install missing packages as per the kvmd -m output in another ssh/terminal." + ;; + y|Y|Yes|yes) + invalid=0 + ;; + *) + echo "Try again.";; + esac + done +} # end check-kvmd-works + +start-kvmd-svcs() { + #### start the main KVM services in order #### + # 1. nginx is the webserver + # 2. kvmd-otg is for OTG devices (keyboard/mouse, etc..) + # 3. kvmd is the main daemon + systemctl daemon-reload + systemctl restart $SERVICES +} # end start-kvmd-svcs + +fix-motd() { + if [ -e /etc/motd ]; then rm /etc/motd; fi + cp armbian/armbian-motd /usr/bin/ + chmod +x /usr/bin/armbian-motd + chmod +x /etc/update-motd.d/* + sed -i 's/cat \/etc\/motd/armbian-motd/g' /lib/systemd/system/kvmd-webterm.service + systemctl daemon-reload + # systemctl restart kvmd-webterm +} # end fix-motd + +# 安装armbian的包 +armbian-packages() { + mkdir -p /opt/vc/bin/ + #cd /opt/vc/bin + if [ ! -e /usr/bin/vcgencmd ]; then + # Install vcgencmd for armbian platform + cp -rf armbian/opt/* /opt/vc/bin + else + ln -s /usr/bin/vcgencmd /opt/vc/bin/ + fi + #cp -rf armbian/udev /etc/ + + cd ${APP_PATH} +} # end armbian-packages + +fix-nfs-msd() { + NAME="aiofiles.tar" + + LOCATION="/usr/lib/python3.11/site-packages" + echo "-> Extracting $NAME into $LOCATION" | tee -a $LOGFILE + tar xvf $NAME -C $LOCATION + + echo "-> Renaming original aiofiles and creating symlink to correct aiofiles" | tee -a $LOGFILE + cd /usr/lib/python3/dist-packages + mv aiofiles aiofiles.$(date +%Y%m%d.%H%M) + ln -s $LOCATION/aiofiles . + ls -ld aiofiles* | tail -5 +} + + +apply-x86-mods() { + TARBALL="${APP_PATH}/x86-mods.tar" + + if [ -e $TARBALL ]; then + echo "-> Making backup of files that require modification" | tee -a $LOGFILE + for i in $( tar tf $TARBALL ); do + echo "cp $PYTHONDIR/$i $PYTHONDIR/$i.orig" | tee -a $LOGFILE + cp $PYTHONDIR/$i $PYTHONDIR/$i.orig + done + tar tvf $TARBALL + + echo "tar xvf $TARBALL -C $PYTHONDIR" | tee -a $LOGFILE + tar xvf $TARBALL -C $PYTHONDIR + + for i in $( tar tf $TARBALL ); do + ls -l $PYTHONDIR/$i + done + else + echo "Missing $TARBALL. Please obtain the tar file from @srepac and try again." | tee -a $LOGFILE + fi +} + +fix-nginx() { + #set -x + KERNEL=$( uname -r | awk -F\- '{print $1}' ) + ARCH=$( uname -r | awk -F\- '{print $NF}' ) + echo "KERNEL: $KERNEL ARCH: $ARCH" | tee -a $LOGFILE + case $ARCH in + ARCH) SEARCHKEY=nginx-mainline;; + *) SEARCHKEY="nginx/";; + esac + + HTTPSCONF="/etc/kvmd/nginx/listen-https.conf" + echo "HTTPSCONF BEFORE: $HTTPSCONF" | tee -a $LOGFILE + cat $HTTPSCONF | tee -a $LOGFILE + + if [[ ! -e /usr/local/bin/pikvm-info || ! -e /tmp/pacmanquery ]]; then + cp -f ${APP_PATH}/pikvm-info /usr/local/bin/pikvm-info + chmod +x /usr/local/bin/pikvm-info + echo "Getting list of packages installed..." | tee -a $LOGFILE + pikvm-info > /dev/null ### this generates /tmp/pacmanquery with list of installed pkgs + fi + + NGINXVER=$( grep $SEARCHKEY /tmp/pacmanquery | awk '{print $1}' | cut -d'.' -f1,2 ) + echo + echo "NGINX version installed: $NGINXVER" | tee -a $LOGFILE + + case $NGINXVER in + 1.2[56789]|1.3*|1.4*|1.5*) # nginx version 1.25 and higher + cat << NEW_CONF > $HTTPSCONF +listen 443 ssl; +listen [::]:443 ssl; +http2 on; +NEW_CONF + ;; + + 1.18|*) # nginx version 1.18 and lower + cat << ORIG_CONF > $HTTPSCONF +listen 443 ssl http2; +listen [::]:443 ssl; +ORIG_CONF + ;; + + esac + + echo "HTTPSCONF AFTER: $HTTPSCONF" | tee -a $LOGFILE + cat $HTTPSCONF | tee -a $LOGFILE + set +x +} # end fix-nginx + +ocr-fix() { # create function + echo + echo "-> Apply OCR fix..." | tee -a $LOGFILE + + # 1. verify that Pillow module is currently running 9.0.x + PILLOWVER=$( pip3 list | grep -i pillow | awk '{print $NF}' ) + + case $PILLOWVER in + 9.*|8.*|7.*) # Pillow running at 9.x and lower + # 2. update Pillow to 10.0.0 + pip3 install -U Pillow 2>> $LOGFILE + + # 3. check that Pillow module is now running 10.0.0 + pip3 list | grep -i pillow | tee -a $LOGFILE + + #4. restart kvmd and confirm OCR now works. + systemctl restart kvmd + ;; + + 10.*|11.*|12.*) # Pillow running at 10.x and higher + echo "Already running Pillow $PILLOWVER. Nothing to do." | tee -a $LOGFILE + ;; + + esac + + set +x + echo +} # end ocr-fix + +x86-fix-3.256() { + echo "-> Apply x86-fix for 3.256 and higher..." | tee -a $LOGFILE + cd /usr/lib/python3/dist-packages/kvmd/apps/ + cp __init__.py __init__.py.$( date +%Y%m%d ) + cp -f ${APP_PATH}/patches/__init__.py __init__.py + #mv __init__.py.1 __init__.py + + cd /usr/share/kvmd/web/share/js + if [ -e session.js ]; then + cp session.js session.js.$( date +%Y%m%d ) + fi + cp -f ${APP_PATH}/patches/session.js session.js + if [ -e session.js.1 ]; then + mv session.js.1 session.js + fi + + cd /usr/lib/python3/dist-packages/kvmd/apps/kvmd/info/ + cp hw.py hw.py.$( date +%Y%m%d ) + #wget --no-check-certificate https://raw.githubusercontent.com/pikvm/kvmd/cec03c4468df87bcdc68f20c2cf51a7998c56ebd/kvmd/apps/kvmd/info/hw.py 2> /dev/null + #mv hw.py.1 hw.py + cp -f ${APP_PATH}/patches/hw.py hw.py + + cp -f ${APP_PATH}patches/main.yaml /etc/kvmd/ + +} # end x86-fix-3.256 + +x86-fix-3.281() { + echo "-> Apply x86-fix for 3.281 and higher..." | tee -a $LOGFILE + cd /usr/lib/python3/dist-packages/kvmd/apps/ + cp __init__.py __init__.py.$( date +%Y%m%d ) + cp -f ${APP_PATH}/patches/__init__.py.2 __init__.py + + cd /usr/lib/python3/dist-packages/kvmd/apps/kvmd + cp -f ${APP_PATH}/patches/streamer.py.1 streamer.py +} # end x86-fix-3.281 + +update-logo() { + sed -i -e 's|class="svg-gray"|class="svg-color"|g' /usr/share/kvmd/web/index.html + sed -i -e 's|target="_blank">> $LOGFILE + printf "\nReboot is required to create kvmd users and groups.\nPlease re-run this script after reboot to complete the install.\n" | tee -a $LOGFILE + + # Fix paste-as-keys if running python 3.7 + if [[ $( python3 -V | awk '{print $2}' | cut -d'.' -f1,2 ) == "3.7" ]]; then + sed -i -e 's/reversed//g' /usr/lib/python3.1*/site-packages/kvmd/keyboard/printer.py + fi + + ### run these to make sure kvmd users are created ### + echo "-> Ensuring KVMD users and groups ..." | tee -a $LOGFILE + systemd-sysusers /usr/lib/sysusers.d/kvmd.conf + systemd-sysusers /usr/lib/sysusers.d/kvmd-webterm.conf + + # Ask user to press CTRL+C before reboot or ENTER to proceed with reboot + echo + ! $NOTCHROOT || read -p "Press ENTER to continue or CTRL+C to break out of script." + ! $NOTCHROOT || reboot +else + printf "\nRunning part 2 of PiKVM installer script v$VER by @srepac and @SilentWind\n" | tee -a $LOGFILE + + echo "-> Re-installing janus ..." | tee -a $LOGFILE + apt reinstall -y janus > /dev/null 2>&1 + ### run these to make sure kvmd users are created ### + echo "-> Ensuring KVMD users and groups ..." | tee -a $LOGFILE + systemd-sysusers /usr/lib/sysusers.d/kvmd.conf + systemd-sysusers /usr/lib/sysusers.d/kvmd-webterm.conf + + fix-nginx-symlinks + fix-python-symlinks + fix-webterm + fix-motd + fix-nfs-msd + fix-nginx + ocr-fix + + set-ownership + create-kvmdfix + + echo "-> Install python3 modules dbus_next and zstandard" | tee -a $LOGFILE + if [[ "$PYTHONVER" == "3.11" ]]; then + apt install -y python3-dbus-next python3-zstandard + else + pip3 install dbus_next zstandard + fi + ### additional python pip dependencies for kvmd 3.238 and higher + case $PYTHONVER in + 3.10*|3.[987]*) + pip3 install async-lru 2> /dev/null + ### Fix for kvmd 3.291 -- only applies to python 3.10 ### + sed -i -e 's|gpiod.EdgeEvent|gpiod.LineEvent|g' /usr/lib/python3/dist-packages/kvmd/aiogp.py + sed -i -e 's|gpiod.line,|gpiod.Line,|g' /usr/lib/python3/dist-packages/kvmd/aiogp.py + ;; + 3.11*) + pip3 install async-lru --break-system-packages 2> /dev/null + ;; + esac + + apply-x86-mods + x86-fix-3.256 + x86-fix-3.281 + check-kvmd-works + enable-kvmd-svcs + update-logo + start-kvmd-svcs + + printf "\nCheck kvmd devices\n\n" | tee -a $LOGFILE + ls -l /dev/kvmd* | tee -a $LOGFILE + printf "\nYou should see devices for keyboard, mouse, and video.\n" | tee -a $LOGFILE + + printf "\nPoint a browser to https://$(hostname)\nIf it doesn't work, then reboot one last time.\nPlease make sure kvmd services are running after reboot.\n" | tee -a $LOGFILE +fi + +cd $CWD +cp -rf web.css /etc/kvmd/web.css + +systemctl status $SERVICES | grep Loaded | tee -a $LOGFILE + +### fix totp.secret file permissions for use with 2FA +chmod go+r /etc/kvmd/totp.secret +chown kvmd:kvmd /etc/kvmd/totp.secret + +### create rw and ro so that /usr/bin/kvmd-bootconfig doesn't fail +touch /usr/local/bin/rw /usr/local/bin/ro +chmod +x /usr/local/bin/rw /usr/local/bin/ro + +### update default hostname info in webui to reflect current hostname +sed -i -e "s/localhost.localdomain/`hostname`/g" /etc/kvmd/meta.yaml + +### restore htpasswd from previous install, if applies +if [ -e /etc/kvmd/htpasswd.save ]; then cp /etc/kvmd/htpasswd.save /etc/kvmd/htpasswd; fi + +### instead of showing # fps dynamic, show REDACTED fps dynamic instead; USELESS fps meter fix +#sed -i -e 's|${__fps}|REDACTED|g' /usr/share/kvmd/web/share/js/kvm/stream_mjpeg.js + +### fix kvmd-webterm 0.49 change that changed ttyd to kvmd-ttyd which broke webterm +sed -i -e 's/kvmd-ttyd/ttyd/g' /lib/systemd/system/kvmd-webterm.service + +# get rid of this line, otherwise kvmd-nginx won't start properly since the nginx version is not 1.25 and higher +if [ -e /etc/kvmd/nginx/nginx.conf.mako ]; then + sed -i -e '/http2 on;/d' /etc/kvmd/nginx/nginx.conf.mako +fi + +systemctl restart kvmd-nginx kvmd-webterm kvmd diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 index 700303ca..f1163fd3 --- a/install.sh +++ b/install.sh @@ -1,108 +1,640 @@ #!/bin/bash +# https://github.com/srepac/kvmd-armbian +# modified by SilentWind 2024-06-17 +# modified by xe5700 2021-11-04 xe5700@outlook.com +# modified by NewbieOrange 2021-11-04 +# created by @srepac 08/09/2021 srepac@kvmnerds.com +# Scripted Installer of Pi-KVM on Armbian 32-bit and 64-bit (as long as it's running python 3.10 or higher) +# +# *** MSD is disabled by default *** +# +# Mass Storage Device requires the use of a USB thumbdrive or SSD and will need to be added in /etc/fstab +: ' +# SAMPLE /etc/fstab entry for USB drive with only one partition formatted as ext4 for the entire drive: -ARCH=$(uname -n) -MACHINE=$(uname -o -s -r -m) -PYVER=$(python3 -V) -CURRENTWD=$PWD -FIND_FILE="/etc/sudoers" -FIND_STR="onecloud_gpio.sh" +/dev/sda1 /var/lib/kvmd/msd ext4 nodev,nosuid,noexec,ro,errors=remount-ro,data=journal,X-kvmd.otgmsd-root=/var/lib/kvmd/msd,X-kvmd.otgmsd-user=kvmd 0 0 -#检查架构和Python版本 -check_environment(){ - echo -e "设备名称:$MACHINE\nPython版本:$PYVER" - if [ ! $ARCH = "onecloud" ]; then - echo -e "此脚本暂不支持armv7l架构以外的设备!\n退出脚本!" - exit +' +# NOTE: This was tested on a new install of raspbian desktop and lite versions, but should also work on an existing install. +# +# Last change 20240526 2345 PDT +VER=3.4 +set +x +PIKVMREPO="https://files.pikvm.org/repos/arch/rpi4" +KVMDFILE="kvmd-3.291-1-any.pkg.tar.xz" +KVMDCACHE="/var/cache/kvmd"; mkdir -p $KVMDCACHE +PKGINFO="${KVMDCACHE}/packages.txt" +APP_PATH=$(readlink -f $(dirname $0)) +LOGFILE="${KVMDCACHE}/installer.log"; touch $LOGFILE; echo "==== $( date ) ====" >> $LOGFILE + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + echo "usage: $0 [-f] where -f will force re-install new pikvm platform" + exit 1 +fi + +CWD=`pwd` + +WHOAMI=$( whoami ) +if [ "$WHOAMI" != "root" ]; then + echo "$WHOAMI, please run script as root." + exit 1 +fi + +PYTHONVER=$( python3 -V | cut -d' ' -f2 | cut -d'.' -f1,2 ) +case $PYTHONVER in + 3.10|3.11) + echo "Python $PYTHONVER is supported." | tee -a $LOGFILE + ;; + *) + echo "Python $PYTHONVER is NOT supported. Please make sure you have python3.10 or higher installed. Exiting." | tee -a $LOGFILE + exit 1 + ;; +esac + +MAKER=$(tr -d '\0' < /proc/device-tree/model | awk '{print $1}') + + +gen-ssl-certs() { + cd /etc/kvmd/nginx/ssl + openssl ecparam -out server.key -name prime256v1 -genkey + openssl req -new -x509 -sha256 -nodes -key server.key -out server.crt -days 3650 \ + -subj "/C=US/ST=Denial/L=Denial/O=Pi-KVM/OU=Pi-KVM/CN=$(hostname)" + cp server* /etc/kvmd/vnc/ssl/ + cd ${APP_PATH} +} # end gen-ssl-certs + + +create-override() { + if [ $( grep ^kvmd: /etc/kvmd/override.yaml | wc -l ) -eq 0 ]; then + + if [[ $( echo $platform | grep usb | wc -l ) -eq 1 ]]; then + cat <> /etc/kvmd/override.yaml +kvmd: + hid: + mouse_alt: + device: /dev/kvmd-hid-mouse-alt # allow relative mouse mode + msd: + type: disabled + atx: + type: disabled + streamer: + #forever: true + cmd_append: + - "--slowdown" # so target doesn't have to reboot + resolution: + default: 1280x720 +USBOVERRIDE + + else + + cat <> /etc/kvmd/override.yaml +kvmd: + ### disable fan socket check ### + info: + fan: + unix: '' + hid: + mouse_alt: + device: /dev/kvmd-hid-mouse-alt + msd: + type: disabled + streamer: + #forever: true + cmd_append: + - "--slowdown" # so target doesn't have to reboot +CSIOVERRIDE + + fi + + fi +} # end create-override + +install-python-packages() { + echo "apt install -y python3-aiofiles python3-aiohttp python3-appdirs python3-asn1crypto python3-async-timeout + python3-bottle python3-cffi python3-chardet python3-click python3-colorama python3-cryptography python3-dateutil + python3-dbus python3-dev python3-hidapi python3-idna python3-libgpiod python3-mako python3-marshmallow + python3-more-itertools python3-multidict python3-netifaces python3-packaging python3-passlib python3-pillow + python3-ply python3-psutil python3-pycparser python3-pyelftools python3-pyghmi python3-pygments python3-pyparsing + python3-requests python3-semantic-version python3-setproctitle python3-setuptools python3-six python3-spidev + python3-systemd python3-tabulate python3-urllib3 python3-wrapt python3-xlib python3-yaml python3-yarl python3-build + python3-pyotp python3-qrcode python3-serial" + apt install -y python3-aiofiles python3-aiohttp python3-appdirs python3-asn1crypto python3-async-timeout\ + python3-bottle python3-cffi python3-chardet python3-click python3-colorama python3-cryptography python3-dateutil\ + python3-dbus python3-dev python3-hidapi python3-idna python3-libgpiod python3-mako python3-marshmallow\ + python3-more-itertools python3-multidict python3-netifaces python3-packaging python3-passlib python3-pillow\ + python3-ply python3-psutil python3-pycparser python3-pyelftools python3-pyghmi python3-pygments python3-pyparsing\ + python3-requests python3-semantic-version python3-setproctitle python3-setuptools python3-six python3-spidev\ + python3-systemd python3-tabulate python3-urllib3 python3-wrapt python3-xlib python3-yaml python3-yarl python3-build\ + python3-pyotp python3-qrcode python3-serial >> $LOGFILE +} # end install python-packages + +otg-devices() { + modprobe libcomposite + if [ ! -e /sys/kernel/config/usb_gadget/kvmd ]; then + mkdir -p /sys/kernel/config/usb_gadget/kvmd/functions + cd /sys/kernel/config/usb_gadget/kvmd/functions + mkdir hid.usb0 hid.usb1 hid.usb2 mass_storage.usb0 + fi + cd ${APP_PATH} +} # end otg-device creation + +boot-files() { + # Remove OTG serial (Orange pi zero's kernel not support it) + sed -i '/^g_serial/d' /etc/modules + + # /etc/modules required entries for DWC2, HID and I2C + if [[ $( grep -w dwc2 /etc/modules | wc -l ) -eq 0 ]]; then + echo "dwc2" >> /etc/modules + fi + if [[ $( grep -w libcomposite /etc/modules | wc -l ) -eq 0 ]]; then + echo "libcomposite" >> /etc/modules + fi + if [[ $( grep -w i2c-dev /etc/modules | wc -l ) -eq 0 ]]; then + echo "i2c-dev" >> /etc/modules fi - if [[ "$PYVER" != *"3.10"* && $(which python3.10) != *"python"* ]]; then - echo -e "您似乎没有安装 Python 3.10!\n退出脚本!" - exit - fi -} + printf "\n/etc/modules\n\n" | tee -a $LOGFILE + cat /etc/modules | tee -a $LOGFILE +} # end of necessary boot files -#安装依赖软件 -install_dependencies(){ - bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --source mirrors.tuna.tsinghua.edu.cn --updata-software false --web-protocol http && echo "换源成功!" - echo -e "正在安装依赖软件......" - apt install -y python3.10 python3-pip python3-dev patch iptables nginx \ - tesseract-ocr tesseract-ocr-eng janus libevent-dev libgpiod-dev \ - tesseract-ocr-chi-sim libjpeg-dev libfreetype6-dev gcc -} +get-packages() { + printf "\n\n-> Getting Pi-KVM packages from ${PIKVMREPO}\n\n" | tee -a $LOGFILE + cp -f ${APP_PATH}/kvmd-packages/* ${KVMDCACHE} -#安装PiKVM -install_pikvm(){ - echo "正在安装PiKVM......" - dpkg -i ./fruity-pikvm_0.2_armhf.deb - systemctl enable kvmd-vnc - systemctl disable nginx kvmd-janus - #rm -f /lib/systemd/system/nginx.service - #rm -f /lib/systemd/system/kvmd-janus.service && systemctl daemon-reload - echo "PiKVM安装成功" - cd $CURRENTWD - cp -f ./patch/onecloud_gpio.sh /usr/bin - chmod +x /usr/bin/onecloud_gpio.sh - echo "GPIO脚本移动成功" - cp -f ./patch/hw.py /usr/local/lib/python3.10/kvmd-packages/kvmd/apps/kvmd/info/ - chmod +x /usr/local/lib/python3.10/kvmd-packages/kvmd/apps/kvmd/info/hw.py - cp -f ./config/main.yaml /etc/kvmd/ && cp -f ./config/override.yaml /etc/kvmd/ - echo "配置文件替换成功" - kvmd -m -} + } # end get-packages function -#应用补丁 -add_patches(){ - if [ ! -f `grep -c "$FIND_STR" $FIND_FILE` ]; then - echo kvmd ALL=\(ALL\) NOPASSWD: /usr/bin/onecloud_gpio.sh >> /etc/sudoers +get-platform() { + platform="kvmd-platform-v2-hdmiusb-rpi4"; + echo + echo "Platform selected -> $platform" | tee -a $LOGFILE + echo +} # end get-platform + +install-kvmd-pkgs() { + cd / + + INSTLOG="${KVMDCACHE}/installed_ver.txt"; rm -f $INSTLOG + date > $INSTLOG + +# uncompress platform package first + i=$( ls ${KVMDCACHE}/${platform}*.tar.xz ) ### install the most up to date kvmd-platform package + + # change the log entry to show 3.291 platform installed as we'll be forcing kvmd-3.291 instead of latest/greatest kvmd + _platformver=$( echo $i | sed -e 's/3\.29[2-9]*/3.291/g' -e 's/3\.3[0-9]*/3.291/g' -e 's/3.2911/3.291/g' -e 's/4\.[0-9].*-/3.291-/g' ) + echo "-> Extracting package $_platformver into /" | tee -a $INSTLOG + tar xfJ $i + +# then uncompress, kvmd-{version}, kvmd-webterm, and janus packages + for i in $( ls ${KVMDCACHE}/*.tar.xz | egrep 'kvmd-[0-9]|webterm' ) + do + case $i in + *kvmd-3.29[2-9]*|*kvmd-3.[3-9]*|*kvmd-[45].[1-9]*) # if latest/greatest is 3.292 and higher, then force 3.291 install + echo "*** Force install kvmd 3.291 ***" | tee -a $LOGFILE + i=$KVMDCACHE/$KVMDFILE + ;; + *) + ;; + esac + + echo "-> Extracting package $i into /" >> $INSTLOG + tar xfJ $i + done + + # uncompress janus package if /usr/bin/janus doesn't exist + if [ ! -e /usr/bin/janus ]; then + i=$( ls ${KVMDCACHE}/*.tar.xz | egrep janus | grep -v 1x ) + echo "-> Extracting package $i into /" >> $INSTLOG + tar xfJ $i + + else # confirm that /usr/bin/janus actually runs properly + /usr/bin/janus --version > /dev/null 2>> $LOGFILE + if [ $? -eq 0 ]; then + echo "You have a working valid janus binary." | tee -a $LOGFILE + else # error status code, so uncompress from REPO package + #i=$( ls ${KVMDCACHE}/*.tar.xz | egrep janus ) + #echo "-> Extracting package $i into /" >> $INSTLOG + #tar xfJ $i + apt-get remove janus janus-dev -y >> $LOGFILE + apt-get install janus janus-dev -y >> $LOGFILE + fi fi - if [ ! -f "/usr/local/lib/python3.10/kvmd-packages/3.198msd.patch" ]; then - cd $CURRENTWD - cp ./patch/3.198msd.patch /usr/local/lib/python3.10/kvmd-packages/ && cd /usr/local/lib/python3.10/kvmd-packages/ - patch -s -p0 < 3.198msd.patch - echo "MSD补丁应用成功" - fi + cd ${APP_PATH} +} # end install-kvmd-pkgs - cd $CURRENTWD - cp -f ./patch/chinese.patch /usr/share/kvmd/web/ && cd /usr/share/kvmd/web/ - patch -s -p0 < chinese.patch - echo -e "中文补丁应用成功" - pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ - pip3 install -U Pillow +fix-udevrules() { + # for hdmiusb, replace %b with 1-1.4:1.0 in /etc/udev/rules.d/99-kvmd.rules + sed -i -e 's+\%b+1-1.4:1.0+g' /etc/udev/rules.d/99-kvmd.rules | tee -a $LOGFILE + echo + cat /etc/udev/rules.d/99-kvmd.rules | tee -a $LOGFILE +} # end fix-udevrules -} +enable-kvmd-svcs() { + # enable KVMD services but don't start them + echo "-> Enabling $SERVICES services, but do not start them." | tee -a $LOGFILE + systemctl enable $SERVICES +} # end enable-kvmd-svcs -#设置网页终端欢迎语 -fix_motd(){ - #cd $CURRENTWD - if [ -e /etc/motd ]; then rm /etc/motd; fi - cat > /usr/bin/armbian-motd << EOF -#!/bin/sh -if [ -e /etc/update-motd.d/10-armbian-header ]; then /etc/update-motd.d/10-armbian-header; fi -if [ -e /etc/update-motd.d/30-armbian-sysinfo ]; then /etc/update-motd.d/30-armbian-sysinfo; fi +build-ustreamer() { + printf "\n\n-> Building ustreamer\n\n" | tee -a $LOGFILE + # Install packages needed for building ustreamer source + echo "apt install -y libevent-dev libjpeg-dev libbsd-dev libgpiod-dev libsystemd-dev janus-dev janus" | tee -a $LOGFILE + apt install -y libevent-dev libjpeg-dev libbsd-dev libgpiod-dev libsystemd-dev janus-dev janus >> $LOGFILE -printf " 欢迎使用 One-KVM,基于开源程序 PiKVM 的 IP-KVM 应用 - ____________________________________________________________________________ + # fix refcount.h + sed -i -e 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h - 要修改默认账户 admin 密码可使用 \"kvmd-htpasswd set admin\" + # Download ustreamer source and build it + cd /tmp + unzip ${APP_PATH}/sources/ustreamer-6.12.zip + cd ustreamer-6.12/ + #添加WITH_PYTHON=1 ,使kvmd-vnc正常工作 + make WITH_GPIO=1 WITH_SYSTEMD=1 WITH_JANUS=1 WITH_PYTHON=1 -j + #删除 --prefix=$(PREFIX) ,修复无法安装pythgon包的问题 + sed -i 's/--prefix=\$(PREFIX)//g' python/Makefile + make install WITH_PYTHON=1 + # kvmd service is looking for /usr/bin/ustreamer + ln -sf /usr/local/bin/ustreamer* /usr/bin/ - 帮助链接: - * https://docs.pikvm.org - * https://one-kvm.mofeng.run/ - * https://github.com/mofeng-git/One-KVM -" -EOF - chmod +x /usr/bin/armbian-motd /etc/update-motd.d/10-armbian-header /etc/update-motd.d/30-armbian-sysinfo - sed -i 's/cat \/etc\/motd/armbian-motd/g' /lib/systemd/system/kvmd-webterm.service - echo "fixed motd" -} + # add janus support + mkdir -p /usr/lib/ustreamer/janus + cp /tmp/ustreamer-6.12/janus/libjanus_ustreamer.so /usr/lib/ustreamer/janus +} # end build-ustreamer -#玩客云特定配置 -onecloud_conf(){ - if [ ! $ARCH = "onecloud" ]; then - echo -e "\n" +install-dependencies() { + echo + echo "-> Installing dependencies for pikvm" | tee -a $LOGFILE + + echo "apt install -y make nginx python3 gcc unzip net-tools bc expect v4l-utils iptables vim dos2unix screen tmate nfs-common gpiod ffmpeg dialog iptables dnsmasq git python3-pip tesseract-ocr tesseract-ocr-eng libasound2-dev libsndfile-dev libspeexdsp-dev build-essential libssl-dev libffi-dev libevent libevent-core libevent-pthreads" | tee -a $LOGFILE + apt install -y make nginx python3 gcc unzip net-tools bc expect v4l-utils iptables vim dos2unix screen tmate nfs-common gpiod ffmpeg dialog iptables dnsmasq git python3-pip tesseract-ocr tesseract-ocr-eng libasound2-dev libsndfile-dev libspeexdsp-dev build-essential libssl-dev libffi-dev libevent libevent-core libevent-pthreads >> $LOGFILE + + sed -i -e 's/#port=5353/port=5353/g' /etc/dnsmasq.conf + + install-python-packages + + + + echo "-> Make tesseract data link" | tee -a $LOGFILE + ln -sf /usr/share/tesseract-ocr/*/tessdata /usr/share/tessdata + + echo "-> Install TTYD" | tee -a $LOGFILE + apt install -y ttyd | tee -a $LOGFILE + /usr/bin/ttyd -v | tee -a $LOGFILE + + if [ ! -e /usr/local/bin/gpio ]; then + printf "\n\n-> Building wiringpi from source\n\n" | tee -a $LOGFILE + cd /tmp; rm -rf WiringPi-3.6 + unzip ${APP_PATH}/sources/WiringPi-3.6.zip + cd WiringPi-3.6 + ./build else - echo "为玩客云配置开机脚本" + printf "\n\n-> Wiringpi (gpio) is already installed.\n\n" | tee -a $LOGFILE + fi + gpio -v | tee -a $LOGFILE + + echo "-> Install ustreamer" | tee -a $LOGFILE + if [ ! -e /usr/bin/ustreamer ]; then + cd /tmp + ### required dependent packages for ustreamer ### + build-ustreamer + cd ${APP_PATH} + fi + echo -n "ustreamer version: " | tee -a $LOGFILE + ustreamer -v | tee -a $LOGFILE + ustreamer --features | tee -a $LOGFILE +} # end install-dependencies + +python-pkg-dir() { + # debian system python3 no alias + # create quick python script to show where python packages need to go + cat << MYSCRIPT > /tmp/syspath.py +#!$(which python3) +import sys +print (sys.path) +MYSCRIPT + + chmod +x /tmp/syspath.py + + #PYTHONDIR=$( /tmp/syspath.py | awk -F, '{print $NF}' | cut -d"'" -f2 ) + ### hardcode path for armbian/raspbian + PYTHONDIR="/usr/lib/python3/dist-packages" +} # end python-pkg-dir + +fix-nginx-symlinks() { + # disable default nginx service since we will use kvmd-nginx instead + echo + echo "-> Disabling nginx service, so that we can use kvmd-nginx instead" | tee -a $LOGFILE + systemctl disable --now nginx + + # setup symlinks + echo + echo "-> Creating symlinks for use with kvmd python scripts" | tee -a $LOGFILE + if [ ! -e /usr/bin/nginx ]; then ln -sf /usr/sbin/nginx /usr/bin/; fi + if [ ! -e /usr/sbin/python ]; then ln -sf /usr/bin/python3 /usr/sbin/python; fi + if [ ! -e /usr/bin/iptables ]; then ln -sf /usr/sbin/iptables /usr/bin/iptables; fi + if [ ! -e /usr/bin/vcgencmd ]; then ln -sf /opt/vc/bin/* /usr/bin/; chmod +x /opt/vc/bin/*; fi + + python-pkg-dir + + if [ ! -e $PYTHONDIR/kvmd ]; then + # Debian python版本比 pikvm官方的低一些 + # in case new kvmd packages are now using python 3.11 + ln -sf /usr/lib/python3.1*/site-packages/kvmd* ${PYTHONDIR} + fi +} # end fix-nginx-symlinks + +fix-python-symlinks(){ + python-pkg-dir + + if [ ! -e $PYTHONDIR/kvmd ]; then + # Debian python版本比 pikvm官方的低一些 + ln -sf /usr/lib/python3.1*/site-packages/kvmd* ${PYTHONDIR} + fi +} + +apply-custom-patch(){ + read -p "Do you want apply old kernel msd patch? [y/n]" answer + case $answer in + n|N|no|No) + echo 'You skipped this patch.' + ;; + y|Y|Yes|yes) + ./patches/custom/old-kernel-msd/apply.sh + ;; + *) + echo "Try again.";; + esac +} + + +fix-webterm() { + echo + echo "-> Creating kvmd-webterm homedir" | tee -a $LOGFILE + mkdir -p /home/kvmd-webterm + chown kvmd-webterm /home/kvmd-webterm + ls -ld /home/kvmd-webterm | tee -a $LOGFILE + + # remove -W option since ttyd installed on raspbian/armbian is 1.6.3 (-W option only works with ttyd 1.7.x) + _ttydver=$( /usr/bin/ttyd -v | awk '{print $NF}' ) + case $_ttydver in + 1.6*) + echo "ttyd $_ttydver found. Removing -W from /lib/systemd/system/kvmd-webterm.service" + sed -i -e '/-W \\/d' /lib/systemd/system/kvmd-webterm.service + ;; + 1.7*) + echo "ttyd $_ttydver found. Nothing to do." + ;; + esac + + # add sudoers entry for kvmd-webterm user to be able to run sudo + echo "kvmd-webterm ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/kvmd-webterm; chmod 440 /etc/sudoers.d/kvmd-webterm +} # end fix-webterm + +create-kvmdfix() { + # Create kvmd-fix service and script + cat < /lib/systemd/system/kvmd-fix.service +[Unit] +Description=KVMD Fixes +After=network.target network-online.target nss-lookup.target +Before=kvmd.service + +[Service] +User=root +Type=simple +ExecStart=/usr/bin/kvmd-fix + +[Install] +WantedBy=multi-user.target +ENDSERVICE + + cat < /usr/bin/kvmd-fix +#!/bin/bash +# Written by @srepac +# 1. Properly set group ownership of /dev/gpio* +# 2. fix /dev/kvmd-video symlink to point to /dev/video1 (Amglogic Device video0 is not usb device) +# +### These fixes are required in order for kvmd service to start properly +# +set -x +chgrp gpio /dev/gpio* +chmod 660 /dev/gpio* +ls -l /dev/gpio* + +udevadm trigger +ls -l /dev/kvmd-video + +if [ \$( systemctl | grep kvmd-oled | grep -c activ ) -eq 0 ]; then + echo "kvmd-oled service is not enabled." + exit 0 +else + echo "kvmd-oled service is enabled and activated." +fi + +### kvmd-oled fix: swap i2c-0 <-> i2c-1 (code is looking for I2C oled on i2c-1) +# pins #1 - 3.3v, #3 - SDA, #5 - SCL, and #9 - GND +i2cget -y 0 0x3c +if [ \$? -eq 0 ]; then + echo "-> Found valid I2C OLED at i2c-0. Applying I2C OLED fix." + cd /dev + + # rename i2c-0 -> i2c-9, move i2c-1 to i2c-0, and rename the good i2c-9 to i2c-1 + mv i2c-0 i2c-9 + mv i2c-1 i2c-0 + mv i2c-9 i2c-1 + + # restart kvmd-oled service + systemctl restart kvmd-oled +else + echo "-> I2C OLED fix already applied and OLED should be showing info." +fi +SCRIPTEND + + chmod +x /usr/bin/kvmd-fix +} # end create-kvmdfix + +set-ownership() { + # set proper ownership of password files and kvmd-webterm homedir + cd /etc/kvmd + chown kvmd:kvmd htpasswd + chown kvmd-ipmi:kvmd-ipmi ipmipasswd + chown kvmd-vnc:kvmd-vnc vncpasswd + chown kvmd-webterm /home/kvmd-webterm + + # add kvmd user to video group (this is required in order to use CSI bridge with OMX and h264 support) + usermod -a -G video kvmd + + # add kvmd user to dialout group (required for xh_hk4401 kvm switch support) + usermod -a -G dialout kvmd +} # end set-ownership + +check-kvmd-works() { + echo "-> Checking kvmd -m works before continuing" | tee -a $LOGFILE + kvmd -m + invalid=1 + ! $NOTCHROOT || while [ $invalid -eq 1 ]; do + #kvmd -m + read -p "Did kvmd -m run properly? [y/n] " answer + case $answer in + n|N|no|No) + echo "Please install missing packages as per the kvmd -m output in another ssh/terminal." + ;; + y|Y|Yes|yes) + invalid=0 + ;; + *) + echo "Try again.";; + esac + done +} # end check-kvmd-works + +start-kvmd-svcs() { + #### start the main KVM services in order #### + # 1. nginx is the webserver + # 2. kvmd-otg is for OTG devices (keyboard/mouse, etc..) + # 3. kvmd is the main daemon + systemctl daemon-reload + systemctl restart $SERVICES +} # end start-kvmd-svcs + +fix-motd() { + if [ -e /etc/motd ]; then rm /etc/motd; fi + cp armbian/armbian-motd /usr/bin/ + chmod +x /usr/bin/armbian-motd + chmod +x /etc/update-motd.d/* + sed -i 's/cat \/etc\/motd/armbian-motd/g' /lib/systemd/system/kvmd-webterm.service + systemctl daemon-reload + # systemctl restart kvmd-webterm +} # end fix-motd + +# 安装armbian的包 +armbian-packages() { + mkdir -p /opt/vc/bin/ + #cd /opt/vc/bin + if [ ! -e /usr/bin/vcgencmd ]; then + # Install vcgencmd for armbian platform + cp -rf armbian/opt/* /opt/vc/bin + else + ln -s /usr/bin/vcgencmd /opt/vc/bin/ + fi + #cp -rf armbian/udev /etc/ + + cd ${APP_PATH} +} # end armbian-packages + +fix-nfs-msd() { + NAME="aiofiles.tar" + + LOCATION="/usr/lib/python3.11/site-packages" + echo "-> Extracting $NAME into $LOCATION" | tee -a $LOGFILE + tar xvf $NAME -C $LOCATION + + echo "-> Renaming original aiofiles and creating symlink to correct aiofiles" | tee -a $LOGFILE + cd /usr/lib/python3/dist-packages + mv aiofiles aiofiles.$(date +%Y%m%d.%H%M) + ln -s $LOCATION/aiofiles . + ls -ld aiofiles* | tail -5 +} + +fix-nginx() { + #set -x + KERNEL=$( uname -r | awk -F\- '{print $1}' ) + ARCH=$( uname -r | awk -F\- '{print $NF}' ) + echo "KERNEL: $KERNEL ARCH: $ARCH" | tee -a $LOGFILE + case $ARCH in + ARCH) SEARCHKEY=nginx-mainline;; + *) SEARCHKEY="nginx/";; + esac + + HTTPSCONF="/etc/kvmd/nginx/listen-https.conf" + echo "HTTPSCONF BEFORE: $HTTPSCONF" | tee -a $LOGFILE + cat $HTTPSCONF | tee -a $LOGFILE + + if [[ ! -e /usr/local/bin/pikvm-info || ! -e /tmp/pacmanquery ]]; then + cp -f ${APP_PATH}/pikvm-info /usr/local/bin/pikvm-info + chmod +x /usr/local/bin/pikvm-info + echo "Getting list of packages installed..." | tee -a $LOGFILE + pikvm-info > /dev/null ### this generates /tmp/pacmanquery with list of installed pkgs + fi + + NGINXVER=$( grep $SEARCHKEY /tmp/pacmanquery | awk '{print $1}' | cut -d'.' -f1,2 ) + echo + echo "NGINX version installed: $NGINXVER" | tee -a $LOGFILE + + case $NGINXVER in + 1.2[56789]|1.3*|1.4*|1.5*) # nginx version 1.25 and higher + cat << NEW_CONF > $HTTPSCONF +listen 443 ssl; +listen [::]:443 ssl; +http2 on; +NEW_CONF + ;; + + 1.18|*) # nginx version 1.18 and lower + cat << ORIG_CONF > $HTTPSCONF +listen 443 ssl http2; +listen [::]:443 ssl; +ORIG_CONF + ;; + + esac + + echo "HTTPSCONF AFTER: $HTTPSCONF" | tee -a $LOGFILE + cat $HTTPSCONF | tee -a $LOGFILE + set +x +} # end fix-nginx + +ocr-fix() { # create function + echo + echo "-> Apply OCR fix..." | tee -a $LOGFILE + + set -x + # 1. verify that Pillow module is currently running 9.0.x + PILLOWVER=$( grep -i pillow $PIP3LIST | awk '{print $NF}' ) + + case $PILLOWVER in + 9.*|8.*|7.*) # Pillow running at 9.x and lower + # 2. update Pillow to 10.0.0 + pip3 install -U Pillow 2>> $LOGFILE + + # 3. check that Pillow module is now running 10.0.0 + pip3 list | grep -i pillow | tee -a $LOGFILE + + #4. restart kvmd and confirm OCR now works. + systemctl restart kvmd + ;; + + 10.*|11.*|12.*) # Pillow running at 10.x and higher + echo "Already running Pillow $PILLOWVER. Nothing to do." | tee -a $LOGFILE + ;; + + esac + + set +x + echo +} # end ocr-fix + +async-lru-fix() { + echo + echo "-> Ensuring async-lru is installed with version 2.x ..." | tee -a $LOGFILE + pip3 install async-lru 2> /dev/null + PIP3LIST="/tmp/pip3.list"; /bin/rm -f $PIP3LIST + pip3 list 2> /dev/null > $PIP3LIST + + ASYNCLRUVER=$( grep -i 'async[-_]lru' $PIP3LIST | awk '{print $NF}' ) + echo "ASYNC-LRU version: $ASYNCLRUVER" + case $ASYNCLRUVER in + 2.*) echo "Nothing to do. aync-lru is already running $ASYNCLRUVER" | tee -a $LOFILE;; + 1.*|*) pip3 install -U async_lru --break-system-packages | tee -a $LOGFILE;; # raspbian bookworm only installs 1.0.x, this forces 2.0.x + esac +} # end async-lru-fix + + +#fix for onecloud +onecloud_conf(){ + if [ "$(hostname)" == "onecloud" ]; then + pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + apt install -y cpufrequtils + echo "-->Add /etc/rc.local and skip usbburning for onecloud" cat </etc/rc.local #!/bin/bash echo "default-on" >/sys/class/leds/onecloud\:green\:alive/trigger @@ -110,26 +642,178 @@ echo "none" >/sys/class/leds/onecloud\:red\:alive/trigger echo "none" >/sys/class/leds/onecloud\:blue\:alive/trigger cpufreq-set -d 1200MHz -u 1200MHz echo device > /sys/class/usb_role/c9040000.usb-role-switch/role -systemctl disable kvmd +systemctl disable kvmd && systemctl stop kvmd systemctl start kvmd exit 0 EOF + sed -i '97c #' /usr/lib/python3.11/site-packages/kvmd/apps/kvmd/info/hw.py + sed -i '106c #' /usr/lib/python3.11/site-packages/kvmd/apps/kvmd/info/hw.py + cp -f ./patches/onecloud_gpio.sh /usr/bin && chmod +x /usr/bin/onecloud_gpio.sh + cp -f ${APP_PATH}/conf/override-onecloud.yaml /etc/kvmd/override.yaml #如果在CHROOT环境需设置NOTCHROOT=false - ! $NOTCHROOT || gzip -dc ./patch/Boot_SkipUSBBurning.gz | dd of=/dev/mmcblk1 bs=512 seek=1 count=32767 + ! $NOTCHROOT || gzip -dc ${APP_PATH}/patches/Boot_SkipUSBBurning.gz | dd of=/dev/mmcblk1 bs=512 seek=1 count=32767 echo -e "\n" + if [ ! -f `grep -c "onecloud_gpio.sh" /etc/sudoers` ]; then + echo kvmd ALL=\(ALL\) NOPASSWD: /usr/bin/onecloud_gpio.sh >> /etc/sudoers + fi fi } -#打印完成信息 -show_info(){ - echo -e "安装结束,重启之后即可开始使用One-KVM" - /usr/bin/armbian-motd + +update-logo() { + sed -i -e 's|class="svg-gray"|class="svg-color"|g' /usr/share/kvmd/web/index.html + sed -i -e 's|target="_blank">> $LOGFILE + printf "\nReboot is required to create kvmd users and groups.\nPlease re-run this script after reboot to complete the install.\n" | tee -a $LOGFILE + + # Fix paste-as-keys if running python 3.7 + if [[ $( python3 -V | awk '{print $2}' | cut -d'.' -f1,2 ) == "3.7" ]]; then + sed -i -e 's/reversed//g' /usr/lib/python3.1*/site-packages/kvmd/keyboard/printer.py + fi + + ### run these to make sure kvmd users are created ### + echo "-> Ensuring KVMD users and groups ..." | tee -a $LOGFILE + systemd-sysusers /usr/lib/sysusers.d/kvmd.conf + systemd-sysusers /usr/lib/sysusers.d/kvmd-webterm.conf + + # Ask user to press CTRL+C before reboot or ENTER to proceed with reboot + echo + ! $NOTCHROOT || read -p "Press ENTER to continue or CTRL+C to break out of script." + ! $NOTCHROOT || reboot +else + printf "\nRunning part 2 of PiKVM installer script v$VER by @srepac and @SilentWind\n" | tee -a $LOGFILE + + echo "-> Re-installing janus ..." | tee -a $LOGFILE + apt reinstall -y janus > /dev/null 2>&1 + ### run these to make sure kvmd users are created ### + echo "-> Ensuring KVMD users and groups ..." | tee -a $LOGFILE + systemd-sysusers /usr/lib/sysusers.d/kvmd.conf + systemd-sysusers /usr/lib/sysusers.d/kvmd-webterm.conf + + fix-nginx-symlinks + fix-python-symlinks + fix-webterm + fix-motd + fix-nfs-msd + fix-nginx + async-lru-fix + ocr-fix + + set-ownership + create-kvmdfix + + echo "-> Install python3 modules dbus_next and zstandard" | tee -a $LOGFILE + if [[ "$PYTHONVER" == "3.11" ]]; then + apt install -y python3-dbus-next python3-zstandard + else + pip3 install dbus_next zstandard + fi + ### additional python pip dependencies for kvmd 3.238 and higher + case $PYTHONVER in + 3.10*|3.[987]*) + pip3 install async-lru 2> /dev/null + ### Fix for kvmd 3.291 -- only applies to python 3.10 ### + sed -i -e 's|gpiod.EdgeEvent|gpiod.LineEvent|g' /usr/lib/python3/dist-packages/kvmd/aiogp.py + sed -i -e 's|gpiod.line,|gpiod.Line,|g' /usr/lib/python3/dist-packages/kvmd/aiogp.py + ;; + 3.11*) + pip3 install async-lru --break-system-packages 2> /dev/null + ;; + esac + + check-kvmd-works + enable-kvmd-svcs + update-logo + start-kvmd-svcs + + printf "\nCheck kvmd devices\n\n" | tee -a $LOGFILE + ls -l /dev/kvmd* | tee -a $LOGFILE + printf "\nYou should see devices for keyboard, mouse, and video.\n" | tee -a $LOGFILE + + printf "\nPoint a browser to https://$(hostname)\nIf it doesn't work, then reboot one last time.\nPlease make sure kvmd services are running after reboot.\n" | tee -a $LOGFILE +fi + +cd $CWD +cp -rf web.css /etc/kvmd/web.css + +systemctl status $SERVICES | grep Loaded | tee -a $LOGFILE + +### fix totp.secret file permissions for use with 2FA +chmod go+r /etc/kvmd/totp.secret +chown kvmd:kvmd /etc/kvmd/totp.secret + +### create rw and ro so that /usr/bin/kvmd-bootconfig doesn't fail +touch /usr/local/bin/rw /usr/local/bin/ro +chmod +x /usr/local/bin/rw /usr/local/bin/ro + +### update default hostname info in webui to reflect current hostname +sed -i -e "s/localhost.localdomain/`hostname`/g" /etc/kvmd/meta.yaml + +### restore htpasswd from previous install, if applies +if [ -e /etc/kvmd/htpasswd.save ]; then cp /etc/kvmd/htpasswd.save /etc/kvmd/htpasswd; fi + +### instead of showing # fps dynamic, show REDACTED fps dynamic instead; USELESS fps meter fix +#sed -i -e 's|${__fps}|REDACTED|g' /usr/share/kvmd/web/share/js/kvm/stream_mjpeg.js + +### fix kvmd-webterm 0.49 change that changed ttyd to kvmd-ttyd which broke webterm +sed -i -e 's/kvmd-ttyd/ttyd/g' /lib/systemd/system/kvmd-webterm.service + +# get rid of this line, otherwise kvmd-nginx won't start properly since the nginx version is not 1.25 and higher +if [ -e /etc/kvmd/nginx/nginx.conf.mako ]; then + sed -i -e '/http2 on;/d' /etc/kvmd/nginx/nginx.conf.mako +fi + +systemctl restart kvmd-nginx kvmd-webterm kvmd diff --git a/kvmd-packages/janus-gateway-pikvm-0.14.3-1-armv7h.pkg.tar.xz b/kvmd-packages/janus-gateway-pikvm-0.14.3-1-armv7h.pkg.tar.xz new file mode 100644 index 00000000..1941135f Binary files /dev/null and b/kvmd-packages/janus-gateway-pikvm-0.14.3-1-armv7h.pkg.tar.xz differ diff --git a/kvmd-packages/janus-gateway-pikvm-1x-1.2.1-1-armv7h.pkg.tar.xz b/kvmd-packages/janus-gateway-pikvm-1x-1.2.1-1-armv7h.pkg.tar.xz new file mode 100644 index 00000000..1006d0dc Binary files /dev/null and b/kvmd-packages/janus-gateway-pikvm-1x-1.2.1-1-armv7h.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-3.291-1-any.pkg.tar.xz b/kvmd-packages/kvmd-3.291-1-any.pkg.tar.xz new file mode 100644 index 00000000..237a1d09 Binary files /dev/null and b/kvmd-packages/kvmd-3.291-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..a2b2b130 Binary files /dev/null and b/kvmd-packages/kvmd-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v0-hdmi-rpi3-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v0-hdmi-rpi3-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..0b1a38e8 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v0-hdmi-rpi3-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v0-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v0-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..7817d584 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v0-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v1-hdmi-rpi3-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v1-hdmi-rpi3-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..50379648 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v1-hdmi-rpi3-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v1-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v1-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..9c8e9780 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v1-hdmiusb-rpi3-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v2-hdmi-rpi3-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v2-hdmi-rpi3-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..8b3a1773 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v2-hdmi-rpi3-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-platform-v2-hdmiusb-rpi4-4.2-1-any.pkg.tar.xz b/kvmd-packages/kvmd-platform-v2-hdmiusb-rpi4-4.2-1-any.pkg.tar.xz new file mode 100644 index 00000000..f3df7ea8 Binary files /dev/null and b/kvmd-packages/kvmd-platform-v2-hdmiusb-rpi4-4.2-1-any.pkg.tar.xz differ diff --git a/kvmd-packages/kvmd-webterm-0.50-1-any.pkg.tar.xz b/kvmd-packages/kvmd-webterm-0.50-1-any.pkg.tar.xz new file mode 100644 index 00000000..b7119203 Binary files /dev/null and b/kvmd-packages/kvmd-webterm-0.50-1-any.pkg.tar.xz differ diff --git a/kvmd_display_install.sh b/kvmd_display_install.sh old mode 100755 new mode 100644 index 9b430d6d..e8b7ffb5 --- a/kvmd_display_install.sh +++ b/kvmd_display_install.sh @@ -21,16 +21,19 @@ RestartSec=3 AmbientCapabilities=CAP_NET_RAW LimitNOFILE=65536 UMask=0117 -ExecStart=/usr/share/kvmd/display_when_ustream_exists.sh +ExecStart=/usr/share/kvmd/display.sh TimeoutStopSec=10 KillMode=mixed [Install] WantedBy=multi-user.target EOF - cp -f ./patch/stream.sh /usr/share/kvmd/ && cp -f ./patch/stream_when_ustream_exists.sh /usr/share/kvmd/ && chmod +x /usr/share/kvmd/stream.sh /usr/share/kvmd/stream_when_ustream_exists.sh + cp -f ./patches/display.sh /usr/share/kvmd/ && chmod +x /usr/share/kvmd/display.sh #启动服务 - systemctl enable kvmd-display && systemctl start kvmd-display + systemctl daemon-reload + ! $NOTCHROOT || systemctl enable kvmd-display + ! $NOTCHROOT || systemctl start kvmd-display + echo "配置完成" } kvmd_display \ No newline at end of file diff --git a/kvmd_h264_install.sh b/kvmd_h264_install.sh old mode 100755 new mode 100644 index 9b240564..eeaf0626 --- a/kvmd_h264_install.sh +++ b/kvmd_h264_install.sh @@ -49,15 +49,19 @@ EOF #修改原有kvmd代码和配置文件 sed -i '17s/.*/ExecStart=\/usr\/bin\/janus --disable-colors --configs-folder=\/etc\/kvmd\/janus2/' /lib/systemd/system/kvmd-janus-static.service sed -i 's/janus.plugin.ustreamer/janus.plugin.streaming/' /usr/share/kvmd/web/share/js/kvm/stream_janus.js - sed -i '293c \/\/' /usr/share/kvmd/web/share/js/kvm/stream_janus.js + sed -i '324c \/\/' /usr/share/kvmd/web/share/js/kvm/stream_janus.js sed -i 's/request\": \"watch\", \"p/request\": \"watch\", \"id\" : 1, \"p/' /usr/share/kvmd/web/share/js/kvm/stream_janus.js #补全网页JS文件并添加相应脚本 - mkdir /usr/share/janus/javascript/ - cp -f ./web/adapter.js /usr/share/janus/javascript/ && cp -f ./web/janus.js /usr/share/janus/javascript/ - cp -f ./patch/stream.sh /usr/share/kvmd/ && cp -f ./patch/stream_when_ustream_exists.sh /usr/share/kvmd/ && chmod +x /usr/share/kvmd/stream.sh /usr/share/kvmd/stream_when_ustream_exists.sh + if [ ! -e /usr/share/janus/javascript/adapter.js ]; then + mkdir /usr/share/janus/javascript/ + cp -f ./patches/adapter.js /usr/share/janus/javascript/ && cp -f ./patches/janus.js /usr/share/janus/javascript/ + fi + cp -f ./patches/stream.sh /usr/share/kvmd/ && cp -f ./patches/stream_when_ustream_exists.sh /usr/share/kvmd/ && chmod +x /usr/share/kvmd/stream.sh /usr/share/kvmd/stream_when_ustream_exists.sh #启动服务 - systemctl enable kvmd-ffmpeg && systemctl enable kvmd-janus-static - systemctl start kvmd-ffmpeg && systemctl start kvmd-janus-static + systemctl daemon-reload + ! $NOTCHROOT || systemctl enable kvmd-ffmpeg && systemctl enable kvmd-janus-static + ! $NOTCHROOT || systemctl start kvmd-ffmpeg && systemctl start kvmd-janus-static + echo "配置完成" } kvmd_ffmpeg_h-264 \ No newline at end of file diff --git a/opikvm-logo.svg b/opikvm-logo.svg new file mode 100644 index 00000000..5c1bb1da --- /dev/null +++ b/opikvm-logo.svg @@ -0,0 +1,49 @@ + + + + + + + + + + Page-1 + + + path7 + + + + diff --git a/patch/chinese.patch b/patch/chinese.patch deleted file mode 100644 index fae24c30..00000000 --- a/patch/chinese.patch +++ /dev/null @@ -1,1509 +0,0 @@ -Only in ./: chinese.patch -diff -ur /usr/share/kvmd/web/index.html ./index.html ---- /usr/share/kvmd/web/index.html 2023-11-05 07:33:58.411778109 +0000 -+++ ./index.html 2023-11-05 02:14:31.204114651 +0000 -@@ -25,7 +25,7 @@ - - - -- PiKVM Index -+ PiKVM 首页 - - - -@@ -53,7 +53,7 @@ - - - -- -+ - - - -@@ -76,16 +76,16 @@ -
-
-

-- Please note that when you are working with a KVM session or another application that captures the keyboard, -- you can't use some keyboard shortcuts such as Ctrl+Alt+Del (which will be caught by your OS) or Ctrl+W (caught by your browser). -+ 请注意,在使用KVM会话或另一个捕获键盘的应用程序时,您不能使用一些键盘快捷键, -+ 例如Ctrl+Alt+Del(这将被您的操作系统捕获)或Ctrl+W(将被您的浏览器捕获)。 -

--

To override this limitation you can use Google Chrome -- or Chromium in application mode. -+

如果您想解除这个限制,您可以在应用程序模式下使用Google Chrome -+ 或 Chromium。 -

-
-
-
--

PiKVM Project  |  Documentation  |  Support

-+

PiKVM 项目  |  文档  |  支持

- - - -diff -ur /usr/share/kvmd/web/ipmi/index.html ./ipmi/index.html ---- /usr/share/kvmd/web/ipmi/index.html 2023-11-05 07:33:58.421778307 +0000 -+++ ./ipmi/index.html 2023-11-03 13:46:31.562013637 +0000 -@@ -43,18 +43,17 @@ - - -
--
  ←   [ PiKVM Index ] -+
  ←   [ PiKVM 首页 ] -
--

This PiKVM device has running kvmd-ipmi daemon and provides IPMI 2.0 interface for some basic -- BMC operations like on/off/reset the server. -+

这是一个运行kvmd-ipmi守护程序的PiKVM设备,并提供IPMI 2.0接口进行基本服务器管理操作,如开关机/重置。 -

--

WARNING! We strongly don't recommend you to use IPMI in untrusted networks because -- this protocol is completely unsafe by design. In short, the authentication process for IPMI mandates -- that the server send a salted SHA1 or MD5 hash of the requested user's password to the client, -- prior to the client authenticating. -+

警告! 我们不建议在不受信任的网络中使用IPMI, -+ 因为这种协议的设计目的是完全不可信的设计。 -+ 总之,IPMI的认证过程要求服务器将请求用户的密码的SHA1或MD5散列发送给客户端, -+ 以便客户端进行身份验证。 -

--

NEVER use the same passwords for KVMD and IPMI users. And even better not to use IPMI. -- Instead, you can directly use KVMD API via curl. Here some examples: -+

静止 请确保KVMD和IPMI用户使用相同的密码。 -+ 最好不使用IPMI,而是直接通过curl使用KVMD API。示例: -

-
-
-diff -ur /usr/share/kvmd/web/kvm/index.html ./kvm/index.html ---- /usr/share/kvmd/web/kvm/index.html 2023-11-05 07:33:58.421778307 +0000 -+++ ./kvm/index.html 2023-11-05 02:32:19.506363158 +0000 -@@ -25,7 +25,7 @@ - - - -- PiKVM Session -+ PiKVM 会话 - - - -@@ -66,11 +66,11 @@ -
The Open Source IP-KVMIP-KVM
- - -- -+ - - -- -+ - -
Raspberry Pi's health is at risk机器处于危险状态
This is not a drill! A red icon indicates a current issue,
-- a yellow one that was observed since the device booted up
不要忽视!红色图标表示当前存在问题,
-+ 黄色图标表示自设备启动以来观察到的问题。
- -@@ -80,11 +80,10 @@ - - - -- -+ - - -- -+ - -
Undervoltage detected检测到低电压
Make sure your power supply and cabling are providing
-- enough power to the Raspberry Pi (3A minimum)
确保电源和电缆能为 Raspberry Pi 提供
足够的电力(至少3A)
- -@@ -95,11 +94,10 @@ - - - -- -+ - - -- -+ - -
Overheating detected检测到过热
Frequency capping due to overheating,
-- improve cooling of the Raspberry Pi
过热导致的频率上限,
请改善机器的散热
- -@@ -114,11 +112,11 @@ - - - -- -+ - - -- -+ - -
Raspberry Pi's health is at risk机器处于危险状态
This is not a drill! A red icon indicates a current issue,
-- a yellow one that was observed in the past
不要忽视! 红色图标表示当前问题,
-+ 黄色图标表示过去发现的问题
- -@@ -128,10 +126,10 @@ - - - -- -+ - - -- -+ - -
Fan failed风扇故障
A fan error occured, please check the log出现风扇错误,请查看日志
- -@@ -139,22 +137,22 @@ - - - --
  • System -+
  • 系统 - -@@ -175,7 +173,7 @@ - - - -- -+ - -
    H.264 is not supported by this browser此浏览器不支持 H.264
    - -@@ -183,20 +181,20 @@ - - - -- -+ - - - -- -+ - - - - -- -+ - -@@ -210,14 +208,14 @@ - - - -- -+ - - - - -- -+ - - - -- -+ - -@@ -237,21 +235,21 @@ -
    Resolution:分辨率: - -
    JPEG quality:JPEG 质量: - -
    H.264 kbps:H.264 码率(kbps): - -
    Max FPS:最大帧率: - -
    Video mode:视频 模式: -
    - -@@ -228,7 +226,7 @@ -
    Audio volume:音频音量: - -
    -
    -
    -- -- -- -+ -+ -+ -
    -
    -
    - - -- -+ - - - -- -+ - -@@ -259,25 +257,25 @@ -
    Keyboard mode:键盘样式: -
    -
    Mouse mode:鼠标 模式: -
    -
    -
    -
    -- Mouse settings -+ 鼠标设置 -
    - - -- -+ - - - - -- -+ - - - - -- -+ - - - -- -+ -
    Polling interval:轮询间隔: - -
    Relative sensitivity:相对灵敏度: - -
    Squash relative moves:壁球相对动作: -
    - -@@ -286,7 +284,7 @@ -
    Reverse scrolling:反向滚动: -
    - -@@ -299,7 +297,7 @@ - - - -- -+ - - - -- -+ - - - -- -+ - - - -- -+ - - - -- -+ -
    Connect HID to Server:将 HID 连接到主机: -
    - -@@ -308,7 +306,7 @@ -
    Mute HID input events:忽略 HID 输入事件: -
    - -@@ -317,16 +315,16 @@ -
    Connect main USB to Server:将主 USB 连接到主机: -
    -- -+ - -
    -
    Enable locator LED:启用定位 LED: -
    - -@@ -335,7 +333,7 @@ -
    Ask page close confirmation:页面关闭确认: -
    - -@@ -346,18 +344,18 @@ -
    -
    -
    -- -- -+ -+ -
    -
    - -
  • ATX - -
  • --
  • Drive -+
  • 外设 - -@@ -423,10 +421,10 @@ - - - -- -+ - - -- -+ - -
    Current image is out of storage当前镜像已超出存储空间
    This image was connected manually using kvmd-otgmsd该镜像是kvmd-otgmsd通过手动连接的
    - -@@ -437,12 +435,12 @@ - - - -- -+ - - -- -+ - -
    Read-write mode is enabled读写模式已启用
    Do not turn off PiKVM while this is active to prevent
    -- filesystem corruption. Use read-only mode where possible,
    -- as writing to SD card often can reduce its lifespan.
    为防止文件系统损坏,请勿关闭 PiKVM。
    -+ 尽可能使用只读模式,
    -+ 因为经常写入 SD 卡会缩短其使用寿命。
    - -@@ -453,10 +451,10 @@ - - - -- -+ - - -- -+ - -
    The image is being downloaded from PiKVM镜像正在从 PiKVM 下载
    Please wait请稍等
    - -@@ -464,7 +462,7 @@ - - - -- -+ - -@@ -478,7 +476,7 @@ -
    Image:镜像: - -
    - - -- -+ - - -- -+ -
    Drive mode:Drive 格式: -
    - -@@ -488,7 +486,7 @@ -
    -
     Writable:可写: -
    - -@@ -503,9 +501,9 @@ -
    -
    -
    -- -- -- -+ -+ -+ -
    - -@@ -522,13 +520,13 @@ -
    - - -- -+ - - - -- -+ - -@@ -537,12 +535,12 @@ -
    -
    Specify a local file:指定本地文件: - -
    Or paste a URL:Or 粘贴一条 URL: - -
    - -- -- -+ -+ - - - -- -+ - -
    Note:• Don't close the browser page until the upload is complete.注意:• 上传完成前不要关闭浏览器页面。
    • To speed up the upload, close the stream window.• 如果要加快上传速度,请关闭视频窗口。
    - -@@ -550,11 +548,11 @@ -
    - - -- -+ - - - -- -+ - - -
    New image:新的镜像:
    Upload size:上传大小:
    -@@ -564,38 +562,38 @@ - -
    -
    -- -- -- -+ -+ -+ -
    - - --
  • Macro -+
  • -