Root/package/base-files/files/sbin/ifdown

1#!/bin/sh
2# Copyright (C) 2006 OpenWrt.org
3
4. /etc/functions.sh
5[ $# = 0 ] && { echo " $0 <group>"; exit; }
6[ "x$1" = "x-a" ] && {
7    [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
8    config_cb() {
9        [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
10    }
11    config_load network
12    exit
13}
14
15include /lib/network
16scan_interfaces
17
18cfg=$1
19debug "### ifdown $cfg ###"
20
21config_get proto "$cfg" proto
22[ -z "$proto" ] && { echo "interface not found."; exit; }
23
24config_get iface "$cfg" device
25[ "static" = "$proto" -o "none" = "$proto" ] && {
26    env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO="$proto" /sbin/hotplug-call "iface"
27}
28
29# call interface stop handler
30( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
31
32config_get ifname "$cfg" ifname
33config_get device "$cfg" device
34
35[ ."$device" != ."$ifname" ] || device=
36for dev in $ifname $device; do
37    ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
38done
39
40config_get iftype "$cfg" type
41[ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
42
43# remove the interface's dns entries
44remove_dns "$cfg"
45
46# remove the interface's network state
47uci_revert_state network "$1"
48
49# revert aliases state as well
50config_get aliases "$1" aliases
51for config in $aliases; do
52    uci_revert_state network "$config"
53done
54

Archive Download this file



interactive