#!/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.
#101202 new script /usr/sbin/pupdial_init_hotpluggable, flag /var/local/pupdial/hotpluggable.
#101203 wvdialconf will ignore many devs that are not /dev/ttyS*, for example /dev/ttyAGS3 (agrmodem).
#101205 warning to wait 30 seconds after plugin.
#101206 innapropriate for another active network interface.
#101206 launch pupdial_wizard_helper after run wvdial.
#101211 update PupDial if modem changes.
#101217 new help button, for modem setup.
#101218 passed param if re-run this script do not do probe of hotpluggable modems.
#110505 support sudo for non-root user.
#120202 rodin.s: internationalized.
#120218 rerwin: Ensure non-null logon info for wvdial.
#120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
#120924 rerwin: correct setting of current modem device after erase.
#130331 change "Mono 12" to "Mono 10".
#130505 rerwin: notify network_tray of analog/wireless connection type
#131214 zigbert: gui (gtkdialog) improvements.
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
export TEXTDOMAIN=pupdial
export TEXTDOMAINDIR=/usr/share/locale
export OUTPUT_CHARSET=UTF-8
eval_gettext () {
local myMESSAGE=$(gettext "$1")
eval echo \"$myMESSAGE\"
}
msg_help (){
echo -e "$(gettext "This documentation has 2 chapters:\n1. Run wvdial\n2. Configure wvdial")\n\n\n
###################################################\n
$(gettext 'R U N W V D I A L')\n
###################################################\n\n" > /tmp/box_help
cat /usr/share/doc/wvdial/wvdial.txt >> /tmp/box_help
echo -e "\n\n\n\n
###################################################\n
$(gettext 'C O N F I G U R E W V D I A L')\n
###################################################\n\n" >> /tmp/box_help
cat /usr/share/doc/wvdial/wvdial.conf.txt >> /tmp/box_help
#box_help sees < > as markups, and will fail
sed -i -e 's/>/]/g' -e 's/[/g' /tmp/box_help
/usr/lib/gtkdialog/box_help "$(gettext 'PupDial - Internet connection with analog dialup or digital wireless modem (3g)')" "file:///usr/share/doc/HOWTO_modem.htm" &
}
export -f msg_help
#hint: for debugging, to force pupdial to ask all questions, delete /var/local/pupdial/hotpluggable
Yes_lbl="$(gettext 'Yes')"
No_lbl="$(gettext 'No')"
KERNVER="`uname -r`"
FLAGNEWPROBE='' #101203
PASSEDPARAM=''
[ $1 ] && PASSEDPARAM="$1" #101218
# dhcpcd interferes with wvdial writing to /etc/resolv.conf
for pid in /var/run/dhcpcd-*;do
D_PID=`cat $pid`
kill -9 $D_PID
rm -f $pid 2>&1 >/dev/null # discard the pid file
done
if [ "$PASSEDPARAM" = "" ];then #101218 do not probe if re-running pupdial.
#101206 innapropriate for another active network interface...
#note, could run 'modemdisconnect' if want to disconnect dialup interface.
/usr/sbin/networkdisconnect #but not ppp interface.
if [ ! -f /var/local/pupdial/hotpluggable ];then #101202
FLAGNEWPROBE='yes' #101203 flag 1st boot, or 'erase' button got clicked in pupdial (latter exits from pupdial).
export HOTDIALOG="
CHK_HOT
"
RETSTRING="`gtkdialog --center -p HOTDIALOG`"
CHK_HOT="`echo "$RETSTRING" | grep '^CHK_HOT' | cut -f 2 -d '"'`"
[ "$CHK_HOT" = "" ] && CHK_HOT='false'
echo -n "$CHK_HOT" > /var/local/pupdial/hotpluggable
fi
CHK_HOT="`cat /var/local/pupdial/hotpluggable`"
if [ "$CHK_HOT" = "true" ];then
#rm -f /dev/modem
pupdial_init_hotpluggable
fi
fi
MYDEVM="MYDEVM"
[ -h /dev/modem ] && MYDEVM='/dev/'"`readlink /dev/modem`"
[ "$MYDEVM" = "/dev/" ] && MYDEVM="MYDEVM" #101203
#101203 wvdialconf will ignore many devs that are not /dev/ttyS*, for example /dev/ttyAGS3 (agrmodem)...
#note, also have this code in /usr/sbin/modemprobe.
if [ "$MYDEVM" != "MYDEVM" ];then
MODEMDEV="`echo -n "$MYDEVM" | sed -e 's%/dev/%%'`" #could be in a subdir, ex: modems/mwave
MODEMBASE="`basename $MODEMDEV`" #ex: modems/mwave becomes: mwave
if [ "`echo -n "$MODEMBASE" | cut -c 1-4`" != "ttyS" ];then
#some that are recognised by wvdialconf: ttyUSB* (v1.51), ttyLT* (v1.50), ttyACM*, ttyI* (v0.12)
OK=0
if [ "`echo -n "$MODEMBASE" | cut -c 1-3`" = "tty" ];then
CHARS3="`echo -n "$MODEMBASE" | cut -c 4-6`"
case $CHARS3 in
USB) OK=1 ;;
LT*) OK=1 ;;
ACM) OK=1 ;;
I*) OK=1 ;;
esac
fi
if [ $OK -eq 0 ];then
SMODEMDEV='ttyS_'"`echo -n "$MODEMBASE" | sed -e 's%^tty%%' | cut -c 1-20`"
ln -snf $MODEMDEV /dev/$SMODEMDEV
ln -snf $SMODEMDEV /dev/modem #so that wvdialconf will look here first.
MYDEVM='/dev/'"$SMODEMDEV" #probably not essential
fi
fi
fi
#note, MYDEVM is placeholder for '/dev/ttyS0' whereas DEVM is just 'ttyS0'.
#101203 logic reorganised...
REPLACE='no'
[ ! -s /etc/wvdial.conf ] && REPLACE='yes'
if [ "$REPLACE" = "yes" ];then
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
fi
if [ "$MYDEVM" != "MYDEVM" ];then #modem detected; make config agree with /dev/modem.
SEDSCRIPT1="s%MYDEVM%$MYDEVM%" #101211 fix.
SEDSCRIPT2="s%/dev/modem%$MYDEVM%"
sed -i -e "$SEDSCRIPT1" -e "$SEDSCRIPT2" /etc/wvdial.conf
fi
#101211 hotpluggable modem may have changed....
if [ "$FLAGNEWPROBE" != "yes" ];then
if [ -h /dev/modem ];then
if [ -f /etc/wvdial.conf ];then
wvMODEM="`grep '^Modem =' /etc/wvdial.conf | head -n 1 | tr -s ' ' | cut -f 3 -d ' '`"
newMODEM="/dev/`readlink /dev/modem | sed -e 's%/dev/%%'`"
if [ -e ${newMODEM} ];then #precaution.
if [ "$wvMODEM" != "$newMODEM" ];then
Xdialog --left --wmclass "pupdial" --title "$(gettext 'PupDial: modem changed')" --ok-label "$(gettext 'UPDATE')" --cancel-label "$No_lbl" --yesno "`eval_gettext \"It seems that the modem has changed.\n
It was '\\\${wvMODEM}', it is now '\\\${newMODEM}'\n
Do you want to update PupDial?\n
Recommend click UPDATE button...\"`" 0 0
[ $? -eq 0 ] && FLAGNEWPROBE='yes'
fi
fi
fi
fi
fi
#i also want this to rerun after 'erase' button pressed in pupdial...
if [ "$FLAGNEWPROBE" = "yes" ];then
if [ "$MYDEVM" != "MYDEVM" -a "$MYDEVM" != "modem" ];then
Xdialog --left --wmclass "pupdial" --title "$(gettext 'PupDial: modem found')" --ok-label "$(gettext 'TEST')" --cancel-label "$No_lbl" --yesno "`eval_gettext \"It seems that you have a modem, at port \\\${MYDEVM}\n
However, it is recommended that you now click the 'TEST' button\n
to test that it is working.\n
\n
Note 1: The test will also optionally probe for what is called an\n
'inialization string'. If you are running PupDial for the first time\n
or have changed modems, you will definitely need to click the 'TEST'\n
button and obtain an initialization string.\n
\n
Note 2: If you think that \\\${MYDEVM} might be the wrong modem,\n
click the 'No' button and the main PupDial GUI has a 'CHOOSE' button\n
that will enable you to test alternative modem interfaces.\n
\n
Recommend click 'TEST' to probe the modem...\"`" 0 0
RETVAL=$?
DEVM="`echo -n "$MYDEVM" | cut -f 3,4 -d '/'`"
[ $RETVAL -eq 0 ] && modemtest $DEVM initonly
fi
fi
#v413 Assure user... 120514 bigger font...
yaf-splash -close never -bg orange -fontsize large -text "$(gettext 'Reading modem configuration file...')" &
X1PID=$!
#disconnect button...
STATECONb="disabled"
#v409 rerwin, bugfix...
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="$(gettext '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="$(gettext 'Modem detected! Device interface:') /dev/$DEVM" \
|| MSG1="$(gettext '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
[ "`grep 'MODEM WAS NOT AUTOMATICALLY DETECTED' /tmp/pupdial.log`" != "" ] && echo -n "" > /tmp/pupdial.log
if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
echo -n "`gettext \"Welcome to PupDial, written by Barry Kauler, with
contributions from 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.
If you are using PupDial for the first time, it is recommended that
you click the help buttons, in particular the 'Modem setup' button.\"`" >> /tmp/pupdial.log
fi
else
if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
echo "`gettext \"Welcome to PupDial, written by Barry Kauler, with
contributions from Richard Erwin, for Puppy Linux.
A MODEM WAS NOT AUTOMATICALLY DETECTED, SO YOU
NEED TO CLICK THE 'Choose modem' 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
MODEMINFO='
CHECKCC
'${STATECCM}'
CHECKDT
'${STATEDTM}'
CHECKBC
'${STATEBCM}'
echo "'${INIT2M}'"
ENTRYINIT2M
echo "'${INIT3M}'"
ENTRYINIT3M
"'${BAUDM}'"
ENTRYBAUDM
password
echo "'${WPINM}'"
ENTRYWPINM
'
export PupDial='
'"`/usr/lib/gtkdialog/xml_info fixed internet_connect.svg 60 "$(gettext 'Connect to internet with a analog dialup or digital wireless (3g) modem')" "$MSG1"`"'
'${MODEMINFO}'
"'${ACC1ISP}'"
ENTRYACC1ISP
"'${ACC1USER}'"
ENTRYACC1USER
"'${ACC1APN}'"
ENTRYACC1APN
password
"'${ACC1PASS}'"
ENTRYACC1PASS
ynSTUPID_MODE1
'${ynSTUPID_MODE1}'
ynAUTO_RECONNECT1
'${ynAUTO_RECONNECT1}'
"'${ACC2ISP}'"
ENTRYACC2ISP
"'${ACC2USER}'"
ENTRYACC2USER
"'${ACC2APN}'"
ENTRYACC2APN
password
"'${ACC2PASS}'"
ENTRYACC2PASS
ynSTUPID_MODE2
'${ynSTUPID_MODE2}'
ynAUTO_RECONNECT2
'${ynAUTO_RECONNECT2}'
INFO
/tmp/pupdial.log
90
'"`/usr/lib/gtkdialog/xml_scalegrip`"'
'
#mono text for log box...
#130331 change "Mono 12" to "Mono 10"...
echo 'style "specialmono"
{
font_name="Mono 10"
}
class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono
export GTK2_RC_FILES=/tmp/gtkrc_mono:$HOME/.gtkrc-2.0
kill $X1PID #v413
. /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
RETSTRING="`gtkdialog -p PupDial`"
#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 2 #101218 pass param.
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}
"
#120218 rerwin: Ensure non-null logon info for wvdial...
[ ! ${ENTRYACC1USER} ] && ENTRYACC1USER="MYUSERNAME"
[ ! ${ENTRYACC1PASS} ] && ENTRYACC1PASS="MYPASSWORD"
[ ! ${ENTRYACC2USER} ] && ENTRYACC2USER="MY2USERNAME"
[ ! ${ENTRYACC2PASS} ] && ENTRYACC2PASS="MY2PASSWORD"
MODEMDEVM="/dev/${DEVM}" #120924
[ "${DEVM}" = "MYDEVM" ] && MODEMDEVM="MYDEVM" #120924
echo '[Dialer Defaults]' > /etc/wvdial.conf
echo -n "Modem = ${MODEMDEVM}
${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]
#$(gettext "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}
#$(gettext 'Init6-Init9 lines are available for user purposes; the commented examples can be used as described:')
#$(gettext '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).')
#$(gettext 'To list all the APNs stored in the modem, uncomment the Init8 line; check the Connection status log for lines beginning with +CGDCONT:.')
#$(gettext '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
[ "$WVISP" = "isp1" ] \
&& ISPSTRING="$ENTRYACC1ISP" \
|| ISPSTRING="$ENTRYACC2ISP" #130505
rm -f /tmp/pupdial.log
#/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
echo "$ISPSTRING" | sed 's/.*,//g' | grep -q '^[0-9\.\-]*$' \
&& touch /tmp/.network_tray-use_analog_dialup_icons #130505
wvdial ${WVISP} ${WVPIN} ${WVAPN} ${WVWRLS} &> /tmp/pupdial.log & #v413
[ ! -f /tmp/pupdial.log ] && sleep 1
[ ! -f /tmp/pupdial.log ] && sleep 1
/usr/sbin/pupdial_wizard_helper & #101206
Xdialog --center --wmclass "pupdial" --backtitle "$(gettext 'NOTICE: If the log shows a failure to connect, please click left button')" --title "$(gettext 'PupDial: WvDial connection log')" --ok-label "$(gettext 'DISCONNECT or stop trying')" --cancel-label "$(gettext '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 2 #v3.91 go back to main window. 101218 pass param.
fi
fi
###END###