pupdial 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. #!/bin/bash
  2. #(c) Copyright 2007 Barry Kauler www.puppylinux.com
  3. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. #written for Puppy Linux 2.17+
  5. #BK v3.91: keep log if failed to connect, display in main status log.
  6. #BK v3.98: improve create mono font in status log. bugfixes.
  7. #BK v3.98: one bugfix had to be removed, which fixed another bugfix.
  8. #BK v3.99: corrected handling of params for each isp.
  9. #BK v3.99: added Stupid Mode and Auto reconnect checkboxes for each isp.
  10. #BK v4.00: crash bugfix.
  11. #HairyWill v4.00: handle init string with quotes, prevent gtkdialog crash.
  12. #v405 updated.
  13. #v408 old pap-secrets, chap-secrets problem has returned, workaround applied.
  14. #v408 rerwin: Make modem startup after 'erase' same as for first time with no conf file.
  15. #v409 rerwin: bugfix, need a delay for fast machines.
  16. #v412 rerwin: increase sleep from 0.3 to 1.
  17. #v465 rerwin: v413 add init strings for wireless modems
  18. #v477 rerwin: v413 add 'Reading...' splash message during sleep.
  19. #v424 rerwin: send PIN only on first wireless connection; move APNs to accounts; associate APN with dial accounts; retain dial type (DT/DP)
  20. #v431 rerwin: retain account checkbox changes; ensure optional lines associated with an account; add APN-specific commands; handle Idle Seconds lines
  21. #v433 rerwin: accomodate bluetooth-connected modems.
  22. #v433 Collect monthly transmission data.
  23. #101202 new script /usr/sbin/pupdial_init_hotpluggable, flag /var/local/pupdial/hotpluggable.
  24. #101203 wvdialconf will ignore many devs that are not /dev/ttyS*, for example /dev/ttyAGS3 (agrmodem).
  25. #101205 warning to wait 30 seconds after plugin.
  26. #101206 innapropriate for another active network interface.
  27. #101206 launch pupdial_wizard_helper after run wvdial.
  28. #101211 update PupDial if modem changes.
  29. #101217 new help button, for modem setup.
  30. #101218 passed param if re-run this script do not do probe of hotpluggable modems.
  31. #110505 support sudo for non-root user.
  32. #120202 rodin.s: internationalized.
  33. #120218 rerwin: Ensure non-null logon info for wvdial.
  34. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  35. #120924 rerwin: correct setting of current modem device after erase.
  36. #130331 change "Mono 12" to "Mono 10".
  37. #130505 rerwin: notify network_tray of analog/wireless connection type
  38. #131214 zigbert: gui (gtkdialog) improvements.
  39. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  40. export TEXTDOMAIN=pupdial
  41. export TEXTDOMAINDIR=/usr/share/locale
  42. export OUTPUT_CHARSET=UTF-8
  43. eval_gettext () {
  44. local myMESSAGE=$(gettext "$1")
  45. eval echo \"$myMESSAGE\"
  46. }
  47. msg_help (){
  48. echo -e "$(gettext "This documentation has 2 chapters:\n1. Run wvdial\n2. Configure wvdial")\n\n\n
  49. ###################################################\n
  50. $(gettext 'R U N W V D I A L')\n
  51. ###################################################\n\n" > /tmp/box_help
  52. cat /usr/share/doc/wvdial/wvdial.txt >> /tmp/box_help
  53. echo -e "\n\n\n\n
  54. ###################################################\n
  55. $(gettext 'C O N F I G U R E W V D I A L')\n
  56. ###################################################\n\n" >> /tmp/box_help
  57. cat /usr/share/doc/wvdial/wvdial.conf.txt >> /tmp/box_help
  58. #box_help sees < > as markups, and will fail
  59. sed -i -e 's/>/]/g' -e 's/</[/g' /tmp/box_help
  60. /usr/lib/gtkdialog/box_help "$(gettext 'PupDial - Internet connection with analog dialup or digital wireless modem (3g)')" "file:///usr/share/doc/HOWTO_modem.htm" &
  61. }
  62. export -f msg_help
  63. #hint: for debugging, to force pupdial to ask all questions, delete /var/local/pupdial/hotpluggable
  64. Yes_lbl="$(gettext 'Yes')"
  65. No_lbl="$(gettext 'No')"
  66. KERNVER="`uname -r`"
  67. FLAGNEWPROBE='' #101203
  68. PASSEDPARAM=''
  69. [ $1 ] && PASSEDPARAM="$1" #101218
  70. if [ "$PASSEDPARAM" = "" ];then #101218 do not probe if re-running pupdial.
  71. #101206 innapropriate for another active network interface...
  72. #note, could run 'modemdisconnect' if want to disconnect dialup interface.
  73. /usr/sbin/networkdisconnect #but not ppp interface.
  74. if [ ! -f /var/local/pupdial/hotpluggable ];then #101202
  75. FLAGNEWPROBE='yes' #101203 flag 1st boot, or 'erase' button got clicked in pupdial (latter exits from pupdial).
  76. export HOTDIALOG="
  77. <window title=\"$(gettext 'PupDial modem Internet dialer')\" icon-name=\"gtk-connect\">
  78. <vbox>
  79. <text><label>$(gettext 'Welcome! First, a basic question: do you want to connect to the Internet using an internal fixed modem, or a removable (USB, serial, PCMCIA) modem?')</label></text>
  80. <text><label>`gettext \"The reason for asking this, is an internal modem will have been detected at bootup, but a 'hotpluggable' external modem may not have have been detected if plugged in after bootup. Also, if you have both, say an internal analog dialup modem, plus a USB modem, PupDial may choose the wrong one -- ticking or unticking the checkbox here will avoid that confusion...\"`</label></text>
  81. <checkbox><label>$(gettext 'Tick checkbox if external modem')</label><variable>CHK_HOT</variable></checkbox>
  82. <hbox><button ok></button></hbox>
  83. </vbox>
  84. </window>"
  85. RETSTRING="`gtkdialog --center -p HOTDIALOG`"
  86. CHK_HOT="`echo "$RETSTRING" | grep '^CHK_HOT' | cut -f 2 -d '"'`"
  87. [ "$CHK_HOT" = "" ] && CHK_HOT='false'
  88. echo -n "$CHK_HOT" > /var/local/pupdial/hotpluggable
  89. fi
  90. CHK_HOT="`cat /var/local/pupdial/hotpluggable`"
  91. if [ "$CHK_HOT" = "true" ];then
  92. #rm -f /dev/modem
  93. pupdial_init_hotpluggable
  94. fi
  95. fi
  96. MYDEVM="MYDEVM"
  97. [ -h /dev/modem ] && MYDEVM='/dev/'"`readlink /dev/modem`"
  98. [ "$MYDEVM" = "/dev/" ] && MYDEVM="MYDEVM" #101203
  99. #101203 wvdialconf will ignore many devs that are not /dev/ttyS*, for example /dev/ttyAGS3 (agrmodem)...
  100. #note, also have this code in /usr/sbin/modemprobe.
  101. if [ "$MYDEVM" != "MYDEVM" ];then
  102. MODEMDEV="`echo -n "$MYDEVM" | sed -e 's%/dev/%%'`" #could be in a subdir, ex: modems/mwave
  103. MODEMBASE="`basename $MODEMDEV`" #ex: modems/mwave becomes: mwave
  104. if [ "`echo -n "$MODEMBASE" | cut -c 1-4`" != "ttyS" ];then
  105. #some that are recognised by wvdialconf: ttyUSB* (v1.51), ttyLT* (v1.50), ttyACM*, ttyI* (v0.12)
  106. OK=0
  107. if [ "`echo -n "$MODEMBASE" | cut -c 1-3`" = "tty" ];then
  108. CHARS3="`echo -n "$MODEMBASE" | cut -c 4-6`"
  109. case $CHARS3 in
  110. USB) OK=1 ;;
  111. LT*) OK=1 ;;
  112. ACM) OK=1 ;;
  113. I*) OK=1 ;;
  114. esac
  115. fi
  116. if [ $OK -eq 0 ];then
  117. SMODEMDEV='ttyS_'"`echo -n "$MODEMBASE" | sed -e 's%^tty%%' | cut -c 1-20`"
  118. ln -snf $MODEMDEV /dev/$SMODEMDEV
  119. ln -snf $SMODEMDEV /dev/modem #so that wvdialconf will look here first.
  120. MYDEVM='/dev/'"$SMODEMDEV" #probably not essential
  121. fi
  122. fi
  123. fi
  124. #note, MYDEVM is placeholder for '/dev/ttyS0' whereas DEVM is just 'ttyS0'.
  125. #101203 logic reorganised...
  126. REPLACE='no'
  127. [ ! -s /etc/wvdial.conf ] && REPLACE='yes'
  128. if [ "$REPLACE" = "yes" ];then
  129. echo "[Dialer Defaults]
  130. Modem = ${MYDEVM}
  131. Baud = 57600
  132. Init1 =
  133. Init2 = ATZ
  134. Init3 =
  135. Carrier Check = no
  136. Dial Command = ATDT
  137. [Dialer isp1]
  138. Phone = MYISPPHONENUM
  139. Username = MYUSERNAME
  140. Password = MYPASSWORD
  141. [Dialer isp1apn]
  142. Init5 = AT+CGDCONT=1,\"IP\",\"\"
  143. [Dialer isp2]
  144. Phone = MY2ISPPHONENUM
  145. Username = MY2USERNAME
  146. Password = MY2PASSWORD
  147. [Dialer isp2apn]
  148. Init5 = AT+CGDCONT=1,\"IP\",\"\"
  149. [Dialer pin]
  150. Init1 = AT+CPIN=" > /etc/wvdial.conf
  151. fi
  152. if [ "$MYDEVM" != "MYDEVM" ];then #modem detected; make config agree with /dev/modem.
  153. SEDSCRIPT1="s%MYDEVM%$MYDEVM%" #101211 fix.
  154. SEDSCRIPT2="s%/dev/modem%$MYDEVM%"
  155. sed -i -e "$SEDSCRIPT1" -e "$SEDSCRIPT2" /etc/wvdial.conf
  156. fi
  157. #101211 hotpluggable modem may have changed....
  158. if [ "$FLAGNEWPROBE" != "yes" ];then
  159. if [ -h /dev/modem ];then
  160. if [ -f /etc/wvdial.conf ];then
  161. wvMODEM="`grep '^Modem =' /etc/wvdial.conf | head -n 1 | tr -s ' ' | cut -f 3 -d ' '`"
  162. newMODEM="/dev/`readlink /dev/modem | sed -e 's%/dev/%%'`"
  163. if [ -e ${newMODEM} ];then #precaution.
  164. if [ "$wvMODEM" != "$newMODEM" ];then
  165. 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
  166. It was '\\\${wvMODEM}', it is now '\\\${newMODEM}'\n
  167. Do you want to update PupDial?\n
  168. Recommend click UPDATE button...\"`" 0 0
  169. [ $? -eq 0 ] && FLAGNEWPROBE='yes'
  170. fi
  171. fi
  172. fi
  173. fi
  174. fi
  175. #i also want this to rerun after 'erase' button pressed in pupdial...
  176. if [ "$FLAGNEWPROBE" = "yes" ];then
  177. if [ "$MYDEVM" != "MYDEVM" -a "$MYDEVM" != "modem" ];then
  178. 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
  179. However, it is recommended that you now click the 'TEST' button\n
  180. to test that it is working.\n
  181. \n
  182. Note 1: The test will also optionally probe for what is called an\n
  183. 'inialization string'. If you are running PupDial for the first time\n
  184. or have changed modems, you will definitely need to click the 'TEST'\n
  185. button and obtain an initialization string.\n
  186. \n
  187. Note 2: If you think that \\\${MYDEVM} might be the wrong modem,\n
  188. click the 'No' button and the main PupDial GUI has a 'CHOOSE' button\n
  189. that will enable you to test alternative modem interfaces.\n
  190. \n
  191. Recommend click 'TEST' to probe the modem...\"`" 0 0
  192. RETVAL=$?
  193. DEVM="`echo -n "$MYDEVM" | cut -f 3,4 -d '/'`"
  194. [ $RETVAL -eq 0 ] && modemtest $DEVM initonly
  195. fi
  196. fi
  197. #v413 Assure user... 120514 bigger font...
  198. yaf-splash -close never -bg orange -fontsize large -text "$(gettext 'Reading modem configuration file...')" &
  199. X1PID=$!
  200. #disconnect button...
  201. STATECONb="disabled"
  202. #v409 rerwin, bugfix...
  203. if [ "`pidof pppd`" != "" ];then #v409
  204. [ ! -f /etc/ppp/peers/wvdial ] && sleep 1 #v409 allow kill completion and repeat test. v412 0.3 to 1.
  205. [ "`pidof pppd`" != "" ] && STATECONb="enabled"
  206. fi #v409
  207. MSG1="$(gettext 'No modem detected! You cannot dialout!')"
  208. STATECONa="disabled"
  209. STATETEST="disabled" #101117
  210. STATECCM="yes"
  211. STATEDTM="yes"
  212. STATEBCM="yes"
  213. TESTMSG="Modem"
  214. #precaution...
  215. cat /etc/wvdial.conf | tr '\t' ' ' | tr -s ' ' > /tmp/wvdial.conf
  216. sync
  217. #Rerwin: v4.05 Substitute /dev/modem target for /dev/modem
  218. if [ "`grep '/dev/modem' /tmp/wvdial.conf`" != "" -a -h /dev/modem ];then #modem = /dev/modem & it exists
  219. SEDSCRIPT="s%/dev/modem%/dev/`readlink /dev/modem`%g"
  220. sed -i -e "$SEDSCRIPT" /tmp/wvdial.conf #replace device in-place
  221. fi
  222. mv -f /tmp/wvdial.conf /etc/wvdial.conf
  223. sync #v413 ensure config updated
  224. ISPM="`cat /etc/wvdial.conf | grep '^Phone = ' | head -n 2`"
  225. ACC1ISP="`echo "$ISPM" | head -n 1 | cut -f 3-6 -d ' '`"
  226. ACC2ISP="`echo "$ISPM" | tail -n 1 | cut -f 3-6 -d ' '`"
  227. USERM="`cat /etc/wvdial.conf | grep '^Username = ' | head -n 2`"
  228. ACC1USER="`echo "$USERM" | head -n 1 | cut -f 3 -d ' '`"
  229. ACC2USER="`echo "$USERM" | tail -n 1 | cut -f 3 -d ' '`"
  230. PASSM="`cat /etc/wvdial.conf | grep '^Password = ' | head -n 2`"
  231. ACC1PASS="`echo "$PASSM" | head -n 1 | cut -f 3 -d ' '`"
  232. ACC2PASS="`echo "$PASSM" | tail -n 1 | cut -f 3 -d ' '`"
  233. INIT5M="`cat /etc/wvdial.conf | grep '^Init5 = AT+CGDCONT=' | head -n 2`"
  234. [ "`grep '\[Dialer isp2apn\]' /etc/wvdial.conf`" = "" ] && INIT5M="`echo -e "$INIT5M\n"`"
  235. ACC1PRFL="`echo "$INIT5M" | head -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
  236. ACC2PRFL="`echo "$INIT5M" | tail -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
  237. ACC1APN="`echo "$INIT5M" | head -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
  238. ACC2APN="`echo "$INIT5M" | tail -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
  239. [ "$ACC1PRFL" = "" ] && ACC1PRFL="1"; [ "$ACC2PRFL" = "" ] && ACC2PRFL="1"
  240. #1st 'cut' fixes if the '/dev/' left off the device name...
  241. #note, initialised wvdial.conf has 'Modem = MYDEVM' where MYDEVM needs to become
  242. # '/dev/ttyS0' (for example)
  243. DEVM="`cat /etc/wvdial.conf | grep '^Modem = ' | cut -f 3 -d ' ' | cut -f 3 -d '/'`"
  244. DEVMALT="`cat /etc/wvdial.conf | grep '^#Modem = ' | tail -n 1 | cut -f 3 -d ' ' | cut -f 3 -d '/'`" #v432
  245. [ "$DEVM" = "" ] && DEVM='MYDEVM' #v4.00 bugfix, crashed if no DEVM.
  246. [ ! -f /tmp/pupdial.log ] && touch /tmp/pupdial.log #v408 rerwin, moved up.
  247. if [ "${DEVM}" != "MYDEVM" ];then
  248. [ -f /tmp/.pupdial-modem_detected ] \
  249. && rm -f /tmp/.pupdial-modem_detected \
  250. && MSG1="$(gettext 'Modem detected! Device interface:') /dev/$DEVM" \
  251. || MSG1="$(gettext 'Selected modem device interface:') /dev/$DEVM" #v433
  252. #101117 Protect HSF/HCF connections from lockup - ensure nvm files installed.
  253. [ "`pidof pppd`" = "" ] \
  254. && STATETEST="enabled" \
  255. && [ "`echo "${DEVM}" | grep 'ttySHSF[0-9]'`" = "" -o -d /etc/hsfmodem/nvm ] \
  256. && [ "`echo "${DEVM}" | grep 'ttySHCF[0-9]'`" = "" -o -d /etc/hcfpcimodem/nvm ] \
  257. && STATECONa="enabled" #dialout button.
  258. [ "$DEVMALT" = "" ] \
  259. && TESTMSG="$DEVM" \
  260. || TESTMSG="$DEVMALT" #v433
  261. TESTDEVM="$TESTMSG" #v432
  262. [ "`grep 'MODEM WAS NOT AUTOMATICALLY DETECTED' /tmp/pupdial.log`" != "" ] && echo -n "" > /tmp/pupdial.log
  263. if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
  264. echo -n "`gettext \"Welcome to PupDial, written by Barry Kauler, with
  265. contributions from Richard Erwin, for Puppy Linux.
  266. There is a configuration file, /etc/wvdial.conf, that is read by
  267. PupDial, and changes made to any of the above boxes will be saved
  268. to wvdial.conf when you click the 'Exit' or 'Connect' buttons.
  269. Note, you can also manually edit wvdial.conf with a text editor.
  270. If you are using PupDial for the first time, it is recommended that
  271. you click the help buttons, in particular the 'Modem setup' button.\"`" >> /tmp/pupdial.log
  272. fi
  273. else
  274. if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
  275. echo "`gettext \"Welcome to PupDial, written by Barry Kauler, with
  276. contributions from Richard Erwin, for Puppy Linux.
  277. A MODEM WAS NOT AUTOMATICALLY DETECTED, SO YOU
  278. NEED TO CLICK THE 'Choose modem' BUTTON. DO THIS NOW!\"`
  279. " > /tmp/pupdial.log
  280. fi
  281. fi
  282. BAUDM="`cat /etc/wvdial.conf | grep '^Baud = ' | cut -f 3 -d ' '`"
  283. #v4.00 HairyWill fixes for embedded $ " characters...
  284. 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
  285. INIT2M="`cat /etc/wvdial.conf | grep '^Init2 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`"
  286. INIT3M="`cat /etc/wvdial.conf | grep '^Init3 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`" #v413
  287. #v413 If first Init1 not null, move contents to Init2, and Init2 to Init3, to reserve Init1 for wireless PIN.
  288. [ "$INIT1M" != "" ] && INIT3M="$INIT2M" && INIT2M="$INIT1M" && INIT1M="" #v413
  289. #v413 Get values for Init1, 4, 6-9.
  290. WPINM="`cat /etc/wvdial.conf | grep '^Init1 = ' | tail -n 1 | cut -f 3 -d '='`"
  291. INIT4M="`cat /etc/wvdial.conf | grep '^#*Init4 =' | sed 's/"/\\"/g;;s/\$/\\$/g;s/$$//g;'`"
  292. [ "$INIT4M" = "" ] && INIT4M="#Init4 = AT+COPS=0,0,\"MYOPS\","
  293. INIT69M="`cat /etc/wvdial.conf | grep '^#*Init[6-9] =' | sed -e 's/"/\\"/g' -e 's/\$/\\$/g' -e 's/$$//'`"
  294. [ "$INIT69M" = "" ] && INIT69M="#Init6 = AT+CGEQMIN=1,4,64,384,64,384
  295. #Init7 = AT+CGEQREQ=1,4,64,384,64,384
  296. #Init8 = AT+CGDCONT?
  297. #Init9 = AT+COPS?"
  298. #v413 end
  299. DIALM="`cat /etc/wvdial.conf | grep '^Dial Command = ' | cut -f 4 -d ' '`"
  300. [ "`echo "$DIALM" | grep -E 'X3|X1'`" != "" ] && STATEDTM="no"
  301. [ "`echo "$DIALM" | grep -E 'X2|X1'`" != "" ] && STATEBCM="no"
  302. CCM="`cat /etc/wvdial.conf | grep '^Carrier Check = ' | cut -f 4 -d ' '`"
  303. [ "$CCM" = "no" ] && STATECCM="no"
  304. [ "`echo "$DIALM" | grep 'DP'`" = "" ] && DIALTYPE="DT" || DIALTYPE="DP" #v424
  305. #v3.99 there may be up to two of each of the above...
  306. ISPCNT=0 #v431
  307. echo -n "" > /tmp/pupdial_read
  308. cat /etc/wvdial.conf |
  309. while read ONELINE
  310. do
  311. ONELINE="`echo -n "$ONELINE" | tr '\t' ' ' | tr -s ' '`" #in case user puts in extra tabs and spaces.
  312. [ "$ONELINE" = "" -o "$ONELINE" = " " ] && continue
  313. #v431 begin
  314. case $ONELINE in
  315. "[Dialer isp1]") ISPCNT=1 ;;
  316. "[Dialer isp1apn]") ISPCNT=0 ;;
  317. "[Dialer isp2]") ISPCNT=2 ;;
  318. "[Dialer isp2apn]") ISPCNT=0 ;;
  319. esac
  320. [ $ISPCNT -eq 0 ] && continue
  321. #v431 end
  322. ONEPARAM="`echo -n "$ONELINE" | cut -f 1 -d '=' | sed -e 's/ $//'`"
  323. ONEVALUE="`echo -n "$ONELINE" | cut -f 2 -d '=' | sed -e 's/^ //'`"
  324. if [ "$ONEVALUE" != "" ];then
  325. case $ONEPARAM in
  326. "Dial Prefix") echo "DIAL_PREFIX${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  327. "Login Prompt") echo "LOGIN_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  328. "Password Prompt") echo "PASSWORD_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  329. "Stupid Mode") echo "STUPID_MODE${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  330. "Default Reply") echo "DEFAULT_REPLY${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  331. "Auto Reconnect") echo "AUTO_RECONNECT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  332. "Idle Seconds") echo "IDLE_SECONDS${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;; #v431
  333. esac
  334. fi
  335. done
  336. eval "`cat /tmp/pupdial_read`"
  337. #v3.99
  338. ynSTUPID_MODE1=no
  339. [ "$STUPID_MODE1" = "1" -o "$STUPID_MODE1" = "yes" ] && ynSTUPID_MODE1=yes
  340. ynSTUPID_MODE2=no
  341. [ "$STUPID_MODE2" = "1" -o "$STUPID_MODE2" = "yes" ] && ynSTUPID_MODE2=yes
  342. ynAUTO_RECONNECT1=yes #default is on.
  343. [ "$AUTO_RECONNECT1" = "1" -o "$AUTO_RECONNECT1" = "yes" ] && ynAUTO_RECONNECT1=yes
  344. [ "$AUTO_RECONNECT1" = "0" -o "$AUTO_RECONNECT1" = "no" ] && ynAUTO_RECONNECT1=no
  345. ynAUTO_RECONNECT2=yes #default is on.
  346. [ "$AUTO_RECONNECT2" = "1" -o "$AUTO_RECONNECT2" = "yes" ] && ynAUTO_RECONNECT2=yes
  347. [ "$AUTO_RECONNECT2" = "0" -o "$AUTO_RECONNECT2" = "no" ] && ynAUTO_RECONNECT2=no
  348. MODEMINFO='
  349. <hbox space-expand="true" space-fill="true">
  350. <vbox space-expand="false" space-fill="false">
  351. <button>
  352. <label>'${TESTMSG}'</label>
  353. <visible>'${STATETEST}'</visible>
  354. <action>/usr/sbin/modemtest '${TESTDEVM}'</action>
  355. <action type="exit">reload</action>
  356. </button>
  357. <button>
  358. <label>'$(gettext 'Choose modem')'</label>
  359. <action>/usr/sbin/modemprobe</action>
  360. <action>cat /tmp/logwvdialprobe > /tmp/pupdial.log 2> /dev/null</action>
  361. <action type="exit">reload</action>
  362. </button>
  363. <checkbox>
  364. <label>'$(gettext 'Carrier check')'</label>
  365. <variable>CHECKCC</variable>
  366. <default>'${STATECCM}'</default>
  367. </checkbox>
  368. <checkbox>
  369. <label>'$(gettext 'Dialtone check')'</label>
  370. <variable>CHECKDT</variable>
  371. <default>'${STATEDTM}'</default>
  372. </checkbox>
  373. <checkbox>
  374. <label>'$(gettext 'Busy check')'</label>
  375. <variable>CHECKBC</variable>
  376. <default>'${STATEBCM}'</default>
  377. </checkbox>
  378. </vbox>
  379. <vseparator width-request="30" space-expand="false" space-fill="false"></vseparator>
  380. <vbox>
  381. <hbox tooltip-text="'$(gettext 'String for modem initialisation')'">
  382. <text><label>'$(gettext 'Initialisation string 2')'</label></text>
  383. <entry>
  384. <input>echo "'${INIT2M}'"</input>
  385. <variable>ENTRYINIT2M</variable>
  386. </entry>
  387. </hbox>
  388. <hbox tooltip-text="'$(gettext 'String for modem initialisation')'">
  389. <text><label>'$(gettext 'Initialisation string 3')'</label></text>
  390. <entry>
  391. <input>echo "'${INIT3M}'"</input>
  392. <variable>ENTRYINIT3M</variable>
  393. </entry>
  394. </hbox>
  395. <text space-expand="true" space-fill="true"><label>""</label></text>
  396. <hbox space-expand="true" space-fill="true">
  397. <text space-expand="false" space-fill="false"><label>'$(gettext 'Max speed')'</label></text>
  398. <entry width-request="100" space-expand="false" space-fill="false">
  399. <default>"'${BAUDM}'"</default>
  400. <variable>ENTRYBAUDM</variable>
  401. </entry>
  402. </hbox>
  403. <hbox space-expand="true" space-fill="true">
  404. <text space-expand="false" space-fill="false"><label>'$(gettext 'SIM PIN (if required)')'</label></text>
  405. <entry width-request="100" space-expand="false" space-fill="false">
  406. <visible>password</visible>
  407. <input>echo "'${WPINM}'"</input>
  408. <variable>ENTRYWPINM</variable>
  409. </entry>
  410. </hbox>
  411. </vbox>
  412. </hbox>'
  413. export PupDial='
  414. <window title="PupDial - '$(gettext 'Modem Internet dialer')'" icon-name="gtk-connect">
  415. <vbox space-expand="true" space-fill="true">
  416. '"`/usr/lib/gtkdialog/xml_info fixed internet_connect.svg 60 "$(gettext 'Connect to internet with a analog dialup or digital wireless (3g) modem')" "<b>$MSG1</b>"`"'
  417. <frame '$(gettext 'Modem setup')'>
  418. '${MODEMINFO}'
  419. </frame>
  420. <hbox>
  421. <notebook labels="'$(gettext 'Account 1|Account2')'" space-expand="true" space-fill="true">
  422. <hbox border-width="10" space-expand="true" space-fill="true">
  423. <button image-position="2" tooltip-text="'$(gettext 'Connect to the Internet')'" space-expand="false" space-fill="false">
  424. <label>" '$(gettext 'Connect')' "</label>
  425. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  426. <visible>'${STATECONa}'</visible>
  427. <action type="exit">CONNECT1</action>
  428. </button>
  429. <vbox space-expand="true" space-fill="true">
  430. <hbox homogeneous="true" space-expand="true" space-fill="true">
  431. <hbox space-expand="true" space-fill="true">
  432. <text space-expand="true" space-fill="true"><label>""</label></text>
  433. <text tooltip-text="'$(gettext 'Enter the Phone or Access Number here')'" space-expand="false" space-fill="false"><label>'$(gettext 'Phone number')'</label></text>
  434. </hbox>
  435. <entry width-request="130" tooltip-text="'$(gettext 'Enter the Phone or Access Number here')'" space-expand="true" space-fill="true">
  436. <default>"'${ACC1ISP}'"</default>
  437. <variable>ENTRYACC1ISP</variable>
  438. </entry>
  439. <hbox space-expand="true" space-fill="true">
  440. <text space-expand="true" space-fill="true"><label>""</label></text>
  441. <text space-expand="false" space-fill="false"><label>'$(gettext 'Username')'</label></text>
  442. </hbox>
  443. <entry width-request="130" space-expand="true" space-fill="true">
  444. <default>"'${ACC1USER}'"</default>
  445. <variable>ENTRYACC1USER</variable>
  446. </entry>
  447. </hbox>
  448. <hbox homogeneous="true" space-expand="true" space-fill="true">
  449. <hbox space-expand="true" space-fill="true">
  450. <text space-expand="true" space-fill="true"><label>""</label></text>
  451. <text tooltip-text="'$(gettext 'Only for 3G or cell/mobile phone connections')'" space-expand="false" space-fill="false"><label>'$(gettext 'Wireless: APN:')'</label></text>
  452. </hbox>
  453. <entry width-request="130" tooltip-text="'$(gettext 'Only for 3G or cell/mobile phone connections')'" space-expand="true" space-fill="true">
  454. <default>"'${ACC1APN}'"</default>
  455. <variable>ENTRYACC1APN</variable>
  456. </entry>
  457. <hbox space-expand="true" space-fill="true">
  458. <text space-expand="true" space-fill="true"><label>""</label></text>
  459. <text tooltip-text="'$(gettext 'Enter your password here')'" space-expand="false" space-fill="false"><label>'$(gettext 'Password')'</label></text>
  460. </hbox>
  461. <entry width-request="130" tooltip-text="'$(gettext 'Enter your password here')'" space-expand="true" space-fill="true">
  462. <visible>password</visible>
  463. <default>"'${ACC1PASS}'"</default>
  464. <variable>ENTRYACC1PASS</variable>
  465. </entry>
  466. </hbox>
  467. <hbox homogeneous="true">
  468. <hbox tooltip-text="'$(gettext 'Recommended to check this box if using a 3G modem')'" space-expand="true" space-fill="true">
  469. <text space-expand="true" space-fill="true"><label>""</label></text>
  470. <checkbox space-expand="false" space-fill="false">
  471. <label>'$(gettext 'Stupid mode')'</label>
  472. <variable>ynSTUPID_MODE1</variable>
  473. <default>'${ynSTUPID_MODE1}'</default>
  474. </checkbox>
  475. </hbox>
  476. <hbox tooltip-text="'$(gettext 'Make sure this box is checked to attempt auto reconnection')'" space-expand="true" space-fill="true">
  477. <text space-expand="true" space-fill="true"><label>""</label></text>
  478. <checkbox space-expand="false" space-fill="false">
  479. <label>'$(gettext 'Auto Reconnect')'</label>
  480. <variable>ynAUTO_RECONNECT1</variable>
  481. <default>'${ynAUTO_RECONNECT1}'</default>
  482. </checkbox>
  483. </hbox>
  484. </hbox>
  485. </vbox>
  486. </hbox>
  487. <hbox border-width="10" space-expand="true" space-fill="true">
  488. <button image-position="2" tooltip-text="'$(gettext 'Connect to the Internet')'" space-expand="false" space-fill="false">
  489. <label>" '$(gettext 'Connect')' "</label>
  490. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  491. <visible>'${STATECONa}'</visible>
  492. <action type="exit">CONNECT2</action>
  493. </button>
  494. <vbox space-expand="true" space-fill="true">
  495. <hbox homogeneous="true" space-expand="true" space-fill="true">
  496. <hbox space-expand="true" space-fill="true">
  497. <text space-expand="true" space-fill="true"><label>""</label></text>
  498. <text tooltip-text="'$(gettext 'Enter the Phone or Access Number here')'" space-expand="false" space-fill="false"><label>'$(gettext 'Phone number')'</label></text>
  499. </hbox>
  500. <entry width-request="130" tooltip-text="'$(gettext 'Enter the Phone or Access Number here')'" space-expand="true" space-fill="true">
  501. <default>"'${ACC2ISP}'"</default>
  502. <variable>ENTRYACC2ISP</variable>
  503. </entry>
  504. <hbox space-expand="true" space-fill="true">
  505. <text space-expand="true" space-fill="true"><label>""</label></text>
  506. <text space-expand="false" space-fill="false"><label>'$(gettext 'Username')'</label></text>
  507. </hbox>
  508. <entry width-request="130" space-expand="true" space-fill="true">
  509. <default>"'${ACC2USER}'"</default>
  510. <variable>ENTRYACC2USER</variable>
  511. </entry>
  512. </hbox>
  513. <hbox homogeneous="true" space-expand="true" space-fill="true">
  514. <hbox space-expand="true" space-fill="true">
  515. <text space-expand="true" space-fill="true"><label>""</label></text>
  516. <text tooltip-text="'$(gettext 'Only for 3G or cell/mobile phone connections')'" space-expand="false" space-fill="false"><label>'$(gettext 'Wireless: APN:')'</label></text>
  517. </hbox>
  518. <entry width-request="130" tooltip-text="'$(gettext 'Only for 3G or cell/mobile phone connections')'" space-expand="true" space-fill="true">
  519. <default>"'${ACC2APN}'"</default>
  520. <variable>ENTRYACC2APN</variable>
  521. </entry>
  522. <hbox space-expand="true" space-fill="true">
  523. <text space-expand="true" space-fill="true"><label>""</label></text>
  524. <text tooltip-text="'$(gettext 'Enter your password here')'" space-expand="false" space-fill="false"><label>'$(gettext 'Password')'</label></text>
  525. </hbox>
  526. <entry width-request="130" tooltip-text="'$(gettext 'Enter your password here')'" space-expand="true" space-fill="true">
  527. <visible>password</visible>
  528. <default>"'${ACC2PASS}'"</default>
  529. <variable>ENTRYACC2PASS</variable>
  530. </entry>
  531. </hbox>
  532. <hbox homogeneous="true">
  533. <hbox tooltip-text="'$(gettext 'Recommended to check this box if using a 3G modem')'" space-expand="true" space-fill="true">
  534. <text space-expand="true" space-fill="true"><label>""</label></text>
  535. <checkbox space-expand="false" space-fill="false">
  536. <label>'$(gettext 'Stupid mode')'</label>
  537. <variable>ynSTUPID_MODE2</variable>
  538. <default>'${ynSTUPID_MODE2}'</default>
  539. </checkbox>
  540. </hbox>
  541. <hbox tooltip-text="'$(gettext 'Make sure this box is checked to attempt auto reconnection')'" space-expand="true" space-fill="true">
  542. <text space-expand="true" space-fill="true"><label>""</label></text>
  543. <checkbox space-expand="false" space-fill="false">
  544. <label>'$(gettext 'Auto Reconnect')'</label>
  545. <variable>ynAUTO_RECONNECT2</variable>
  546. <default>'${ynAUTO_RECONNECT2}'</default>
  547. </checkbox>
  548. </hbox>
  549. </hbox>
  550. </vbox>
  551. </hbox>
  552. </notebook>
  553. </hbox>
  554. <vbox space-expand="true" space-fill="true">
  555. <edit editable="false" space-expand="true" space-fill="true">
  556. <variable>INFO</variable>
  557. <input file>/tmp/pupdial.log</input>
  558. <height>90</height>
  559. </edit>
  560. </vbox>
  561. <hbox space-expand="false" space-fill="false">
  562. <button space-expand="false" space-fill="false">
  563. <label>'$(gettext 'Help')'</label>
  564. '"`/usr/lib/gtkdialog/xml_button-icon help`"'
  565. <action>msg_help</action>
  566. </button>
  567. <text space-expand="true" space-fill="true"><label>""</label></text>
  568. <button>
  569. <label>'$(gettext 'Disconnect from the internet')'</label>
  570. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect_no.svg`"'
  571. <visible>'${STATECONb}'</visible>
  572. <action>/usr/sbin/modemdisconnect</action>
  573. <action>rm -f /tmp/pupdial.log</action>
  574. <action type="exit">EXIT</action>
  575. </button>
  576. <button>
  577. <label>'$(gettext 'Quit')'</label>
  578. '"`/usr/lib/gtkdialog/xml_button-icon quit`"'
  579. <action type="exit">EXIT</action>
  580. </button>
  581. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  582. </hbox>
  583. </vbox>
  584. </window>'
  585. #mono text for log box...
  586. #130331 change "Mono 12" to "Mono 10"...
  587. echo 'style "specialmono"
  588. {
  589. font_name="Mono 10"
  590. }
  591. class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono
  592. export GTK2_RC_FILES=/tmp/gtkrc_mono:$HOME/.gtkrc-2.0
  593. kill $X1PID #v413
  594. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  595. RETSTRING="`gtkdialog -p PupDial`"
  596. #v4.00 to handle embedded quote, extract ENTRYINIT2M and ENTRYINIT3M separately...
  597. ENTRYINIT2M="`echo "$RETSTRING" | grep '^ENTRYINIT2M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
  598. ENTRYINIT3M="`echo "$RETSTRING" | grep '^ENTRYINIT3M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
  599. ENTRYWPINM="`echo "$RETSTRING" | grep '^ENTRYWPINM=' | cut -f 2-9 -d '"' | sed -e 's/"$//' | tr -d ' '`" #no spaces
  600. RETSTRING="`echo "$RETSTRING" | grep -v '^ENTRYINIT3M=' | grep -v '^ENTRYINIT2M=' | grep -v '^ENTRYWPINM='`"
  601. #v405 getting some weird stuff on stdout from gtkdialog3, fix...
  602. #all lines must have format variable="value"... v406 add '_'...
  603. xRETSTRING="`echo "$RETSTRING" | grep -E '^[a-zA-Z0-9_]+=\".*\"$'`" # | grep -v '^INFO='
  604. eval "$xRETSTRING"
  605. [ ! -f /etc/wvdial.conf ] && exit
  606. if [ "$EXIT" = "abort" -o "$EXIT" = "" ];then
  607. rm -f /tmp/pupdial.log #v3.91
  608. exit
  609. fi
  610. [ "$EXIT" = "reload" ] && exec pupdial 2 #101218 pass param.
  611. rm -f /tmp/pupdial.log #v3.91
  612. #v3.99
  613. STUPID_MODE1=""
  614. STUPID_MODE2=""
  615. [ "$ynSTUPID_MODE1" = "true" ] && STUPID_MODE1="yes"
  616. [ "$ynSTUPID_MODE2" = "true" ] && STUPID_MODE2="yes"
  617. [ "$ynAUTO_RECONNECT1" = "true" ] && AUTO_RECONNECT1=yes
  618. [ "$ynAUTO_RECONNECT1" = "false" ] && AUTO_RECONNECT1=no
  619. [ "$ynAUTO_RECONNECT2" = "true" ] && AUTO_RECONNECT2=yes
  620. [ "$ynAUTO_RECONNECT2" = "false" ] && AUTO_RECONNECT2=no
  621. USEREXTRA1="" #v3.99 bug fix...
  622. [ "$DIAL_PREFIX1" != "" ] && USEREXTRA1="${USEREXTRA1}Dial Prefix = ${DIAL_PREFIX1}
  623. "
  624. [ "$LOGIN_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Login Prompt = ${LOGIN_PROMPT1}
  625. "
  626. [ "$PASSWORD_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Password Prompt = ${PASSWORD_PROMPT1}
  627. "
  628. [ "$STUPID_MODE1" != "" ] && USEREXTRA1="${USEREXTRA1}Stupid Mode = ${STUPID_MODE1}
  629. "
  630. [ "$DEFAULT_REPLY1" != "" ] && USEREXTRA1="${USEREXTRA1}Default Reply = ${DEFAULT_REPLY1}
  631. "
  632. [ "$AUTO_RECONNECT1" != "" ] && USEREXTRA1="${USEREXTRA1}Auto Reconnect = ${AUTO_RECONNECT1}
  633. "
  634. [ "$IDLE_SECONDS1" != "" ] && USEREXTRA1="${USEREXTRA1}Idle Seconds = ${IDLE_SECONDS1}
  635. "
  636. USEREXTRA2="" #v3.99 bugfix...
  637. [ "$DIAL_PREFIX2" != "" ] && USEREXTRA2="${USEREXTRA2}Dial Prefix = ${DIAL_PREFIX2}
  638. "
  639. [ "$LOGIN_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Login Prompt = ${LOGIN_PROMPT2}
  640. "
  641. [ "$PASSWORD_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Password Prompt = ${PASSWORD_PROMPT2}
  642. "
  643. [ "$STUPID_MODE2" != "" ] && USEREXTRA2="${USEREXTRA2}Stupid Mode = ${STUPID_MODE2}
  644. "
  645. [ "$DEFAULT_REPLY2" != "" ] && USEREXTRA2="${USEREXTRA2}Default Reply = ${DEFAULT_REPLY2}
  646. "
  647. [ "$AUTO_RECONNECT2" != "" ] && USEREXTRA2="${USEREXTRA2}Auto Reconnect = ${AUTO_RECONNECT2}
  648. "
  649. [ "$IDLE_SECONDS2" != "" ] && USEREXTRA2="${USEREXTRA2}Idle Seconds = ${IDLE_SECONDS2}
  650. "
  651. [ "$CHECKCC" = "true" ] && CHECKCC="yes"
  652. [ "$CHECKCC" = "false" ] && CHECKCC="no"
  653. #v424 Retain original dial type, in case edited to DP.
  654. DIALSTR="AT"
  655. [ "$CHECKDT" = "true" -a "$CHECKBC" = "true" ] && DIALSTR="AT"
  656. [ "$CHECKDT" = "false" -a "$CHECKBC" = "true" ] && DIALSTR="ATX3"
  657. [ "$CHECKDT" = "false" -a "$CHECKBC" = "false" ] && DIALSTR="ATX1"
  658. [ "$CHECKDT" = "true" -a "$CHECKBC" = "false" ] && DIALSTR="ATX2"
  659. DIALSTR="${DIALSTR}${DIALTYPE}"
  660. [ "$DEVMALT" = "" ] && DEVMALTLINE="" || DEVMALTLINE="#Modem = /dev/${DEVMALT}
  661. "
  662. #120218 rerwin: Ensure non-null logon info for wvdial...
  663. [ ! ${ENTRYACC1USER} ] && ENTRYACC1USER="MYUSERNAME"
  664. [ ! ${ENTRYACC1PASS} ] && ENTRYACC1PASS="MYPASSWORD"
  665. [ ! ${ENTRYACC2USER} ] && ENTRYACC2USER="MY2USERNAME"
  666. [ ! ${ENTRYACC2PASS} ] && ENTRYACC2PASS="MY2PASSWORD"
  667. MODEMDEVM="/dev/${DEVM}" #120924
  668. [ "${DEVM}" = "MYDEVM" ] && MODEMDEVM="MYDEVM" #120924
  669. echo '[Dialer Defaults]' > /etc/wvdial.conf
  670. echo -n "Modem = ${MODEMDEVM}
  671. ${DEVMALTLINE}Baud = ${ENTRYBAUDM}
  672. Init1 =
  673. Init2 = ${ENTRYINIT2M}
  674. Init3 = ${ENTRYINIT3M}
  675. Carrier Check = ${CHECKCC}
  676. Dial Command = ${DIALSTR}
  677. [Dialer isp1]
  678. Phone = ${ENTRYACC1ISP}
  679. Username = ${ENTRYACC1USER}
  680. Password = ${ENTRYACC1PASS}
  681. ${USEREXTRA1}
  682. [Dialer isp1apn]
  683. Init5 = AT+CGDCONT=${ACC1PRFL},\"IP\",\"${ENTRYACC1APN}\"
  684. [Dialer isp2]
  685. Phone = ${ENTRYACC2ISP}
  686. Username = ${ENTRYACC2USER}
  687. Password = ${ENTRYACC2PASS}
  688. ${USEREXTRA2}
  689. [Dialer isp2apn]
  690. Init5 = AT+CGDCONT=${ACC2PRFL},\"IP\",\"${ENTRYACC2APN}\"
  691. [Dialer pin]
  692. Init1 = AT+CPIN=${ENTRYWPINM}
  693. [Dialer wireless]
  694. #$(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.")
  695. ${INIT4M}
  696. #$(gettext 'Init6-Init9 lines are available for user purposes; the commented examples can be used as described:')
  697. #$(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).')
  698. #$(gettext 'To list all the APNs stored in the modem, uncomment the Init8 line; check the Connection status log for lines beginning with +CGDCONT:.')
  699. #$(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:').
  700. ${INIT69M}" >> /etc/wvdial.conf
  701. [ "$EXIT" = "EXIT" ] && exit
  702. if [ "$EXIT" = "CONNECT1" -o "$EXIT" = "CONNECT2" ];then
  703. [ "$EXIT" = "CONNECT1" ] && WVISP="isp1" || WVISP="isp2"
  704. ln -snf $WVISP /var/local/pupdial/isp #v433 for stats
  705. #v3.98 put this in, now remove... v408 back in...
  706. #v3.98 something wrong with wvdial, it is supposed to automatically write
  707. #to /etc/ppp/chap-secrets and pap-secrets but isn't...
  708. if [ "$WVISP" = "isp1" ];then
  709. echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/chap-secrets
  710. echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/pap-secrets
  711. else
  712. echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/chap-secrets
  713. echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/pap-secrets
  714. fi
  715. #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.
  716. WVWRLS=""; WVPIN=""; WVAPN=""
  717. 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
  718. WVWRLS="wireless" #Include optional user-edited init strings
  719. if [ "$WVISP" = "isp1" ];then
  720. [ "$ENTRYACC1APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC1APN" #v431
  721. else
  722. [ "$ENTRYACC2APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC2APN" #v431
  723. fi
  724. if [ "$ENTRYWPINM" != "" ] && [ ! -e /tmp/.pupdial_pin_sent ];then
  725. WVPIN="pin"
  726. touch /tmp/.pupdial_pin_sent
  727. fi
  728. fi
  729. [ "$WVISP" = "isp1" ] \
  730. && ISPSTRING="$ENTRYACC1ISP" \
  731. || ISPSTRING="$ENTRYACC2ISP" #130505
  732. rm -f /tmp/pupdial.log
  733. #/etc/ppp/peers/wvdial and wvdial-pipe are part of wvdial pkg, but these files
  734. #conflict with Gkdial. Therefore, in the Unleashed wvdial pkg these files are
  735. #kept in /etc/ppp/ and moved into peers/ as needed...
  736. cp -f /etc/ppp/wvdial /etc/ppp/peers/
  737. #v433 Substitute bluetooth wvdial options...
  738. if which rfcomm >/dev/null && which hcitool >/dev/null \
  739. && [ "`echo "$DEVM" | grep '^rfcomm[0-9]'`" != "" ];then
  740. [ -f /etc/wvdial_options/BT-wvdial ] \
  741. && cp -f /etc/wvdial_options/BT-wvdial /etc/ppp/peers/wvdial
  742. BDADDR="`rfcomm show $DEVM | grep 'connected' | cut -f 2 -d > | cut -f 2 -d ' '`"
  743. if [ "$BDADDR" != "" ];then
  744. BDNAME="`hcitool name $BDADDR | tr -s ' ' | tr ' ' _ | tr / _ | tr '$' _`"
  745. if [ "$BDNAME" != "" ];then
  746. [ -f /etc/wvdial_options/BT-$BDNAME ] \
  747. && cp -f /etc/wvdial_options/BT-$BDNAME /etc/ppp/peers/wvdial \
  748. || cp -f /etc/ppp/peers/wvdial /etc/wvdial_options/BT-$BDNAME
  749. fi
  750. fi
  751. echo -e "pupdial BT: DEVM: $DEVM BDADDR: $BDADDR /peers/wvdial:\n`cat /etc/ppp/peers/wvdial`" >> /tmp/udevtrace-modem.log #DEBUG
  752. fi #433 end
  753. [ "${WVAPN}" != "" ] \
  754. && [ -f /etc/wvdial_options/APN-${APNSTRING} ] \
  755. && echo "`cat /etc/wvdial_options/APN-${APNSTRING}`" >> /etc/ppp/peers/wvdial #431
  756. [ -f /etc/ppp/wvdial-pipe ] \
  757. && cp -f /etc/ppp/wvdial-pipe /etc/ppp/peers/ #v3.98
  758. echo "$ISPSTRING" | sed 's/.*,//g' | grep -q '^[0-9\.\-]*$' \
  759. && touch /tmp/.network_tray-use_analog_dialup_icons #130505
  760. wvdial ${WVISP} ${WVPIN} ${WVAPN} ${WVWRLS} &> /tmp/pupdial.log & #v413
  761. [ ! -f /tmp/pupdial.log ] && sleep 1
  762. [ ! -f /tmp/pupdial.log ] && sleep 1
  763. /usr/sbin/pupdial_wizard_helper & #101206
  764. 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
  765. if [ $? -eq 0 ];then
  766. /usr/sbin/modemdisconnect #v433
  767. echo '' >> /tmp/pupdial.log
  768. echo '------------------------------------------------------' >> /tmp/pupdial.log
  769. echo '' >> /tmp/pupdial.log
  770. exec pupdial 2 #v3.91 go back to main window. 101218 pass param.
  771. fi
  772. fi
  773. ###END###