#!/bin/bash BackupRestoreDir=BackupRestoreDir # Function to check if "NVIDIA Corp. APX" is present in lsusb output function check_for_usb() { echo "Waiting for 'NVIDIA Corp. APX' in lsusb output..." echo "Please put the jetson in Recovery mode" while ! lsusb | grep -q "NVIDIA Corp. APX"; do sleep 1 # Wait for 1 second before checking again done } check_for_usb # Execute the specific command inside the located directory cd /home/$USER/.dcs_deploy/flash/xavier_nx_nvme_1.2_51_full/Linux_for_Tegra/tools/kernel_flash pwd sleep 3 sudo ./l4t_initrd_flash.sh --flash-only --external-only --external-device nvme0n1p1 -c flash_l4t_external_custom.xml --showlogs airvolute-dcs1.2+p3668-0001-qspi-emmc nvme0n1p1 # Add a message to indicate that the script has finished echo "Script completed." # Check for "NVIDIA Corp. APX" in lsusb output before continuing check_for_usb # Additional lines to enter another directory and run a command additional_directory="~/$BackupRestoreDir/Linux_for_Tegra" additional_directory=$(eval echo "$additional_directory") if [ -d "$additional_directory" ]; then # The additional directory exists, cd into it and run the command echo "Entering '$additional_directory' and running additional command." cd "$additional_directory" sudo ./tools/backup_restore/l4t_backup_restore.sh -r airvolute-dcs1.2+p3668-0001-qspi-emmc else echo "Error: Additional directory not found." fi # Your variables hostname="fe80::1%usb0" username="root" password="root" # SSH command to connect and reboot sshpass -p "$password" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$username@$hostname" "reboot" read -p "Press Enter to close this terminal"