moleflap/www/opendoor

80 lines
1.6 KiB
Plaintext
Raw Normal View History

2010-02-25 08:37:50 +01:00
#!/bin/sh
echo "* try to open tronlab's moleflap"
2010-03-03 05:06:38 +01:00
HOST='moleflap.hq.c3d2.de'
2010-02-25 08:37:50 +01:00
STORE=~/.moletoken.c3d2
WLAN_NAME="<<</>>"
usage()
{
cat << EOF
usage: $0 options
try to open tronlab's moleflap
--n800 nokia n8xx/n9xx connect mode
--help help
EOF
exit
}
n800() {
for i in `gconftool /system/osso/connectivity/IAP --all-dirs`; do
NAME=`gconftool --get $i/name`;
if [ "x$NAME" == "x$WLAN_NAME" ]; then
dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:${i##/system/osso/connectivity/IAP/} uint32:0;
echo -n "connect & wait...";
for j in $(seq 1 1 15); do
ping -c 1 $HOST >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then break; fi
echo -n .
sleep 1;
done
echo
break;
fi;
done;
}
# Process command line arguments
for i in $@; do
case "$i" in
"--n800" ) CONNECT=n800;;
"--help" ) usage;;
* ) echo "Error!"; usage;;
esac
done
2010-02-25 08:37:50 +01:00
if [ -e $STORE ]
then
token=`cat $STORE`
else
echo "Please enter your valid token:"
read token
# save new token first
echo "$token" > $STORE
fi
# test for connection
ping -c 1 $HOST >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
if [ "x$CONNECT" == "x" ]; then
echo "can't connect to host $HOST"
exit;
else
$CONNECT
fi
2010-02-25 08:37:50 +01:00
fi
newtoken=`wget -qO - http://$HOST/open?$token`
if [ "$?" -eq "0" ]
then
echo "* check door ..."
echo "$newtoken" > $STORE
else
echo "* moleflap unreachable"
fi