Add USB driver check service
This commit is contained in:
parent
88c31deacf
commit
b63d814741
22
rootfs/standard/etc/systemd/system/usb_driver_check.service
Normal file
22
rootfs/standard/etc/systemd/system/usb_driver_check.service
Normal file
|
@ -0,0 +1,22 @@
|
|||
# myNode usb driver check
|
||||
# /etc/systemd/system/usb_driver_check.service
|
||||
|
||||
[Unit]
|
||||
Description=myNode USB Driver Check
|
||||
Wants=mynode.service
|
||||
After=mynode.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/mynode_usb_driver_check.sh
|
||||
User=root
|
||||
Group=root
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=mynode
|
||||
|
||||
RestartSec=30
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -154,6 +154,7 @@ fi
|
|||
# Enable any new/required services
|
||||
systemctl enable firewall
|
||||
systemctl enable invalid_block_check
|
||||
systemctl enable usb_driver_check
|
||||
|
||||
# Disable any old services
|
||||
sudo systemctl disable hitch
|
||||
|
|
34
rootfs/standard/usr/bin/mynode_usb_driver_check.sh
Executable file
34
rootfs/standard/usr/bin/mynode_usb_driver_check.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/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
|
||||
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
|
||||
else
|
||||
echo "${CMDLINE} usb-storage.quirks=${QUIRK}" > /boot/cmdline.txt
|
||||
fi
|
||||
|
||||
sync
|
||||
sleep 5s
|
||||
reboot
|
||||
fi
|
||||
else
|
||||
echo "No UAS devices found"
|
||||
fi
|
|
@ -382,6 +382,7 @@ systemctl enable rtl
|
|||
systemctl enable lnd_admin
|
||||
systemctl enable tor
|
||||
systemctl enable invalid_block_check
|
||||
systemctl enable usb_driver_check
|
||||
|
||||
|
||||
# Regenerate MAC Address for Rock64
|
||||
|
|
Loading…
Reference in New Issue
Block a user