12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/bin/sh
- #(c) Copyright Barry Kauler Dec. 2010, License: GPL v3 /usr/share/doc/legal
- #called from pupdial.
- #got code out of rc.shutdown.
- #shutdown network interfaces, except for ppp
- #100814 log the cumulative bytes transmitted on network...
- # (see also /etc/rc.d/rc.sysinit and network_tray)
- ACTIVE_INTERFACE=""
- [ -f /tmp/sns_interface_success ] && ACTIVE_INTERFACE="`cat /tmp/sns_interface_success`" #SNS
- [ ! "$ACTIVE_INTERFACE" ] && ACTIVE_INTERFACE="`ifconfig | grep '^[a-z]' | grep -v '^lo' | grep -v '^ppp' | grep 'Link encap:Ethernet' | cut -f 1 -d ' ' | head -n 1`"
- if [ "$ACTIVE_INTERFACE" ];then
- if [ -d /sys/class/net/${ACTIVE_INTERFACE}/statistics ];then
- RX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/rx_bytes`"
- TX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/tx_bytes`"
- echo -n "$RX_BYTES" > /var/local/sns/rx_bytes_session
- echo -n "$TX_BYTES" > /var/local/sns/tx_bytes_session
- RX_BYTES_MONTH=`cat /var/local/sns/rx_bytes_month`
- RX_BYTES_MONTH=`expr $RX_BYTES_MONTH + $RX_BYTES`
- echo -n "$RX_BYTES_MONTH" > /var/local/sns/rx_bytes_month
- TX_BYTES_MONTH=`cat /var/local/sns/tx_bytes_month`
- TX_BYTES_MONTH=`expr $TX_BYTES_MONTH + $TX_BYTES`
- echo -n "$TX_BYTES_MONTH" > /var/local/sns/tx_bytes_month
- fi
- fi
- [ "`pidof wpa_supplicant`" != "" ] && wpa_cli terminate #100309 kills any running wpa_supplicant.
- if [ "`grep 'net-setup.sh' /usr/local/bin/defaultconnect`" = "" ];then #see connectwizard and connectwizard_2nd.
- for ONENETIF in `ifconfig | grep -E '^wifi[0-9]|^wlan[0-9]|^eth[0-9]' | cut -f 1 -d ' ' | tr '\n' ' '`
- do
- ifconfig $ONENETIF down 2> /dev/null
- [ "`iwconfig | grep "^${ONENETIF}" | grep "ESSID"`" != "" ] && iwconfig $ONENETIF essid off #100309
- dhcpcd --release $ONENETIF 2>/dev/null #100309
- done
- else
- /etc/rc.d/rc.network stop
- fi
- ###END###
|