commit a3e40447db74dbdcc6152590ce257bec049a27d2
parent 2a26978dd9e4fbf750eb225e6dcef38371b93776
Author: Christoph Lohmann <20h@r-36.net>
Date: Tue, 21 Oct 2014 12:23:19 +0200
Fixing many things:
WWAN:
* ppp fixed
Wifi:
* allow ssids with spaces
Common:
* Fix WLAN SSID detection
Diffstat:
9 files changed, 73 insertions(+), 33 deletions(-)
diff --git a/etc/conn/common.sh b/etc/conn/common.sh
@@ -122,6 +122,15 @@ stopwpa() {
pkill -KILL -f "$WPACLICMD -i $1 -a $WIFIDIR/$1-action.sh -B"
}
+iswparunning() {
+ if [ -n "$(pgrep -f "$WPACMD -i $1")" ];
+ then
+ return 1
+ else
+ return 0
+ fi
+}
+
getssid() {
$WPACLIREQ -i $1 list_networks \
| awk -F'\t' "/\[CURRENT\]$/ {print \$2}"
@@ -137,6 +146,15 @@ stopdhcp() {
$DHCPKILLCMD $1 2>&1 >/dev/null
}
+isdhcprunning() {
+ if [ -n "$(pgrep -f "$DHCPCMD $1")" ];
+ then
+ return 1
+ else
+ return 0
+ fi
+}
+
## Connection handling
runconnection() {
SRVDIR="${ETCDIR}/$1"
diff --git a/examples/eth/run.sh b/examples/eth/run.sh
@@ -19,6 +19,9 @@ case "$1" in
islinkup $interface && setlinkdown $interface
exit $?
;;
+ -o)
+ exit isdhcprunning $interface
+ ;;
-u)
;;
-r)
diff --git a/examples/wifi/run.sh b/examples/wifi/run.sh
@@ -46,6 +46,9 @@ case "$1" in
hupwpa $interface
exit $?
;;
+ -o)
+ exit iswparunning $interface
+ ;;
-r)
$0 -k $interface;
$0 -s $interface;
diff --git a/examples/wifi/wlan0-action.sh b/examples/wifi/wlan0-action.sh
@@ -7,7 +7,7 @@ WIFIDIR="${ETCDIR}/wifi"
interface="$1"
action="$2"
ssid="$3"
-[ -z "$ssid" ] && ssid=`getssid $interface`
+[ -z "$ssid" ] && ssid="$(getssid $interface)"
[ $LOGGING -eq 1 ] && \
logger -t "$interface-action" "Got request for $interface $ssid $action."
@@ -20,28 +20,28 @@ if [ ! -z "$ssid" ];
then
case "$action" in
CONNECTED)
- aps=`getstates "wifi" $interface $ssid`
+ aps=$(getstates "wifi" $interface "$ssid")
if [ ! -z "$aps" ];
then
for i in "$aps":
do
- issid=`echo $i | awk -F'|' '{print $2}'`
- $0 $interface DISCONNECTED $issid
+ issid="$(echo $i | awk -F'|' '{print $2}')"
+ $0 $interface DISCONNECTED "$issid"
done
fi
- addstate "wifi" $interface $ssid
+ addstate "wifi" $interface "$ssid"
;;
DISCONNECTED)
- delstate "wifi" $interface $ssid
+ delstate "wifi" $interface "$ssid"
;;
*)
exit 1;
;;
esac
- script=`getscript $ssid`
- if [ ! -z "$script" ];
+ script="$(getscript "$ssid")"
+ if [ -n "$script" ];
then
cd ${WIFIDIR}/networks
./$script $interface $action
diff --git a/examples/wwan/README.md b/examples/wwan/README.md
@@ -9,3 +9,5 @@ in serial, after which dhcp is run on it. Besides this a ping is started,
which increases the stability of a wwan connection; at least here in Ger-
many.
+There are now support scripts for the gobi WWAN modems.
+
diff --git a/examples/wwan/f3507g-x201-init b/examples/wwan/f3507g-x201-init
@@ -38,7 +38,7 @@ case "$1" in
chat -v "" "AT+CPIN?" "OK" "AT+CFUN=1" "+PACSP0" "AT" \
"OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
echo "done"
- ;;
+ ;;
-k)
echo -n "Turning off F3507g card..."
chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
@@ -49,13 +49,14 @@ case "$1" in
rmmod zaurus
rmmod cdc_ether
echo "done"
- ;;
+ ;;
-r)
$0 -k
$0 -s
- ;;
+ ;;
*)
echo "usage: $0 [-s|-k|-r]"
+ ;;
esac
exit 0
diff --git a/examples/wwan/gobi-x201-init b/examples/wwan/gobi-x201-init
@@ -11,7 +11,7 @@ CONTROL_DEVICE="/dev/gobimodem"
#
# Change the PIN to your SIM PIN.
#
-PIN="XXXX"
+PIN="7471"
#
# Your provider's APN.
#
@@ -27,10 +27,12 @@ NUMBER="*99#"
case "$1" in
-s)
- modprobe qcserial
+ if [ -z "$(lsmod | grep qcserial)" ];
+ then
+ modprobe qcserial
+ fi
echo -n "Powering up Gobi card.."
- echo enable > /proc/acpi/ibm/wan
rfkill unblock wwan
while [ ! -c $CONTROL_DEVICE ];
do
@@ -41,8 +43,8 @@ case "$1" in
echo -n "Turning on Gobi card..."
sleep 2
- chat -t 2 -v "ABORT" "NO CARRIER" "" "AT+CFUN=1" "OK" > $CONTROL_DEVICE \
- < $CONTROL_DEVICE
+ chat -t 2 -v "ABORT" "NO CARRIER" "" "AT+CFUN=1" "OK" > \
+ $CONTROL_DEVICE < $CONTROL_DEVICE
if [ $? -eq 4 ];
then
logger -s -t "gobi-init" "AT+CFUN=1 failed. This" \
@@ -64,20 +66,17 @@ case "$1" in
i=0
while [ $i -lt 11 ];
do
- chat -t 2 -v "" "AT+CPIN?" "SIM busy" \
+ chat -t 2 -v "" "AT+CPIN?" "READY" \
> $CONTROL_DEVICE < $CONTROL_DEVICE
- [ $? -gt 0 ] && break
+ [ $? -eq 0 ] && break
i=`expr $i + 1`
if [ $i -eq 10 ];
then
- 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
+ logger -s -t "gobi-init" "Gobi modem" \
+ "needed more than 10 seconds" \
+ "to be SIM ready. Please" \
+ "restart the connection."
exit 1
fi
sleep 1
@@ -96,7 +95,7 @@ case "$1" in
echo "done"
echo -n "Starting pppd ..."
- if [ "`ip route | grep default`" != "" ];
+ if [ "$(ip route | grep default)" != "" ];
then
ip route del default
fi
@@ -104,7 +103,15 @@ case "$1" in
usehostname user $USER noipdefault usepeerdns noauth \
nolock nolog
echo "done"
- ;;
+ ;;
+ -o)
+ if [ -n "$(pgrep -f "pppd $CONTROL_DEVICE")" ];
+ then
+ return 1
+ else
+ return 0
+ fi
+ ;;
-k)
echo -n "Killing pppd ..."
pkill -KILL -f "pppd $CONTROL_DEVICE"
@@ -118,17 +125,17 @@ case "$1" in
echo "done"
fi
- echo -n "Removing qcserial driver ..."
- rmmod qcserial 2>/dev/null
- echo "done"
- ;;
+ #echo -n "Removing qcserial driver ..."
+ #rmmod qcserial 2>/dev/null
+ #echo "done"
+ ;;
-r)
$0 -k
$0 -s
- ;;
+ ;;
*)
echo "usage: $0 [-s|-k|-r]"
- ;;
+ ;;
esac
exit 0
diff --git a/examples/wwan/ppp0-run.sh b/examples/wwan/ppp0-run.sh
@@ -54,6 +54,9 @@ case "$1" in
${WWANDIR}/gobi-x201-init -k
exit $?
;;
+ -o)
+ exit islinkup $interface
+ ;;
-u)
break;
;;
diff --git a/examples/wwan/wwan0-run.sh b/examples/wwan/wwan0-run.sh
@@ -21,6 +21,9 @@ case "$1" in
;;
-u)
;;
+ -o)
+ exit islinkup $interface
+ ;;
-r)
$0 -k $interface;
$0 -s $interface;