#!/bin/bash # Company: PowerCraft Technology # Author: Copyright Jelle de Jong # Note: Please send me an email if you enhanced the script # Version: 0.0.2 # Date: 2008-03-31 / 2009-06-04 # System: Ubuntu/Debian GNU/Linux # Description: Monitor a HSDPA connection with the USB Huawei Modems # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more de/usr/bin/tails. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. unset ipaddress maximum=30 count=0 while [ -z "$ipaddress" ] && [ "$count" -lt "$maximum" ] do count=$(($count+1)) cd /sys/class/net/ for interface in * do if [ "$interface" = "ppp0" ] && [ -z "$ipaddress" ] then ipaddress=$(/sbin/ifconfig $interface | /bin/grep 'inet addr:' | /usr/bin/cut -d: -f2 | /usr/bin/awk '{ print $1}') case "$ipaddress" in *.*.*.*) /bin/echo "received ipaddress: $ipaddress" ;; esac fi done if [ -z "$ipaddress" ] then /bin/sleep 2 && /bin/echo -ne "...get ipaddress trial: $count/$maximum \r" fi done if [ -n "$ipaddress" ] then # ping -q -c 1 google.com >/dev/null 2>&1 # if [ ! "$?" -eq 0 ]; then # echo "ipaddress: $ipaddress, but no successful dns resolve" # exit 1 # fi /bin/echo "starting screen session ppp-monitor in background" active=$(ps ax | grep ppp-monitor | grep bwm-ng) [ -n "$active" ] && /usr/bin/screen -x ppp-monitor -X quit && echo "closing existing screen session" /usr/bin/screen -d -m -S ppp-monitor /usr/bin/bwm-ng --interfaces ppp0 --output curses --unit bytes --type sum --timeout 1000 else /bin/echo "connection failed, closing now" exit 1 fi exit