the script will be placed in /etc/hotplug.d/usb/30-rtl8152.sh
#!/bin/sh
[[ "$ACTION" = add -a "$DEVTYPE" = usb_device ]] || exit 0
logger -t "RTL8152 Script" "Checking USB";
if $(lsusb | grep "0bda:8152");then
logger -t "RTL8152 Script" "USB Connected";
until $(uci get network.wan2.ifname);do
if [[ $(uci get network.wan2.ifname) = wan2 ]];then
logger -t "RTL8152 Script" "Applying to WAN2";
uci set network.wan2.ifname='eth1';
uci set network.wan2.hostname=$(uci show system.@system[0].hostname | sed 's/^.*hostname=//g' | sed "s/'//g");
uci commit network.wan2;
sync;
ifup wan2;
service network reload;
fi;
done;
fi;
logger -t "RTL8152 Script" "Script Finished";
exit 0
why logread -e "RTL8152 Script"
only print last if ("RTL8152 Script" "Applying to WAN2"
) ?