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

57 lines
1.8 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
2022-02-04 03:23:22 +00:00
# Allow UAS
if [ -f /mnt/hdd/mynode/settings/.uas_usb_enabled ] || [ -f /home/bitcoin/.mynode/.uas_usb_enabled ]; then
cat /boot/cmdline.txt | grep "usb-storage.quirks="
if [ $? -eq 0 ]; then
cat /boot/cmdline.txt | grep "usb-storage.quirks=none"
if [ $? -eq 0 ]; then
exit 0
else
sed -i "s/usb-storage.quirks=.*/usb-storage.quirks=none/g" /boot/cmdline.txt
sync
/usr/bin/mynode-reboot
fi
fi
exit 0
else
# Disable UAS
lsusb -t | grep "Driver=uas"
if [ $? -eq 0 ]; then
echo "UAS FOUND"
USBINFO=$(lsusb | grep "SATA 6Gb/s bridge")
DEVID=$(egrep -o '[0-9a-f]+:[0-9a-f]+' <<< $USBINFO)
#echo $DEVID
2019-10-14 01:47:14 +00:00
2022-02-04 03:23:22 +00:00
if [ $IS_RASPI -eq 1 ]; then
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
cat /boot/cmdline.txt | grep "usb-storage.quirks=${QUIRK}"
if [ $? -eq 0 ]; then
# Quirk already added, exit 0
exit 0
else
# Different quirk exists, update and reboot
sed -i "s/usb-storage.quirks=.*/usb-storage.quirks=${QUIRK}/g" /boot/cmdline.txt
fi
else
# No quirk found, add it and reboot
echo "${CMDLINE} usb-storage.quirks=${QUIRK}" > /boot/cmdline.txt
fi
2019-10-14 01:47:14 +00:00
2020-01-21 00:35:36 +00:00
sync
2022-02-04 03:23:22 +00:00
sleep 5s
/usr/bin/mynode-reboot
2020-01-21 00:35:36 +00:00
fi
2019-10-14 01:47:14 +00:00
fi
2022-02-04 03:23:22 +00:00
else
echo "No UAS devices found"
2019-10-14 01:47:14 +00:00
fi
2022-02-04 03:23:22 +00:00
fi