mirror of https://github.com/hak5/openwrt.git
parent
3145156ebe
commit
155c4da52b
|
@ -8,8 +8,8 @@ addif() {
|
||||||
|
|
||||||
# find all vlan configurations for this interface and set them up as well
|
# find all vlan configurations for this interface and set them up as well
|
||||||
for ifc in $interfaces; do
|
for ifc in $interfaces; do
|
||||||
config_get type "$ifc" type
|
config_get iftype "$ifc" type
|
||||||
case "$type" in
|
case "$iftype" in
|
||||||
bridge) config_get ifs "$ifc" ifnames;;
|
bridge) config_get ifs "$ifc" ifnames;;
|
||||||
*) config_get ifs "$ifc" ifname;;
|
*) config_get ifs "$ifc" ifname;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
# DEBUG="echo"
|
# DEBUG="echo"
|
||||||
|
|
||||||
find_config() {
|
find_config() {
|
||||||
local type iface ifn
|
local iftype iface ifn
|
||||||
for ifn in $interfaces; do
|
for ifn in $interfaces; do
|
||||||
config_get type "$ifn" type
|
config_get iftype "$ifn" type
|
||||||
config_get iface "$ifn" ifname
|
config_get iface "$ifn" ifname
|
||||||
case "$type" in
|
case "$iftype" in
|
||||||
bridge)
|
bridge)
|
||||||
config_get iface "$ifn" ifnames
|
config_get iface "$ifn" ifnames
|
||||||
;;
|
;;
|
||||||
|
@ -25,15 +25,15 @@ find_config() {
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_interfaces() {
|
scan_interfaces() {
|
||||||
local mode type iface
|
local mode iftype iface
|
||||||
interfaces=
|
interfaces=
|
||||||
config_cb() {
|
config_cb() {
|
||||||
config_get type "$CONFIG_SECTION" TYPE
|
config_get iftype "$CONFIG_SECTION" TYPE
|
||||||
case "$type" in
|
case "$iftype" in
|
||||||
interface)
|
interface)
|
||||||
config_get type "$CONFIG_SECTION" type
|
config_get iftype "$CONFIG_SECTION" type
|
||||||
config_get mode "$CONFIG_SECTION" proto
|
config_get mode "$CONFIG_SECTION" proto
|
||||||
case "$type" in
|
case "$iftype" in
|
||||||
bridge)
|
bridge)
|
||||||
config_get iface "$CONFIG_SECTION" ifname
|
config_get iface "$CONFIG_SECTION" ifname
|
||||||
iface="${iface:-br-$CONFIG_SECTION}"
|
iface="${iface:-br-$CONFIG_SECTION}"
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
include network
|
include network
|
||||||
scan_interfaces
|
scan_interfaces
|
||||||
|
|
||||||
debug "### ifdown $type ###"
|
cfg=$1
|
||||||
type=$1
|
debug "### ifdown $cfg ###"
|
||||||
|
|
||||||
config_get proto "$type" proto
|
config_get proto "$cfg" proto
|
||||||
[ -z "$proto" ] && { echo "interface not found."; exit; }
|
[ -z "$proto" ] && { echo "interface not found."; exit; }
|
||||||
|
|
||||||
# kill active ppp daemon
|
# kill active ppp daemon
|
||||||
pid="$(cat /var/run/ppp-${type}.pid 2>/dev/null)"
|
pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
||||||
[ -n "$pid" -a -d "/proc/$pid" ] && {
|
[ -n "$pid" -a -d "/proc/$pid" ] && {
|
||||||
kill $pid
|
kill $pid
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -21,14 +21,14 @@ pid="$(cat /var/run/ppp-${type}.pid 2>/dev/null)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# kill any other process associated with the interface
|
# kill any other process associated with the interface
|
||||||
config_get ifname "$type" ifname
|
config_get ifname "$cfg" ifname
|
||||||
pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
|
pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
|
||||||
[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
|
[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
|
||||||
|
|
||||||
config_get ifname "$type" ifname
|
config_get ifname "$cfg" ifname
|
||||||
ifconfig "$ifname" >/dev/null 2>/dev/null && {
|
ifconfig "$ifname" >/dev/null 2>/dev/null && {
|
||||||
ifconfig "$ifname" 0.0.0.0 down
|
ifconfig "$ifname" 0.0.0.0 down
|
||||||
|
|
||||||
config_get iftype "$type" type
|
config_get iftype "$cfg" type
|
||||||
[ "$iftype" = "bridge" ] && brctl delbr "$ifname"
|
[ "$iftype" = "bridge" ] && brctl delbr "$ifname"
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,12 @@ config_load wireless
|
||||||
include wifi
|
include wifi
|
||||||
|
|
||||||
for device in $DEVICES; do (
|
for device in $DEVICES; do (
|
||||||
config_get type "$device" type
|
config_get iftype "$device" type
|
||||||
eval "type setup_$type" 2>/dev/null >/dev/null && {
|
eval "type setup_$iftype" 2>/dev/null >/dev/null && {
|
||||||
eval "scan_$type '$device'"
|
eval "scan_$iftype '$device'"
|
||||||
eval "setup_$type '$device'" && {
|
eval "setup_$iftype '$device'" && {
|
||||||
# TODO: set up network settings
|
# TODO: set up network settings
|
||||||
/bin/true
|
/bin/true
|
||||||
} || echo "$device($type): Setup failed" || true
|
} || echo "$device($iftype): Setup failed" || true
|
||||||
} || echo "$device($type): Interface type not supported"
|
} || echo "$device($iftype): Interface type not supported"
|
||||||
); done
|
); done
|
||||||
|
|
|
@ -5,8 +5,8 @@ bridge_interface() {
|
||||||
scan_interfaces
|
scan_interfaces
|
||||||
cfg="$(find_config "$1")"
|
cfg="$(find_config "$1")"
|
||||||
[ -z "$cfg" ] && return 0
|
[ -z "$cfg" ] && return 0
|
||||||
config_get type "$cfg" type
|
config_get iftype "$cfg" type
|
||||||
[ "$type" = bridge ] && config_get "$type" bridge
|
[ "$iftype" = bridge ] && config_get "$iftype" bridge
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue