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 +