[bglug] gprsetup

k|b|s kbs@bglug.it
Ven 13 Gen 2006 18:03:24 CET


Visto che ho gprs/edge con diversi gestori ho fatto uno script per cambiare al
volo la connessione ppp. Non modifica nulla, non richiede wvdial o pppconfig,
si appoggia esclusivamente a ppp-on e ppp-off.
Have fun.
;^)

--8<-- CUT HERE --8<-- 
#!/bin/sh
#
# gprsetup v1.0 by k|b|s
# License: GPL
#

: ${DIALOG=dialog}

if [ ! "`id -u`" = "0" ]; then
	echo "su root, dude..."
	echo "Trad.: mangia polenta, ragazzo..."
fi

if [ ! -d /etc/ppp/peers ]; then
	mkdir -p /etc/ppp/peers
fi

gest=/tmp/gest
num=/tmp/num
dev=/tmp/dev

$DIALOG --backtitle "gprsetup v1.0 by k|b|s" \
 --title " GPRS Setup " --menu "Scegli il gestore" 20 50 10 \
 "1" "TIM" \
 "2" "Vodafone" \
 "3" "Wind" \
 2> $gest

$DIALOG --backtitle "gprsetup v1.0 by k|b|s" \
 --title " GPRS Setup " --menu "Scegli il numero da comporre" 20 50 10 \
 "*99#" "Nokia, Sony, ecc" \
 "*99***1#" "Motorola, ecc" \
 "custom" "inserimento manuale" \
 2> $num

if [ `cat $num` = "custom" ]; then
$DIALOG --backtitle "gprsetup v1.0 by k|b|s" \
 --title " GPRS Setup " --inputbox "inserisci il numero:" 20 40 \
 2> $num
 else
	 continue
fi

 
$DIALOG --backtitle "gprsetup v1.0 by k|b|s" \
 --title " GPRS Setup " --menu "Scegli il device" 20 50 10 \
 "rfcomm0" "Bluetooth" \
 "ttyACM0" "USB modem" \
 "custom" "inserimento manuale" \
 2> $dev

if [ `cat $dev` = "custom" ]; then
$DIALOG --backtitle "gprsetup v1.0 by k|b|s" \
 --title " GPRS Setup " --inputbox "inserisci il device:" 20 40 \
 2> $dev
 else
	 continue
fi

if [ -f /etc/ppp/pppscript ]; then
	mv /etc/ppp/pppscript /etc/ppp/pppscript.backup
fi

if [ -f /etc/ppp/options ]; then
	mv /etc/ppp/options /etc/ppp/options.backup
fi

cat << EOF >> /etc/ppp/options
#!/bin/bash
connect "chat -V -f /etc/ppp/pppscript" crtscts /dev/`cat $dev` 115200 -detach noccp defaultroute noauth ipcp-accept-remote ipcp-accept-local noipdefault debug
EOF

cat << EOF >> /etc/ppp/peers/TIM
'' AT
TIMEOUT 240
OK ATE0
OK ATV1
OK 'AT+CGDCONT=9,"IP","ibox.tim.it"'
OK ATDT`cat $num`
TIMEOUT 22
CONNECT ""
EOF

cat << EOF >> /etc/ppp/peers/Vodafone
'' AT
TIMEOUT 240
OK ATE0
OK ATV1
OK 'AT+CGDCONT=1,"IP","web.omnitel.it"'
OK ATDT`cat $num`
TIMEOUT 22
CONNECT ""
EOF

cat << EOF >> /etc/ppp/peers/Wind
'' AT
TIMEOUT 240
OK ATE0
OK ATV1
OK 'AT+CGDCONT=1,"IP","internet.wind"'
OK ATDT`cat $num`
TIMEOUT 22
CONNECT ""
EOF

case `cat $gest` in
	1)
	ln -sf /etc/ppp/peers/TIM /etc/ppp/ppscript
	;;
	2)
	ln -sf /etc/ppp/peers/Vodafone /etc/ppp/pppscript
	;;
	3)
	ln -sf /etc/ppp/peers/Wind /etc/ppp/pppscript
	;;
esac

rm $gest $num $dev

$DIALOG --backtitle "Visit http://www.stixx.org" --infobox \
"\n     
    Joe Galaxy fecit - © MMV\n\n
 <joegalaxy(at)despammed(dot)com>\n\n
   License: GPL - For info see:\n
http://www.gnu.org/licenses/gpl.txt\n\n
          BONUM OTIUM ;^)" 12 39
--8<-- CUT HERE --8<-- 


-- 
No message found in this outgoing virus.
k|b|s > mailto `echo ti.gulgb@sbk|'rev'`


Maggiori informazioni sulla lista bglug