conn

A script repository to manage connections in Linux.
git clone git://r-36.net/conn
Log | Files | Refs | LICENSE

commit 2b14714c13931b097c11ae28c92da9118e5e292e
parent 2becc1cb27c1501aaf7bc9da2b585bd3bffe41a0
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 27 Feb 2011 10:21:32 +0100

Fixing some state related bug. State is now live.

Diffstat:
etc/conn/common.sh | 16+++++++++-------
etc/conn/run.sh | 13+++++++++++--
2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/etc/conn/common.sh b/etc/conn/common.sh @@ -1,7 +1,7 @@ #!/bin/sh -LOGGING=0 -DEBUG=0 +LOGGING=1 +DEBUG=1 # If none is set, a connection always needs to be specified. DEFAULTCONNECTION="wifi" @@ -102,18 +102,20 @@ WPACLICMD="/usr/sbin/wpa_cli" WPACLIREQ="/usr/sbin/wpa_cli" startwpa() { - $WPACMD -P $WPAPID.$1 -i $1 + $WPACMD -i $1 $WPACLICMD -i $1 -a $WIFIDIR/$1-action.sh 2>&1 >/dev/null & - echo $! > $WPACLIPID.$1 } hupwpa() { - [ -e $WPAPID.$1 ] && /bin/kill -HUP `cat $WPAPID.$1` + PID=`pgrep -f "$WPACMD -i $1"` + [ ! -z "$PID" ] && kill -HUP $PID } stopwpa() { - [ -e $WPAPID.$1 ] && /bin/kill -KILL `cat $WPAPID.$1` - [ -e $WPACLIPID.$1 ] && /bin/kill -KILL `cat $WPACLIPID.$1` + PID=`pgrep -f "$WPACMD -i $1"` + [ ! -z "$PID" ] && kill -KILL $PID + PID=`pgrep -f "$WPACLICMD -i $1 $WIFIDIR/$1-action.sh"` + [ ! -z "$PID" ] && kill -KILL $PID } # $WPA_ID must be set from within the calling action script. diff --git a/etc/conn/run.sh b/etc/conn/run.sh @@ -89,7 +89,7 @@ then exit 0 fi -[ $dowakeup -eq 1 ] && cmdarg="-s" +[ $dowakeup -eq 1 ] && cmdarg="-f -s" if [ $dosuspend -eq 1 ]; then @@ -139,7 +139,16 @@ fi if [ ! $doforce -eq 1 ]; then - [ $dostart -eq 1 ] && addconnection $connection $profile + if [ $dostart -eq 1 ]; + then + if isopen $connection $profile; + then + echo "Connection $connection $profile is already open" + echo "Use -k or -f for killing it." + exit 1 + fi + addconnection $connection $profile + fi [ $dokill -eq 1 ] && delconnection $connection $profile fi