mynode/rootfs/standard/usr/bin/mynode_usb_driver_check.sh

39 lines
1.0 KiB
Bash
Raw Normal View History

2019-10-14 01:47:14 +00:00
#!/bin/bash
set -x
source /usr/share/mynode/mynode_config.sh
lsusb -t | grep "Driver=uas"
if [ $? -eq 0 ]; then
echo "UAS FOUND"
read PORT DEV <<< $(lsusb -t | grep 'Driver=uas' | head -n 1 | awk '{ print $3,$5 }')
PORT=$(egrep -o '[0-2]+' <<< $PORT)
DEV=$(egrep -o '[0-2]+' <<< $DEV)
USBINFO=$(lsusb -s $PORT:$DEV)
DEVID=$(egrep -o '[0-9a-f]+:[0-9a-f]+' <<< $USBINFO)
#echo $DEVID
if [ $IS_RASPI -eq 1 ]; then
2020-01-21 00:35:36 +00:00
if [ -f /boot/cmdline.txt ]; then
QUIRK="${DEVID}:u"
CMDLINE=$(head -n 1 /boot/cmdline.txt)
cat /boot/cmdline.txt | grep "usb-storage.quirks"
if [ $? -eq 0 ]; then
sed -i "s/usb-storage.quirks=.*/usb-storage.quirks=${QUIRK}/g" /boot/cmdline.txt
sync
exit 0
else
echo "${CMDLINE} usb-storage.quirks=${QUIRK}" > /boot/cmdline.txt
fi
2019-10-17 03:31:48 +00:00
sync
2020-01-21 00:35:36 +00:00
sleep 5s
reboot
2019-10-14 01:47:14 +00:00
fi
fi
else
echo "No UAS devices found"
fi