diff --git a/dongle_hotplug b/dongle_hotplug index 6160461bc893fa9fc8b9cb532cd36d9dc517d514..0a05559b20a1a148734d0548ba003b9fe1d3dc3f 100755 --- a/dongle_hotplug +++ b/dongle_hotplug @@ -1,32 +1,26 @@ #echo "DEVTYPE - $DEVTYPE " > /dev/console #echo "DEVPATH - $DEVPATH " > /dev/console - -if [ "$ACTION" == "remove" ]; then - #echo "tmp file removed!" > /dev/console - rm -r /tmp/donglehotplug -fi - -if [[ -f /tmp/donglehotplug ]] ; then - #echo "File exists" > /dev/console - exit -fi - -DEV_MOUNTPATH=`echo "$DEVPATH" | cut -d'/' -f 1-6` +DEV_MOUNTPATH=`echo "$DEVPATH" | cut -d'/' -f 1-7` +JUNK=`echo "$DEVPATH" | cut -d'/' -f 8` +#echo "dev_path: $DEVPATH" > /dev/console #echo "dongle path: $DEV_MOUNTPATH" > /dev/console - +#echo "JUNK: $JUNK" > /dev/console case "$ACTION" in - add) - ubus call dongle alert '{"path":"/sys'${DEV_MOUNTPATH}'"}' - echo "ubus call dongle alert '{\"path\":\"/sys$DEV_MOUNTPATH\"}'" > /dev/console - touch /tmp/donglehotplug - ;; - remove) - echo "dongle removed!" - ;; - *) - echo "Action: Neither add nor remove" > /dev/console - ;; + add) + if [ -z "$JUNK" ];then + ubus call dongle alert '{"path":"/sys'${DEV_MOUNTPATH}'"}' + echo "ubus call dongle alert '{\"path\":\"/sys$DEV_MOUNTPATH\"}'" > /dev/console + touch /tmp/donglehotplug + fi + ;; + remove) + echo "dongle removed!" + ubus call dongle update + ;; + *) + echo "Action: Neither add nor remove" > /dev/console + ;; esac