network: code optimization for speed and removal/cornering of obsolete functions
This commit is contained in:
parent
57701f3c38
commit
94b6db3676
@ -15,9 +15,6 @@ me="network"
|
||||
|
||||
. /etc/postplug/postplug.defs
|
||||
|
||||
postplugnew_file=$postplugnewdir/network
|
||||
rm -f $postplugnew_file
|
||||
|
||||
[ -r /etc/sysconfig/postplug ] && . /etc/sysconfig/postplug
|
||||
|
||||
[ -r /etc/sysconfig/rc ] && . /etc/sysconfig/rc
|
||||
@ -66,7 +63,7 @@ function cdc_usb() {
|
||||
|
||||
ifconfig usb0 &>/dev/null && {
|
||||
[ "$NETWORK_CDC_NETMASK" ] && CDC_NETMASK=$NETWORK_CDC_NETMASK
|
||||
[ -e $network_devices/ifcng-usb0 ] || {
|
||||
[ -e $network_devices/ifcfg-usb0 ] || {
|
||||
[ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR
|
||||
cat > $network_devices/ifcfg-usb0 << _EOF
|
||||
DEVICE=usb0
|
||||
@ -144,34 +141,43 @@ _EOF
|
||||
[ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb
|
||||
[ "$NETWORK_ANDROID_DISABLE" = "1" ] || android_usb
|
||||
|
||||
wlan_ints=()
|
||||
for wlan_int in $(cat /proc/net/wireless 2>/dev/null | sed -n '/[a-z]*[0-9]*:/{s,:.*,,;p}'); do
|
||||
# checks for existing physical interfaces
|
||||
/sbin/ifconfig $wlan_int >/dev/null 2>&1 || continue
|
||||
# Disable p2p interface managed by NetworkManager
|
||||
for net_int in $(cat /proc/net/dev | sed -n '/p2p[0-9]*:/{s,:.*,,;p}'); do
|
||||
# found interface already configured
|
||||
[ -e $network_devices/ifcfg-${net_int} ] && continue
|
||||
|
||||
if [ "${net_int:0:3}" = "p2p" ]; then
|
||||
P2P_HWADDR=`ifconfig $net_int | grep HWaddr | sed "s|.* HWaddr ||"`
|
||||
cat > $network_devices/ifcfg-${net_int} << _EOF
|
||||
DEVICE=$net_int
|
||||
HWADDR=$P2P_HWADDR
|
||||
ONBOOT=no
|
||||
NM_CONTROLLED=no
|
||||
_EOF
|
||||
fi
|
||||
done
|
||||
|
||||
# INFO: the following code is going obsolete
|
||||
if [ "$NETWORK_NEWDEVICE" -a "$NETWORK_NEWDEVICE" != "off" ]; then
|
||||
|
||||
wlan_ints=()
|
||||
for wlan_int in $(cat /proc/net/wireless 2>/dev/null | sed -n '/[a-z]*[0-9]*:/{s,:.*,,;p}'); do
|
||||
# found interface already configured
|
||||
[ -e $network_devices/ifcfg-$wlan_int ] && continue
|
||||
|
||||
wlan_ints[${#wlan_ints[*]}]="$wlan_int"
|
||||
echo "$wlan_int" >> $postplugnew_file 2>/dev/null
|
||||
done
|
||||
|
||||
eth_ints=()
|
||||
for eth_int in $(cat /proc/net/dev | sed -n '/eth[0-9]*:/{s,:.*,,;p}'); do
|
||||
# checks for existing physical interfaces
|
||||
/sbin/ifconfig $eth_int >/dev/null 2>&1 || continue
|
||||
done
|
||||
|
||||
eth_ints=()
|
||||
for eth_int in $(cat /proc/net/dev | sed -n '/eth[0-9]*:/{s,:.*,,;p}'); do
|
||||
# found interface already configured
|
||||
[ -e $network_devices/ifcfg-$eth_int ] && continue
|
||||
|
||||
eth_ints[${#eth_ints[*]}]="$eth_int"
|
||||
echo "$eth_int" >> $postplugnew_file 2>/dev/null
|
||||
done
|
||||
done
|
||||
|
||||
# how many interface have been configured?
|
||||
let "int_newconf = 0"
|
||||
# how many interface have been configured?
|
||||
let "int_newconf = 0"
|
||||
|
||||
if [ ${#eth_ints[*]} -gt 0 ]; then
|
||||
if [ ${#eth_ints[*]} -gt 0 ]; then
|
||||
case "$NETWORK_NEWDEVICE" in
|
||||
"auto")
|
||||
for eth_int in ${eth_ints[*]}; do
|
||||
@ -188,9 +194,9 @@ illegal value for NETWORK_NEWDEVICE ($NETWORK_NEWDEVICE)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${#wlan_ints[*]} -gt 0 ]; then
|
||||
if [ ${#wlan_ints[*]} -gt 0 ]; then
|
||||
case "$NETWORK_NEWDEVICE" in
|
||||
"auto")
|
||||
for wlan_int in ${wlan_ints[*]}; do
|
||||
@ -200,6 +206,7 @@ if [ ${#wlan_ints[*]} -gt 0 ]; then
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user