#!/bin/bash
#(c) Copyright 2007 Barry Kauler www.puppylinux.com
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#written for Puppy Linux 2.17+
#BK v3.91: keep log if failed to connect, display in main status log.
#BK v3.98: improve create mono font in status log. bugfixes.
#BK v3.98: one bugfix had to be removed, which fixed another bugfix.
#BK v3.99: corrected handling of params for each isp.
#BK v3.99: added Stupid Mode and Auto reconnect checkboxes for each isp.
#BK v4.00: crash bugfix.
#HairyWill v4.00: handle init string with quotes, prevent gtkdialog crash.
#v405 updated.
#v408 old pap-secrets, chap-secrets problem has returned, workaround applied.
#v408 rerwin: Make modem startup after 'erase' same as for first time with no conf file.
#v409 rerwin: bugfix, need a delay for fast machines.
#v412 rerwin: increase sleep from 0.3 to 1.
#v465 rerwin: v413 add init strings for wireless modems
#v477 rerwin: v413 add 'Reading...' splash message during sleep.
#v424 rerwin: send PIN only on first wireless connection; move APNs to accounts; associate APN with dial accounts; retain dial type (DT/DP)
#v431 rerwin: retain account checkbox changes; ensure optional lines associated with an account; add APN-specific commands; handle Idle Seconds lines
#v433 rerwin: accomodate bluetooth-connected modems.
#v433 Collect monthly transmission data.
KERNVER="`uname -r`"
#if no wvdial.conf, create a skeleton...
MYDEVM="MYDEVM"
[ -h /dev/modem ] && MYDEVM='/dev/'"`readlink /dev/modem`"
#note, MYDEVM is placeholder for '/dev/ttyS0' whereas DEVM is just 'ttyS0'.
#v408 rerwin...
if [ ! -s /etc/wvdial.conf ] || [ "`grep '/dev/MYDEVM' /etc/wvdial.conf`" != "" ];then #also replace empty file #v408
if [ ! -s /etc/wvdial.conf ];then #v408
echo "[Dialer Defaults]
Modem = ${MYDEVM}
Baud = 57600
Init1 =
Init2 = ATZ
Init3 =
Carrier Check = no
Dial Command = ATDT
[Dialer isp1]
Phone = MYISPPHONENUM
Username = MYUSERNAME
Password = MYPASSWORD
[Dialer isp1apn]
Init5 = AT+CGDCONT=1,\"IP\",\"\"
[Dialer isp2]
Phone = MY2ISPPHONENUM
Username = MY2USERNAME
Password = MY2PASSWORD
[Dialer isp2apn]
Init5 = AT+CGDCONT=1,\"IP\",\"\"
[Dialer pin]
Init1 = AT+CPIN=" > /etc/wvdial.conf
#v408 Treat erased modem device name same as for absent wvdial.conf.
else #wvdial.conf indicates modem field has been erased
if [ "$MYDEVM" != "MYDEVM" ];then #modem detected; make config agree with /dev/modem.
SEDSCRIPT="s%/dev/MYDEVM%$MYDEVM%"
sed -i -e "$SEDSCRIPT" /etc/wvdial.conf
fi
fi
#v408 end rerwin.
if [ "$MYDEVM" != "MYDEVM" -a "$MYDEVM" != "modem" ];then
Xdialog --left --wmclass "pupdial" --title "PupDial: modem string" --no-cancel --yesno "It seems that you have a modem, at port ${MYDEVM}\n
However, for the modem to work properly, you may need to supply an initialization\n
string. There are two of these. The first one is already setup as 'ATZ' which just\n
resets the modem. For many modems that is all that is needed, and you can just\n
click the 'No' button as no further probing is required.\n
However some modems need a bit more. If you click the 'Yes' button (recommended)\n
then the modem will be probed to determine a required second initialization string.\n
This probe will timeout after 29 seconds, which may have meant that the probe\n
failed, in which case the second string will be set to nothing.\n
Note that you can manually enter something into the second-string box in PupDial\n
(the User Manual for the modem may have a recommended string).\n
\n
Recommend click 'Yes', afterward PupDial will start..." 0 0
RETVAL=$?
DEVM="`echo -n "$MYDEVM" | cut -f 3,4 -d '/'`"
[ $RETVAL -eq 0 ] && modemtest $DEVM initonly
fi
fi
#v413 Assure user...
yaf-splash -font "8x16" -outline 0 -margin 4 -bg orange -text "Reading modem configuration file..." &
X1PID=$!
#disconnect button...
STATECONb="disabled"
#v409 rerwin, bugfix...
#[ "`pidof pppd`" != "" ] && STATECONb="enabled"
if [ "`pidof pppd`" != "" ];then #v409
[ ! -f /etc/ppp/peers/wvdial ] && sleep 1 #v409 allow kill completion and repeat test. v412 0.3 to 1.
[ "`pidof pppd`" != "" ] && STATECONb="enabled"
fi #v409
MSG1="WARNING! No modem detected! You cannot dialout!"
STATECONa="disabled"
STATETEST="disabled" #101117
STATECCM="yes"
STATEDTM="yes"
STATEBCM="yes"
TESTMSG="MODEM"
#precaution...
cat /etc/wvdial.conf | tr '\t' ' ' | tr -s ' ' > /tmp/wvdial.conf
sync
#Rerwin: v4.05 Substitute /dev/modem target for /dev/modem
if [ "`grep '/dev/modem' /tmp/wvdial.conf`" != "" -a -h /dev/modem ];then #modem = /dev/modem & it exists
SEDSCRIPT="s%/dev/modem%/dev/`readlink /dev/modem`%g"
sed -i -e "$SEDSCRIPT" /tmp/wvdial.conf #replace device in-place
fi
mv -f /tmp/wvdial.conf /etc/wvdial.conf
sync #v413 ensure config updated
ISPM="`cat /etc/wvdial.conf | grep '^Phone = ' | head -n 2`"
ACC1ISP="`echo "$ISPM" | head -n 1 | cut -f 3-6 -d ' '`"
ACC2ISP="`echo "$ISPM" | tail -n 1 | cut -f 3-6 -d ' '`"
USERM="`cat /etc/wvdial.conf | grep '^Username = ' | head -n 2`"
ACC1USER="`echo "$USERM" | head -n 1 | cut -f 3 -d ' '`"
ACC2USER="`echo "$USERM" | tail -n 1 | cut -f 3 -d ' '`"
PASSM="`cat /etc/wvdial.conf | grep '^Password = ' | head -n 2`"
ACC1PASS="`echo "$PASSM" | head -n 1 | cut -f 3 -d ' '`"
ACC2PASS="`echo "$PASSM" | tail -n 1 | cut -f 3 -d ' '`"
INIT5M="`cat /etc/wvdial.conf | grep '^Init5 = AT+CGDCONT=' | head -n 2`"
[ "`grep '\[Dialer isp2apn\]' /etc/wvdial.conf`" = "" ] && INIT5M="`echo -e "$INIT5M\n"`"
ACC1PRFL="`echo "$INIT5M" | head -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
ACC2PRFL="`echo "$INIT5M" | tail -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
ACC1APN="`echo "$INIT5M" | head -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
ACC2APN="`echo "$INIT5M" | tail -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
[ "$ACC1PRFL" = "" ] && ACC1PRFL="1"; [ "$ACC2PRFL" = "" ] && ACC2PRFL="1"
#1st 'cut' fixes if the '/dev/' left off the device name...
#note, initialised wvdial.conf has 'Modem = MYDEVM' where MYDEVM needs to become
# '/dev/ttyS0' (for example)
DEVM="`cat /etc/wvdial.conf | grep '^Modem = ' | cut -f 3 -d ' ' | cut -f 3 -d '/'`"
DEVMALT="`cat /etc/wvdial.conf | grep '^#Modem = ' | tail -n 1 | cut -f 3 -d ' ' | cut -f 3 -d '/'`" #v432
[ "$DEVM" = "" ] && DEVM='MYDEVM' #v4.00 bugfix, crashed if no DEVM.
[ ! -f /tmp/pupdial.log ] && touch /tmp/pupdial.log #v408 rerwin, moved up.
if [ "${DEVM}" != "MYDEVM" ];then
[ -f /tmp/.pupdial-modem_detected ] \
&& rm -f /tmp/.pupdial-modem_detected \
&& MSG1="Modem detected! Device interface: /dev/$DEVM" \
|| MSG1="Selected modem device interface: /dev/$DEVM" #v433
#101117 Protect HSF/HCF connections from lockup - ensure nvm files installed.
[ "`pidof pppd`" = "" ] \
&& STATETEST="enabled" \
&& [ "`echo "${DEVM}" | grep 'ttySHSF[0-9]'`" = "" -o -d /etc/hsfmodem/nvm ] \
&& [ "`echo "${DEVM}" | grep 'ttySHCF[0-9]'`" = "" -o -d /etc/hcfpcimodem/nvm ] \
&& STATECONa="enabled" #dialout button.
[ "$DEVMALT" = "" ] \
&& TESTMSG="$DEVM" \
|| TESTMSG="$DEVMALT" #v433
TESTDEVM="$TESTMSG" #v432
#[ ! -f /tmp/pupdial.log ] && touch /tmp/pupdial.log
[ "`grep 'MODEM WAS NOT AUTOMATICALLY DETECTED' /tmp/pupdial.log`" != "" ] && echo -n "" > /tmp/pupdial.log
if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
echo "Welcome to PupDial, originally written by Barry Kauler and
enhanced by Richard Erwin for Puppy Linux.
There is a configuration file, /etc/wvdial.conf, that is read by
PupDial, and changes made to any of the above boxes will be saved
to wvdial.conf when you click the 'Exit' or 'Connect' buttons.
Note, you can also manually edit wvdial.conf with a text editor.
Some computers have two modems, perhaps one on the motherboard,
and Puppy may have detected the wrong one. In that case, click the
'probe' button. If it is still wrong, manually edit wvdial.conf." >> /tmp/pupdial.log
fi
else
if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
echo "Welcome to PupDial, originally written by Barry Kauler and
enhanced by Richard Erwin for Puppy Linux.
A MODEM WAS NOT AUTOMATICALLY DETECTED, SO YOU
NEED TO CLICK THE 'CHOOSE' BUTTON. DO THIS NOW!
" > /tmp/pupdial.log
fi
fi
BAUDM="`cat /etc/wvdial.conf | grep '^Baud = ' | cut -f 3 -d ' '`"
#v4.00 HairyWill fixes for embedded $ " characters...
INIT1M="`cat /etc/wvdial.conf | grep '^Init1 =' | head -n 1 | cut -f 3-12 -d ' ' | grep -v 'AT+CPIN=' | sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`" #v413
INIT2M="`cat /etc/wvdial.conf | grep '^Init2 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`"
INIT3M="`cat /etc/wvdial.conf | grep '^Init3 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`" #v413
#v413 If first Init1 not null, move contents to Init2, and Init2 to Init3, to reserve Init1 for wireless PIN.
[ "$INIT1M" != "" ] && INIT3M="$INIT2M" && INIT2M="$INIT1M" && INIT1M="" #v413
#v413 Get values for Init1, 4, 6-9.
WPINM="`cat /etc/wvdial.conf | grep '^Init1 = ' | tail -n 1 | cut -f 3 -d '='`"
INIT4M="`cat /etc/wvdial.conf | grep '^#*Init4 =' | sed 's/"/\\"/g;;s/\$/\\$/g;s/$$//g;'`"
[ "$INIT4M" = "" ] && INIT4M="#Init4 = AT+COPS=0,0,\"MYOPS\","
INIT69M="`cat /etc/wvdial.conf | grep '^#*Init[6-9] =' | sed -e 's/"/\\"/g' -e 's/\$/\\$/g' -e 's/$$//'`"
[ "$INIT69M" = "" ] && INIT69M="#Init6 = AT+CGEQMIN=1,4,64,384,64,384
#Init7 = AT+CGEQREQ=1,4,64,384,64,384
#Init8 = AT+CGDCONT?
#Init9 = AT+COPS?"
#v413 end
DIALM="`cat /etc/wvdial.conf | grep '^Dial Command = ' | cut -f 4 -d ' '`"
[ "`echo "$DIALM" | grep -E 'X3|X1'`" != "" ] && STATEDTM="no"
[ "`echo "$DIALM" | grep -E 'X2|X1'`" != "" ] && STATEBCM="no"
CCM="`cat /etc/wvdial.conf | grep '^Carrier Check = ' | cut -f 4 -d ' '`"
[ "$CCM" = "no" ] && STATECCM="no"
[ "`echo "$DIALM" | grep 'DP'`" = "" ] && DIALTYPE="DT" || DIALTYPE="DP" #v424
#v3.99 there may be up to two of each of the above...
ISPCNT=0 #v431
echo -n "" > /tmp/pupdial_read
cat /etc/wvdial.conf |
while read ONELINE
do
ONELINE="`echo -n "$ONELINE" | tr '\t' ' ' | tr -s ' '`" #in case user puts in extra tabs and spaces.
[ "$ONELINE" = "" -o "$ONELINE" = " " ] && continue
#v431 begin
case $ONELINE in
"[Dialer isp1]") ISPCNT=1 ;;
"[Dialer isp1apn]") ISPCNT=0 ;;
"[Dialer isp2]") ISPCNT=2 ;;
"[Dialer isp2apn]") ISPCNT=0 ;;
esac
[ $ISPCNT -eq 0 ] && continue
#v431 end
ONEPARAM="`echo -n "$ONELINE" | cut -f 1 -d '=' | sed -e 's/ $//'`"
ONEVALUE="`echo -n "$ONELINE" | cut -f 2 -d '=' | sed -e 's/^ //'`"
if [ "$ONEVALUE" != "" ];then
case $ONEPARAM in
"Dial Prefix") echo "DIAL_PREFIX${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Login Prompt") echo "LOGIN_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Password Prompt") echo "PASSWORD_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Stupid Mode") echo "STUPID_MODE${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Default Reply") echo "DEFAULT_REPLY${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Auto Reconnect") echo "AUTO_RECONNECT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
"Idle Seconds") echo "IDLE_SECONDS${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;; #v431
esac
fi
done
eval "`cat /tmp/pupdial_read`"
#v3.99
ynSTUPID_MODE1=no
[ "$STUPID_MODE1" = "1" -o "$STUPID_MODE1" = "yes" ] && ynSTUPID_MODE1=yes
ynSTUPID_MODE2=no
[ "$STUPID_MODE2" = "1" -o "$STUPID_MODE2" = "yes" ] && ynSTUPID_MODE2=yes
ynAUTO_RECONNECT1=yes #default is on.
[ "$AUTO_RECONNECT1" = "1" -o "$AUTO_RECONNECT1" = "yes" ] && ynAUTO_RECONNECT1=yes
[ "$AUTO_RECONNECT1" = "0" -o "$AUTO_RECONNECT1" = "no" ] && ynAUTO_RECONNECT1=no
ynAUTO_RECONNECT2=yes #default is on.
[ "$AUTO_RECONNECT2" = "1" -o "$AUTO_RECONNECT2" = "yes" ] && ynAUTO_RECONNECT2=yes
[ "$AUTO_RECONNECT2" = "0" -o "$AUTO_RECONNECT2" = "no" ] && ynAUTO_RECONNECT2=no
#v4.00 HairyWill, replaced lines (see below), fix for quotes in string...
#< \"${INIT2M}\"
#> echo \"${INIT2M}\"
#< \"${INIT3M}\"
#> echo \"${INIT3M}\"
MODEMINFO="
CHECKCC
${STATECCM}
CHECKDT
${STATEDTM}
CHECKBC
${STATEBCM}
echo \"${INIT2M}\"
ENTRYINIT2M
echo \"${INIT3M}\"
ENTRYINIT3M
\"${BAUDM}\"
ENTRYBAUDM
echo \"${WPINM}\"
ENTRYWPINM
"
export MAINDIALOG="
${MODEMINFO}
\"${ACC1ISP}\"
ENTRYACC1ISP
\"${ACC1USER}\"
ENTRYACC1USER
\"${ACC1PASS}\"
ENTRYACC1PASS
\"${ACC1APN}\"
ENTRYACC1APN
ynSTUPID_MODE1
${ynSTUPID_MODE1}
ynAUTO_RECONNECT1
${ynAUTO_RECONNECT1}
\"${ACC2ISP}\"
ENTRYACC2ISP
\"${ACC2USER}\"
ENTRYACC2USER
\"${ACC2PASS}\"
ENTRYACC2PASS
\"${ACC2APN}\"
ENTRYACC2APN
ynSTUPID_MODE2
${ynSTUPID_MODE2}
ynAUTO_RECONNECT2
${ynAUTO_RECONNECT2}
INFO
/tmp/pupdial.log
600
170
"
# wvdial &> /tmp/pupdial.log &
# sleep 2
# tail /tmp/pupdial.log > /tmp/pupdial.log.tail
# INFO
#mono text for log box...
echo 'style "specialmono"
{
font_name="Mono 12"
}
class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono
export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0
kill $X1PID #v413
#RETSTRING="`echo "$MAINDIALOG" | gtkdialog3 --stdin`"
RETSTRING="`gtkdialog3 --program=MAINDIALOG`"
#v4.00 to handle embedded quote, extract ENTRYINIT2M and ENTRYINIT3M separately...
ENTRYINIT2M="`echo "$RETSTRING" | grep '^ENTRYINIT2M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
ENTRYINIT3M="`echo "$RETSTRING" | grep '^ENTRYINIT3M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
ENTRYWPINM="`echo "$RETSTRING" | grep '^ENTRYWPINM=' | cut -f 2-9 -d '"' | sed -e 's/"$//' | tr -d ' '`" #no spaces
RETSTRING="`echo "$RETSTRING" | grep -v '^ENTRYINIT3M=' | grep -v '^ENTRYINIT2M=' | grep -v '^ENTRYWPINM='`"
#v405 getting some weird stuff on stdout from gtkdialog3, fix...
#all lines must have format variable="value"... v406 add '_'...
xRETSTRING="`echo "$RETSTRING" | grep -E '^[a-zA-Z0-9_]+=\".*\"$'`" # | grep -v '^INFO='
eval "$xRETSTRING"
[ ! -f /etc/wvdial.conf ] && exit
if [ "$EXIT" = "abort" -o "$EXIT" = "" ];then
rm -f /tmp/pupdial.log #v3.91
exit
fi
[ "$EXIT" = "reload" ] && exec pupdial
rm -f /tmp/pupdial.log #v3.91
#v3.99
STUPID_MODE1=""
STUPID_MODE2=""
[ "$ynSTUPID_MODE1" = "true" ] && STUPID_MODE1="yes"
[ "$ynSTUPID_MODE2" = "true" ] && STUPID_MODE2="yes"
[ "$ynAUTO_RECONNECT1" = "true" ] && AUTO_RECONNECT1=yes
[ "$ynAUTO_RECONNECT1" = "false" ] && AUTO_RECONNECT1=no
[ "$ynAUTO_RECONNECT2" = "true" ] && AUTO_RECONNECT2=yes
[ "$ynAUTO_RECONNECT2" = "false" ] && AUTO_RECONNECT2=no
USEREXTRA1="" #v3.99 bug fix...
[ "$DIAL_PREFIX1" != "" ] && USEREXTRA1="${USEREXTRA1}Dial Prefix = ${DIAL_PREFIX1}
"
[ "$LOGIN_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Login Prompt = ${LOGIN_PROMPT1}
"
[ "$PASSWORD_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Password Prompt = ${PASSWORD_PROMPT1}
"
[ "$STUPID_MODE1" != "" ] && USEREXTRA1="${USEREXTRA1}Stupid Mode = ${STUPID_MODE1}
"
[ "$DEFAULT_REPLY1" != "" ] && USEREXTRA1="${USEREXTRA1}Default Reply = ${DEFAULT_REPLY1}
"
[ "$AUTO_RECONNECT1" != "" ] && USEREXTRA1="${USEREXTRA1}Auto Reconnect = ${AUTO_RECONNECT1}
"
[ "$IDLE_SECONDS1" != "" ] && USEREXTRA1="${USEREXTRA1}Idle Seconds = ${IDLE_SECONDS1}
"
USEREXTRA2="" #v3.99 bugfix...
[ "$DIAL_PREFIX2" != "" ] && USEREXTRA2="${USEREXTRA2}Dial Prefix = ${DIAL_PREFIX2}
"
[ "$LOGIN_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Login Prompt = ${LOGIN_PROMPT2}
"
[ "$PASSWORD_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Password Prompt = ${PASSWORD_PROMPT2}
"
[ "$STUPID_MODE2" != "" ] && USEREXTRA2="${USEREXTRA2}Stupid Mode = ${STUPID_MODE2}
"
[ "$DEFAULT_REPLY2" != "" ] && USEREXTRA2="${USEREXTRA2}Default Reply = ${DEFAULT_REPLY2}
"
[ "$AUTO_RECONNECT2" != "" ] && USEREXTRA2="${USEREXTRA2}Auto Reconnect = ${AUTO_RECONNECT2}
"
[ "$IDLE_SECONDS2" != "" ] && USEREXTRA2="${USEREXTRA2}Idle Seconds = ${IDLE_SECONDS2}
"
[ "$CHECKCC" = "true" ] && CHECKCC="yes"
[ "$CHECKCC" = "false" ] && CHECKCC="no"
#v424 Retain original dial type, in case edited to DP.
DIALSTR="AT"
[ "$CHECKDT" = "true" -a "$CHECKBC" = "true" ] && DIALSTR="AT"
[ "$CHECKDT" = "false" -a "$CHECKBC" = "true" ] && DIALSTR="ATX3"
[ "$CHECKDT" = "false" -a "$CHECKBC" = "false" ] && DIALSTR="ATX1"
[ "$CHECKDT" = "true" -a "$CHECKBC" = "false" ] && DIALSTR="ATX2"
DIALSTR="${DIALSTR}${DIALTYPE}"
[ "$DEVMALT" = "" ] && DEVMALTLINE="" || DEVMALTLINE="#Modem = /dev/${DEVMALT}
"
echo '[Dialer Defaults]' > /etc/wvdial.conf
echo -n "Modem = /dev/${DEVM}
${DEVMALTLINE}Baud = ${ENTRYBAUDM}
Init1 =
Init2 = ${ENTRYINIT2M}
Init3 = ${ENTRYINIT3M}
Carrier Check = ${CHECKCC}
Dial Command = ${DIALSTR}
[Dialer isp1]
Phone = ${ENTRYACC1ISP}
Username = ${ENTRYACC1USER}
Password = ${ENTRYACC1PASS}
${USEREXTRA1}
[Dialer isp1apn]
Init5 = AT+CGDCONT=${ACC1PRFL},\"IP\",\"${ENTRYACC1APN}\"
[Dialer isp2]
Phone = ${ENTRYACC2ISP}
Username = ${ENTRYACC2USER}
Password = ${ENTRYACC2PASS}
${USEREXTRA2}
[Dialer isp2apn]
Init5 = AT+CGDCONT=${ACC2PRFL},\"IP\",\"${ENTRYACC2APN}\"
[Dialer pin]
Init1 = AT+CPIN=${ENTRYWPINM}
[Dialer wireless]
#To force only 2G or 3G, uncomment the Init4 line and append 0 (2G) or 2 (3G), and substitute your operator's name for MYOPS.
${INIT4M}
#Init6-Init9 lines are available for user purposes; the commented examples can be used as described:
#To force the 3G quality of service level, uncomment the Init6/Init7 line pair and set value two places each, for 384k/144k/64k, omitting the \"k\" (e.g., =1,4,64,384,64,384).
#To list all the APNs stored in the modem, uncomment the Init8 line; check the Connection status log for lines beginning with +CGDCONT:.
#To list the operator identifier stored in the modem, uncomment the Init9 line; check the Connection status log for a line beginning with +COPS:.
${INIT69M}" >> /etc/wvdial.conf
[ "$EXIT" = "EXIT" ] && exit
if [ "$EXIT" = "CONNECT1" -o "$EXIT" = "CONNECT2" ];then
[ "$EXIT" = "CONNECT1" ] && WVISP="isp1" || WVISP="isp2"
ln -snf $WVISP /var/local/pupdial/isp #v433 for stats
#v3.98 put this in, now remove... v408 back in...
#v3.98 something wrong with wvdial, it is supposed to automatically write
#to /etc/ppp/chap-secrets and pap-secrets but isn't...
if [ "$WVISP" = "isp1" ];then
echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/chap-secrets
echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/pap-secrets
else
echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/chap-secrets
echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/pap-secrets
fi
#v413 set wireless wvdial arguments, based on device, driver, PIN and APN fields; these do not include wireless modems that appear identical to wired analog modems.
WVWRLS=""; WVPIN=""; WVAPN=""
if [ "`echo "$DEVM" | grep -E 'ttyACM[0-9]|ttyUSB[0-9]|ttyHS[0-9]|ttynoz[0-9]|ttyIPWp[0-9]|rfcomm[0-9]'`" != "" ];then #v433 100929
WVWRLS="wireless" #Include optional user-edited init strings
if [ "$WVISP" = "isp1" ];then
[ "$ENTRYACC1APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC1APN" #v431
else
[ "$ENTRYACC2APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC2APN" #v431
fi
if [ "$ENTRYWPINM" != "" ] && [ ! -e /tmp/.pupdial_pin_sent ];then
WVPIN="pin"
touch /tmp/.pupdial_pin_sent
fi
fi
rm -f /tmp/pupdial.log
#v3.98 put this in, now remove...
#v3.98 /etc/ppp/options can cause conflict for wvdial.
#(i think 'options' is used by roaring penguin) hide it...
# mv -f /etc/ppp/options /etc/ppp/optionsHIDE
#/etc/ppp/peers/wvdial and wvdial-pipe are part of wvdial pkg, but these files
#conflict with Gkdial. Therefore, in the Unleashed wvdial pkg these files are
#kept in /etc/ppp/ and moved into peers/ as needed...
cp -f /etc/ppp/wvdial /etc/ppp/peers/
#v433 Substitute bluetooth wvdial options...
if which rfcomm >/dev/null && which hcitool >/dev/null \
&& [ "`echo "$DEVM" | grep '^rfcomm[0-9]'`" != "" ];then
[ -f /etc/wvdial_options/BT-wvdial ] \
&& cp -f /etc/wvdial_options/BT-wvdial /etc/ppp/peers/wvdial
BDADDR="`rfcomm show $DEVM | grep 'connected' | cut -f 2 -d > | cut -f 2 -d ' '`"
if [ "$BDADDR" != "" ];then
BDNAME="`hcitool name $BDADDR | tr -s ' ' | tr ' ' _ | tr / _ | tr '$' _`"
if [ "$BDNAME" != "" ];then
[ -f /etc/wvdial_options/BT-$BDNAME ] \
&& cp -f /etc/wvdial_options/BT-$BDNAME /etc/ppp/peers/wvdial \
|| cp -f /etc/ppp/peers/wvdial /etc/wvdial_options/BT-$BDNAME
fi
fi
echo -e "pupdial BT: DEVM: $DEVM BDADDR: $BDADDR /peers/wvdial:\n`cat /etc/ppp/peers/wvdial`" >> /tmp/udevtrace-modem.log #DEBUG
fi #433 end
[ "${WVAPN}" != "" ] \
&& [ -f /etc/wvdial_options/APN-${APNSTRING} ] \
&& echo "`cat /etc/wvdial_options/APN-${APNSTRING}`" >> /etc/ppp/peers/wvdial #431
[ -f /etc/ppp/wvdial-pipe ] \
&& cp -f /etc/ppp/wvdial-pipe /etc/ppp/peers/ #v3.98
wvdial ${WVISP} ${WVPIN} ${WVAPN} ${WVWRLS} &> /tmp/pupdial.log & #v413
[ ! -f /tmp/pupdial.log ] && sleep 1
[ ! -f /tmp/pupdial.log ] && sleep 1
Xdialog --center --wmclass "pupdial" --backtitle "NOTICE: If the log shows a failure to connect, please click left button" --title "PupDial: WvDial connection log" --ok-label "DISCONNECT or stop trying" --cancel-label "CLOSE window but stay online" --fixed-font --tailbox /tmp/pupdial.log 20 80
if [ $? -eq 0 ];then
/usr/sbin/modemdisconnect #v433
echo '' >> /tmp/pupdial.log
echo '------------------------------------------------------' >> /tmp/pupdial.log
echo '' >> /tmp/pupdial.log
exec pupdial #v3.91 go back to main window.
fi
fi
###END###