From 981870c6c1ab72c6f422f149d9074f084eb1bf64 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakobols@kth.se> Date: Tue, 12 Jun 2018 09:25:43 +0200 Subject: [PATCH] remove dongle_hotplug dependency on some bool-file, different static approach --- dongle_hotplug | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/dongle_hotplug b/dongle_hotplug index 6160461..0a05559 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 -- GitLab