mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
switch: add switch_ctl.init to restart mt753x ports when LAN reload
This commit is contained in:
parent
96d850d02a
commit
0e1af68761
@ -42,8 +42,10 @@ endef
|
|||||||
define Package/switch/install
|
define Package/switch/install
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_DIR) $(1)/lib/network
|
$(INSTALL_DIR) $(1)/lib/network
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/switch $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/switch $(1)/usr/sbin/
|
||||||
$(INSTALL_BIN) ./files/switch_ctl.sh $(1)/usr/sbin/
|
$(INSTALL_BIN) ./files/switch_ctl.sh $(1)/usr/sbin/
|
||||||
|
$(INSTALL_BIN) ./files/switch_ctl.init $(1)/etc/init.d/switch_ctl
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,switch))
|
$(eval $(call BuildPackage,switch))
|
||||||
|
16
package/mtk/applications/switch/files/switch_ctl.init
Normal file
16
package/mtk/applications/switch/files/switch_ctl.init
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=99
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_interface_trigger "lan"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
logger -t "switch_ctl" "restart mt753x all ports"
|
||||||
|
source "/usr/sbin/switch_ctl.sh"
|
||||||
|
sw_poweroff_ports "0 1 2 3 4"
|
||||||
|
sleep 3
|
||||||
|
sw_poweron_ports "0 1 2 3 4"
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
[ ! -x /usr/sbin/switch ] && exit 1
|
[ ! -x /usr/sbin/switch ] && return
|
||||||
|
|
||||||
# power off ports
|
# power off ports
|
||||||
# $1 ports list, ex: "1 2 3"
|
# $1 ports list, ex: "1 2 3"
|
||||||
@ -14,7 +14,7 @@ sw_poweroff_ports() {
|
|||||||
|
|
||||||
# register 0, bit 11 is power down control bit, set to 1
|
# register 0, bit 11 is power down control bit, set to 1
|
||||||
set_value=$(($ori_value | 0x800))
|
set_value=$(($ori_value | 0x800))
|
||||||
switch phy cl22 w $p 0 $set_value
|
switch phy cl22 w $p 0 $set_value >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ sw_poweron_ports() {
|
|||||||
|
|
||||||
# register 0, bit 11 is power down control bit, set to 0
|
# register 0, bit 11 is power down control bit, set to 0
|
||||||
set_value=$(($ori_value & ~0x800))
|
set_value=$(($ori_value & ~0x800))
|
||||||
switch phy cl22 w $p 0 $set_value
|
switch phy cl22 w $p 0 $set_value >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
# restart Auto-neg on ports
|
# restart Auto-neg on ports
|
||||||
@ -45,6 +45,6 @@ sw_restart_port() {
|
|||||||
|
|
||||||
# register 0, bit 9 is Restart Auto-Negotiation bit, set to 1
|
# register 0, bit 9 is Restart Auto-Negotiation bit, set to 1
|
||||||
set_value=$(($ori_value | 0x200))
|
set_value=$(($ori_value | 0x200))
|
||||||
switch phy cl22 w $p 0 $set_value
|
switch phy cl22 w $p 0 $set_value >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user