chore(usbgadget): update usbgadget config only when needed (#474)

This commit is contained in:
Aveline
2025-05-19 21:48:43 +02:00
committed by GitHub
parent 0a4a1af80e
commit 7a9fb7cbb1
14 changed files with 1357 additions and 221 deletions

View File

@@ -26,6 +26,8 @@ show_help() {
echo "Optional:"
echo " -u, --user <remote_user> Remote username (default: root)"
echo " --run-go-tests Run go tests"
echo " --run-go-tests-only Run go tests and exit"
echo " --run-go-tests-json Run go tests and output JSON"
echo " --skip-ui-build Skip frontend/UI build"
echo " --help Display this help message"
echo
@@ -42,6 +44,8 @@ RESET_USB_HID_DEVICE=false
LOG_TRACE_SCOPES="${LOG_TRACE_SCOPES:-jetkvm,cloud,websocket,native,jsonrpc}"
RUN_GO_TESTS=false
RUN_GO_TESTS_JSON=false
RUN_GO_TESTS_ONLY=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
@@ -67,6 +71,12 @@ while [[ $# -gt 0 ]]; do
;;
--run-go-tests-json)
RUN_GO_TESTS_JSON=true
RUN_GO_TESTS=true
shift
;;
--run-go-tests-only)
RUN_GO_TESTS_ONLY=true
RUN_GO_TESTS=true
shift
;;
--help)
@@ -81,10 +91,6 @@ while [[ $# -gt 0 ]]; do
esac
done
if [ "$RUN_GO_TESTS_JSON" = true ]; then
RUN_GO_TESTS=true
fi
# Verify required parameters
if [ -z "$REMOTE_HOST" ]; then
msg_err "Error: Remote IP is a required parameter"
@@ -98,9 +104,6 @@ if [ "$SKIP_UI_BUILD" = false ]; then
make frontend
fi
msg_info "▶ Building go binary"
make build_dev
if [ "$RUN_GO_TESTS" = true ]; then
msg_info "▶ Building go tests"
make build_dev_test
@@ -117,10 +120,18 @@ if [ "$RUN_GO_TESTS" = true ]; then
set -e
cd ${REMOTE_PATH}
tar zxvf device-tests.tar.gz
./run_all_tests $TEST_ARGS
PION_LOG_TRACE=all ./run_all_tests $TEST_ARGS
EOF
if [ "$RUN_GO_TESTS_ONLY" = true ]; then
msg_info "▶ Go tests completed"
exit 0
fi
fi
msg_info "▶ Building go binary"
make build_dev
# Kill any existing instances of the application
ssh "${REMOTE_USER}@${REMOTE_HOST}" "killall jetkvm_app_debug || true"
@@ -128,6 +139,8 @@ ssh "${REMOTE_USER}@${REMOTE_HOST}" "killall jetkvm_app_debug || true"
ssh "${REMOTE_USER}@${REMOTE_HOST}" "cat > ${REMOTE_PATH}/jetkvm_app_debug" < bin/jetkvm_app
if [ "$RESET_USB_HID_DEVICE" = true ]; then
msg_info "▶ Resetting USB HID device"
msg_warn "The option has been deprecated and will be removed in a future version, as JetKVM will now reset USB gadget configuration when needed"
# Remove the old USB gadget configuration
ssh "${REMOTE_USER}@${REMOTE_HOST}" "rm -rf /sys/kernel/config/usb_gadget/jetkvm/configs/c.1/hid.usb*"
ssh "${REMOTE_USER}@${REMOTE_HOST}" "ls /sys/class/udc > /sys/kernel/config/usb_gadget/jetkvm/UDC"