From 8aee3ac70d2b1df726b668c042b20d673064ed19 Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Fri, 20 Sep 2024 21:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20otg=20=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/init.sh | 5 +++++ configs/kvmd/clean_when_exit.sh | 15 +++++++++++++++ configs/kvmd/supervisord.conf | 14 +++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 configs/kvmd/clean_when_exit.sh diff --git a/build/init.sh b/build/init.sh index ab187f06..722f84e3 100755 --- a/build/init.sh +++ b/build/init.sh @@ -134,7 +134,12 @@ fi if [ "$OTG" == "1" ]; then echo "Trying OTG Port..." python -m kvmd.apps.otg start + if [ -f /dev/hidg0 ] && [ -f /dev/hidg1 ]; then + ln -s /dev/hidg1 /dev/kvmd-hid-mouse && ln -s /dev/hidg0 /dev/kvmd-hid-keyboard + fi fi + + echo -e "${GREEN}One-KVM starting...${NC}" exec supervisord -c /etc/kvmd/supervisord.conf \ No newline at end of file diff --git a/configs/kvmd/clean_when_exit.sh b/configs/kvmd/clean_when_exit.sh new file mode 100755 index 00000000..337286d1 --- /dev/null +++ b/configs/kvmd/clean_when_exit.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cleanup() { + if [ "$OTG" == "1" ]; then + echo "Trying exit OTG Port..." + python -m kvmd.apps.otg stop + fi + exit 0 +} + +trap cleanup SIGTERM + +while true; do + sleep 3600 +done \ No newline at end of file diff --git a/configs/kvmd/supervisord.conf b/configs/kvmd/supervisord.conf index 1ce0fa43..9867da32 100644 --- a/configs/kvmd/supervisord.conf +++ b/configs/kvmd/supervisord.conf @@ -41,4 +41,16 @@ priority=100 stopasgroup=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes = 0 -redirect_stderr=true \ No newline at end of file +redirect_stderr=true + +[program:clean_when_exit] +command=/etc/kvmd/clean_when_exit.sh +autostart=true +autorestart=true +startsecs=10 +priority=200 +stopasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes = 0 +redirect_stderr=true +