ifdown 826 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. # Copyright (C) 2006 OpenWrt.org
  3. [ $# = 0 ] && { echo " $0 <group>"; exit; }
  4. . /etc/functions.sh
  5. include /lib/network
  6. scan_interfaces
  7. cfg=$1
  8. debug "### ifdown $cfg ###"
  9. config_get proto "$cfg" proto
  10. [ -z "$proto" ] && { echo "interface not found."; exit; }
  11. # kill active ppp daemon
  12. pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
  13. [ -n "$pid" -a -d "/proc/$pid" ] && {
  14. kill $pid
  15. sleep 1
  16. [ -d "/proc/$pid" ] && kill -9 $pid
  17. }
  18. # kill any other process associated with the interface
  19. config_get ifname "$cfg" ifname
  20. pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
  21. [ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
  22. config_get ifname "$cfg" ifname
  23. ifconfig "$ifname" >/dev/null 2>/dev/null && {
  24. ifconfig "$ifname" 0.0.0.0 down
  25. config_get iftype "$cfg" type
  26. [ "$iftype" = "bridge" ] && brctl delbr "$ifname"
  27. }