2
0

trelay.init 702 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh /etc/rc.common
  2. START=80
  3. check_relay() {
  4. local cfg="$1"
  5. config_get_bool enabled "$cfg" enabled 1
  6. [ "$enabled" -gt 0 ] || return
  7. config_get dev1 "$cfg" dev1
  8. config_get dev2 "$cfg" dev2
  9. [ -d "/sys/kernel/debug/trelay/${dev1}-${dev2}" ] && return
  10. [ -d "/sys/class/net/${dev1}" -a -d "/sys/class/net/${dev2}" ] || return
  11. ip link set dev "$dev1" up
  12. ip link set dev "$dev2" up
  13. echo "${dev1}-${dev2},${dev1},${dev2}" > /sys/kernel/debug/trelay/add
  14. }
  15. start() {
  16. config_load trelay
  17. config_foreach check_relay trelay
  18. touch /var/run/trelay.active
  19. }
  20. stop() {
  21. rm -f /var/run/trelay.active
  22. for relay in /sys/kernel/debug/trelay/*; do
  23. [ -d "$relay" ] && echo > "$relay/remove"
  24. done
  25. }