[CONTACT]

[ABOUT]

[POLICY]

Log gph Files gph Refs gph

Found at: gopher.r-36.net:70/scm/conn/commit/3582be6315a274e7a107028d8b8996d6b0b8392e.gph

Logging is now stderr and syslog. Gobi fixes. - conn - A script repository to manage connections in Linux.

Log

Files

Refs

LICENSE

---

commit 3582be6315a274e7a107028d8b8996d6b0b8392e

parent 93fd4851fe99edccd0f3e8f73e57eff03e9fa7ab

Author: Christoph Lohmann <20h@r-36.net>

Date:   Sat,  9 Apr 2011 12:47:58 +0200
Logging is now stderr and syslog. Gobi fixes.
Diffstat:
  etc/conn/run.sh                     |       5 ++++-
  examples/wifi/run.sh                |      30 ++++++++++++++++++------------
  examples/wwan/gobi-x201-init        |      33 +++++++++++++++++++++++--------
  examples/wwan/run.sh                |      11 +++++++++--
4 files changed, 56 insertions(+), 23 deletions(-)
---

diff --git a/etc/conn/run.sh b/etc/conn/run.sh

@@ -169,8 +169,11 @@ else
         shift 2
 fi
+t[ $LOGGING -eq 1 ] && \
+        logger -s -t "conn" "running: $connection $cmdarg $profile $*"
+
 runconnection $connection $cmdarg $profile $*
-if [ $? -gt 1 ] && [ $dostart -eq 1 ] && [ $doforce -eq 1 ];
+if [ $? -eq 0 ] && [ $dostart -eq 1 ] && [ ! $doforce -eq 1 ];
 tthen
         addstate "open" $connection $profile
 fi

diff --git a/examples/wifi/run.sh b/examples/wifi/run.sh

@@ -2,23 +2,24 @@
 . ../common.sh
-if isblocked "wifi";
-tthen
-        if [ $DOUNBLOCK -eq 1 ];
-        then
-                dounblock "wifi"
-        else
-                echo "Your wifi device seems to be blocked. Please use rfkill" \
-                        "to unblock it."
-                exit 1
-        fi
-fi
-
 interface=$2
 t[ "$2" == "" ] && interface="wlan0"
 case "$1" in
         -s)
+                if isblocked "wifi";
+                then
+                        if [ $DOUNBLOCK -eq 1 ];
+                        then
+                                dounblock "wifi"
+                        else
+                                syslog -s -t "wifi-init" "Your wifi device" \
+                                        "seems to be blocked. Please use" \
+                                        "rfkill to unblock it."
+                                exit 1
+                        fi
+                fi
+
                 if ! islinkup $interface;
                 then
                         setlinkup $interface
@@ -30,6 +31,11 @@ case "$1" in
                 stopwpa $interface
                 islinkup $interface && setlinkdown $interface
+
+                if [ $DOBLOCK -eq 1 ] && ! isblocked "wifi";
+                then
+                        doblock "wifi"
+                fi
                 exit $?
                 ;;
         -u)

diff --git a/examples/wwan/gobi-x201-init b/examples/wwan/gobi-x201-init

@@ -40,11 +40,18 @@ case "$1" in
                 echo "done"
                 echo -n "Turning on Gobi card..."
-                sleep 5
-                chat -t 2 -v "" "AT+CFUN=1" "OK" > $CONTROL_DEVICE \
+                sleep 2
+                chat -t 2 -v "ABORT" "NO CARRIER" "" "AT+CFUN=1" "OK" > $CONTROL_DEVICE \
                         < $CONTROL_DEVICE
-                [ ! $? -eq  0 ] && exit 1
+                if [ $? -eq 4 ];
+                then
+                        logger -s -t "gobi-init" "AT+CFUN=1 failed. This" \
+                                "could be because of no carrier found. Try" \
+                                "restarting the connection."
+                        exit 1
+                fi
+                sleep 2
                 if [ -n "$PIN" ];
                 then
                         echo -n "PIN..."
@@ -52,6 +59,7 @@ case "$1" in
                                 "AT" "OK" "AT+CPIN=\"$PIN\"" "OK" \
                                 > $CONTROL_DEVICE < $CONTROL_DEVICE
                 fi
+                sleep 1
                 echo -n "COM..."
                 i=0
                 while [ $i -lt 11 ];
@@ -63,18 +71,28 @@ case "$1" in
                         i=`expr $i + 1`
                         if [ $i -eq 10 ];
                         then
-                                echo "Gobi modem needed more than 10 seconds" \
-                                        "to be SIM ready. Please restart the" \
-                                        "connection, if this isn't an error."
+                                if [ $LOGGING -eq 1 ];
+                                then
+                                        logger -s -t "gobi-init" "Gobi modem" \
+                                                "needed more than 10 seconds" \
+                                                "to be SIM ready. Please" \
+                                                "restart the connection."
+                                fi
                                 exit 1
                         fi
                         sleep 1
                 done
+                sleep 1
                 chat -t 2 -v "" "AT+CPIN?" "READY" "AT" "OK" \
                         "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" \
                         "ATDT${NUMBER}" "CONNECT" \
                         > $CONTROL_DEVICE < $CONTROL_DEVICE
-                [ ! $? -eq  0 ] && exit 1
+                if [ $? -gt 0 ];
+                then
+                        logger -s -t "gobi-init" "Dialing the carrier failed." \
+                                "See syslog for details."
+                        exit 1
+                fi
                 echo "done"
                 echo -n "Starting pppd ..."
@@ -92,7 +110,6 @@ case "$1" in
                 pkill -KILL -f "pppd $CONTROL_DEVICE"
                 echo "done"
-                rfkill block wwan
                 if [ -e $CONTROL_DEVICE ];
                 then
                         echo -n "Powering down Gobi card..."

diff --git a/examples/wwan/run.sh b/examples/wwan/run.sh

@@ -8,8 +8,8 @@ then
         then
                 dounblock "wwan"
         else
-                echo "Your wwan device(s) seem to be blocked. Please use rfkill" \
-                        "to unblock them."
+                syslog -s -t "wwan-init" "Your wwan device(s) seem to be"
+                        "blocked. Please use rfkill to unblock them."
                 exit 1
         fi
 fi
@@ -22,5 +22,12 @@ iffile="${WWANDIR}/${interface}-run.sh"
 t[ ! -e $iffile ] && exit 1
 $iffile $1
+
+if [ "$1" == "-k" ] && [ $DOBLOCK -eq 1 ] && ! isblocked "wwan";
+tthen
+        doblock "wwan"
+        sleep 4
+fi
+
 exit $?
.


AD: