From 58bc8e3b43884a186c2054d258b0637aafbb7c7a Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 6 May 2025 10:51:15 -0700 Subject: [PATCH] op: more robust openpilot finding (#35136) --- tools/op.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/op.sh b/tools/op.sh index 25a4670cd1..93e774a2ac 100755 --- a/tools/op.sh +++ b/tools/op.sh @@ -52,6 +52,7 @@ function op_run_command() { # be default, assume openpilot dir is in current directory OPENPILOT_ROOT=$(pwd) function op_get_openpilot_dir() { + # First try traversing up the directory tree while [[ "$OPENPILOT_ROOT" != '/' ]]; do if find "$OPENPILOT_ROOT/launch_openpilot.sh" -maxdepth 1 -mindepth 1 &> /dev/null; then @@ -59,6 +60,14 @@ function op_get_openpilot_dir() { fi OPENPILOT_ROOT="$(readlink -f "$OPENPILOT_ROOT/"..)" done + + # Fallback to hardcoded directories if not found + for dir in "$HOME/openpilot" "/data/openpilot"; do + if [[ -f "$dir/launch_openpilot.sh" ]]; then + OPENPILOT_ROOT="$dir" + return 0 + fi + done } function op_install_post_commit() { @@ -378,11 +387,6 @@ function op_default() { echo " op is only a wrapper for existing scripts, tools, and commands." echo " op will always show you what it will run on your system." echo "" - echo " op will try to find your openpilot directory in the following order:" - echo " 1: use the directory specified with the --dir option" - echo " 2: use the current working directory" - echo " 3: go up the file tree non-recursively" - echo "" echo -e "${BOLD}${UNDERLINE}Usage:${NC} op [OPTIONS] " echo "" echo -e "${BOLD}${UNDERLINE}Commands [System]:${NC}"