modemdisconnect 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. #130505 rerwin: notify network_tray of analog/wireless connection type
  3. #Disconnect from ISP and update usage statistics...
  4. [ "`ps aux | grep -w 'wvdial' | grep -v 'grep'`" = "" ] && exit
  5. #Collect transmission data...
  6. if [ -e /var/local/pupdial/isp ];then
  7. ACTIVE_INTERFACE="`ifconfig | grep -m 1 -o '^ppp[0-9]'`"
  8. if [ "$ACTIVE_INTERFACE" != "" ] \
  9. && [ -d /sys/class/net/${ACTIVE_INTERFACE}/statistics ];then
  10. RX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/rx_bytes`"
  11. TX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/tx_bytes`"
  12. RX_BYTES_MONTH=`cat /var/local/pupdial/isp/rx_bytes_month`
  13. RX_BYTES_MONTH=`expr $RX_BYTES_MONTH + $RX_BYTES`
  14. echo -n "$RX_BYTES_MONTH" > /var/local/pupdial/isp/rx_bytes_month
  15. TX_BYTES_MONTH=`cat /var/local/pupdial/isp/tx_bytes_month`
  16. TX_BYTES_MONTH=`expr $TX_BYTES_MONTH + $TX_BYTES`
  17. echo -n "$TX_BYTES_MONTH" > /var/local/pupdial/isp/tx_bytes_month
  18. fi
  19. fi
  20. rm -f /etc/ppp/peers/wvdial
  21. rm -f /etc/ppp/peers/wvdial-pipe 2>/dev/null #432
  22. killall wvdial
  23. killall pppd
  24. rm -f /tmp/.network_tray-use_analog_dialup_icons 2>/dev/null #130505