From 0ad3a95b3023bc3320798e41f53fa858593fa33a Mon Sep 17 00:00:00 2001 From: Alex Oprea Date: Fri, 19 May 2017 14:38:56 +0200 Subject: [PATCH] netmode: script to simulate power-off hotplug net events (of course): The event that happened when the router was powered off is simulated by this script. Triggered by /etc/init.d/done from base-files. --- .../files/sbin/netmode-repeater-correction | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 inteno-netmodes/files/sbin/netmode-repeater-correction diff --git a/inteno-netmodes/files/sbin/netmode-repeater-correction b/inteno-netmodes/files/sbin/netmode-repeater-correction new file mode 100755 index 000000000..6a41ec307 --- /dev/null +++ b/inteno-netmodes/files/sbin/netmode-repeater-correction @@ -0,0 +1,19 @@ +#!/bin/sh + +MTK=0 +[ "$(db -q get hw.board.hardware)" == "EX400" ] && MTK=1 + +if [ $MTK -eq 1 ]; then + WANDEV="eth0.2" + link=$(swconfig dev switch0 port 0 get link | awk '{print$2}' | cut -d':' -f2) +else + WANDEV="$(uci get layer2_interface_ethernet.Wan.ifname)" + link=$(cat /sys/class/net/${WANDEV:0:4}/operstate) +fi + +[ "$link" == "up" ] && action=add +[ "$link" == "down" ] && action=remove +[ -z "$action" ] && exit + +# trigger a fake hotplug net event +INTERFACE=$WANDEV ACTION=$action /sbin/hotplug-call net