#!/bin/sh
# manage your gprs connection
#
# $Id: gprs v 0.1 2005/07/02 15:52:14 y3dips Exp $
# turn on your device to discoverable , then do ./gp scan then ./gp start
RFCOMM=/usr/bin/rfcomm
HCITOOL=/usr/bin/hcitool
X=0 #alamat bind tuk device
FILE=log
PSFILE=ps
PIDFILE=gprs.pid
ADDRESS=addres
test -f $RFCOMM || exit 0
test -f $HCITOOL || exit 0
case "$1" in
scan)
echo -n "Mendeteksi Peralatan"
$HCITOOL scan > $ADDRESS &
sleep 10
echo " "
;;
start)
echo -n "Menyalakan GPRS "
ps awx | grep "pppd call gprs" > $PSFILE
if [ "`grep ^"pppd call gprs" $PSFILE`"] ; then
echo "..... pppd sudah di jalankan" && exit 0
echo -n
else
echo -n
$RFCOMM show > $FILE
if [ "`grep ^rfcomm0: $FILE`" ] ; then
pppd call gprs &
else
tail -n 1 $ADDRESS > 2
cut -f 2 2 > $ADDRESS
DEVICE=`cat $ADDRESS`
$RFCOMM bind $X $DEVICE 1
pppd call gprs &
fi
fi
;;
stop)
echo -n "Matikan GPRS "
ps awx | grep -e "pppd call gprs" > $PSFILE
head -n 1 $PSFILE > 3
cut -f 1 -d ' ' 3 > $PIDFILE
pid=`cat $PIDFILE`
kill -9 $pid
$RFCOMM release $X
rm -rf $FILE
rm -rf $PSFILE
sleep 5
echo "..... tewas"
echo -n
;;
restart)
$0 stop
$0 start
;;
*)
echo " Gunakan : $0 { scan | start | stop | restart }"
exit 1
esac
exit 0
#y3dips(c)2005
y3dips shares stories about life, family, hacking, computer security, and *nix.
Sunday, July 03, 2005
Gprs shell script
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment