Advertisement
Guest User

Untitled

a guest
Jan 21st, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.72 KB | None | 0 0
  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.  
  24. KERNVER="`uname -r`"
  25.  
  26. #if no wvdial.conf, create a skeleton...
  27. MYDEVM="MYDEVM"
  28. [ -h /dev/modem ] && MYDEVM='/dev/'"`readlink /dev/modem`"
  29. #note, MYDEVM is placeholder for '/dev/ttyS0' whereas DEVM is just 'ttyS0'.
  30. #v408 rerwin...
  31.  
  32. if [ ! -s /etc/wvdial.conf ] || [ "`grep '/dev/MYDEVM' /etc/wvdial.conf`" != "" ];then #also replace empty file #v408
  33. if [ ! -s /etc/wvdial.conf ];then #v408
  34. echo "[Dialer Defaults]
  35. Modem = ${MYDEVM}
  36. Baud = 57600
  37. Init1 =
  38. Init2 = ATZ
  39. Init3 =
  40. Carrier Check = no
  41. Dial Command = ATDT
  42.  
  43. [Dialer isp1]
  44. Phone = MYISPPHONENUM
  45. Username = MYUSERNAME
  46. Password = MYPASSWORD
  47.  
  48. [Dialer isp1apn]
  49. Init5 = AT+CGDCONT=1,\"IP\",\"\"
  50.  
  51. [Dialer isp2]
  52. Phone = MY2ISPPHONENUM
  53. Username = MY2USERNAME
  54. Password = MY2PASSWORD
  55.  
  56. [Dialer isp2apn]
  57. Init5 = AT+CGDCONT=1,\"IP\",\"\"
  58.  
  59. [Dialer pin]
  60. Init1 = AT+CPIN=" > /etc/wvdial.conf
  61. #v408 Treat erased modem device name same as for absent wvdial.conf.
  62. else #wvdial.conf indicates modem field has been erased
  63. if [ "$MYDEVM" != "MYDEVM" ];then #modem detected; make config agree with /dev/modem.
  64. SEDSCRIPT="s%/dev/MYDEVM%$MYDEVM%"
  65. sed -i -e "$SEDSCRIPT" /etc/wvdial.conf
  66. fi
  67. fi
  68. #v408 end rerwin.
  69. if [ "$MYDEVM" != "MYDEVM" -a "$MYDEVM" != "modem" ];then
  70. Xdialog --left --wmclass "pupdial" --title "PupDial: modem string" --no-cancel --yesno "It seems that you have a modem, at port ${MYDEVM}\n
  71. However, for the modem to work properly, you may need to supply an initialization\n
  72. string. There are two of these. The first one is already setup as 'ATZ' which just\n
  73. resets the modem. For many modems that is all that is needed, and you can just\n
  74. click the 'No' button as no further probing is required.\n
  75. However some modems need a bit more. If you click the 'Yes' button (recommended)\n
  76. then the modem will be probed to determine a required second initialization string.\n
  77. This probe will timeout after 29 seconds, which may have meant that the probe\n
  78. failed, in which case the second string will be set to nothing.\n
  79. Note that you can manually enter something into the second-string box in PupDial\n
  80. (the User Manual for the modem may have a recommended string).\n
  81. \n
  82. Recommend click 'Yes', afterward PupDial will start..." 0 0
  83. RETVAL=$?
  84. DEVM="`echo -n "$MYDEVM" | cut -f 3,4 -d '/'`"
  85. [ $RETVAL -eq 0 ] && modemtest $DEVM initonly
  86. fi
  87. fi
  88.  
  89. #v413 Assure user...
  90. yaf-splash -font "8x16" -outline 0 -margin 4 -bg orange -text "Reading modem configuration file..." &
  91. X1PID=$!
  92.  
  93. #disconnect button...
  94. STATECONb="disabled"
  95. #v409 rerwin, bugfix...
  96. #[ "`pidof pppd`" != "" ] && STATECONb="enabled"
  97. if [ "`pidof pppd`" != "" ];then #v409
  98. [ ! -f /etc/ppp/peers/wvdial ] && sleep 1 #v409 allow kill completion and repeat test. v412 0.3 to 1.
  99. [ "`pidof pppd`" != "" ] && STATECONb="enabled"
  100. fi #v409
  101.  
  102. MSG1="WARNING! No modem detected! You cannot dialout!"
  103. STATECONa="disabled"
  104. STATETEST="disabled" #101117
  105. STATECCM="yes"
  106. STATEDTM="yes"
  107. STATEBCM="yes"
  108. TESTMSG="MODEM"
  109.  
  110. #precaution...
  111. cat /etc/wvdial.conf | tr '\t' ' ' | tr -s ' ' > /tmp/wvdial.conf
  112. sync
  113. #Rerwin: v4.05 Substitute /dev/modem target for /dev/modem
  114. if [ "`grep '/dev/modem' /tmp/wvdial.conf`" != "" -a -h /dev/modem ];then #modem = /dev/modem & it exists
  115. SEDSCRIPT="s%/dev/modem%/dev/`readlink /dev/modem`%g"
  116. sed -i -e "$SEDSCRIPT" /tmp/wvdial.conf #replace device in-place
  117. fi
  118. mv -f /tmp/wvdial.conf /etc/wvdial.conf
  119. sync #v413 ensure config updated
  120.  
  121. ISPM="`cat /etc/wvdial.conf | grep '^Phone = ' | head -n 2`"
  122. ACC1ISP="`echo "$ISPM" | head -n 1 | cut -f 3-6 -d ' '`"
  123. ACC2ISP="`echo "$ISPM" | tail -n 1 | cut -f 3-6 -d ' '`"
  124. USERM="`cat /etc/wvdial.conf | grep '^Username = ' | head -n 2`"
  125. ACC1USER="`echo "$USERM" | head -n 1 | cut -f 3 -d ' '`"
  126. ACC2USER="`echo "$USERM" | tail -n 1 | cut -f 3 -d ' '`"
  127. PASSM="`cat /etc/wvdial.conf | grep '^Password = ' | head -n 2`"
  128. ACC1PASS="`echo "$PASSM" | head -n 1 | cut -f 3 -d ' '`"
  129. ACC2PASS="`echo "$PASSM" | tail -n 1 | cut -f 3 -d ' '`"
  130. INIT5M="`cat /etc/wvdial.conf | grep '^Init5 = AT+CGDCONT=' | head -n 2`"
  131. [ "`grep '\[Dialer isp2apn\]' /etc/wvdial.conf`" = "" ] && INIT5M="`echo -e "$INIT5M\n"`"
  132. ACC1PRFL="`echo "$INIT5M" | head -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
  133. ACC2PRFL="`echo "$INIT5M" | tail -n 1 | cut -f 3 -d '=' | cut -f 1 -d ','`"
  134. ACC1APN="`echo "$INIT5M" | head -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
  135. ACC2APN="`echo "$INIT5M" | tail -n 1 | cut -f 4 -d '\"' | sed 's/\\$/\\\\$/g;'`"
  136. [ "$ACC1PRFL" = "" ] && ACC1PRFL="1"; [ "$ACC2PRFL" = "" ] && ACC2PRFL="1"
  137.  
  138. #1st 'cut' fixes if the '/dev/' left off the device name...
  139. #note, initialised wvdial.conf has 'Modem = MYDEVM' where MYDEVM needs to become
  140. # '/dev/ttyS0' (for example)
  141. DEVM="`cat /etc/wvdial.conf | grep '^Modem = ' | cut -f 3 -d ' ' | cut -f 3 -d '/'`"
  142. DEVMALT="`cat /etc/wvdial.conf | grep '^#Modem = ' | tail -n 1 | cut -f 3 -d ' ' | cut -f 3 -d '/'`" #v432
  143. [ "$DEVM" = "" ] && DEVM='MYDEVM' #v4.00 bugfix, crashed if no DEVM.
  144. [ ! -f /tmp/pupdial.log ] && touch /tmp/pupdial.log #v408 rerwin, moved up.
  145. if [ "${DEVM}" != "MYDEVM" ];then
  146. [ -f /tmp/.pupdial-modem_detected ] \
  147. && rm -f /tmp/.pupdial-modem_detected \
  148. && MSG1="Modem detected! Device interface: /dev/$DEVM" \
  149. || MSG1="Selected modem device interface: /dev/$DEVM" #v433
  150. #101117 Protect HSF/HCF connections from lockup - ensure nvm files installed.
  151. [ "`pidof pppd`" = "" ] \
  152. && STATETEST="enabled" \
  153. && [ "`echo "${DEVM}" | grep 'ttySHSF[0-9]'`" = "" -o -d /etc/hsfmodem/nvm ] \
  154. && [ "`echo "${DEVM}" | grep 'ttySHCF[0-9]'`" = "" -o -d /etc/hcfpcimodem/nvm ] \
  155. && STATECONa="enabled" #dialout button.
  156. [ "$DEVMALT" = "" ] \
  157. && TESTMSG="$DEVM" \
  158. || TESTMSG="$DEVMALT" #v433
  159. TESTDEVM="$TESTMSG" #v432
  160. #[ ! -f /tmp/pupdial.log ] && touch /tmp/pupdial.log
  161. [ "`grep 'MODEM WAS NOT AUTOMATICALLY DETECTED' /tmp/pupdial.log`" != "" ] && echo -n "" > /tmp/pupdial.log
  162. if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
  163. echo "Welcome to PupDial, originally written by Barry Kauler and
  164. enhanced by Richard Erwin for Puppy Linux.
  165.  
  166. There is a configuration file, /etc/wvdial.conf, that is read by
  167. PupDial, and changes made to any of the above boxes will be saved
  168. to wvdial.conf when you click the 'Exit' or 'Connect' buttons.
  169. Note, you can also manually edit wvdial.conf with a text editor.
  170.  
  171. Some computers have two modems, perhaps one on the motherboard,
  172. and Puppy may have detected the wrong one. In that case, click the
  173. 'probe' button. If it is still wrong, manually edit wvdial.conf." >> /tmp/pupdial.log
  174. fi
  175. else
  176. if [ "`grep 'Barry Kauler' /tmp/pupdial.log`" = "" ];then
  177. echo "Welcome to PupDial, originally written by Barry Kauler and
  178. enhanced by Richard Erwin for Puppy Linux.
  179.  
  180. A MODEM WAS NOT AUTOMATICALLY DETECTED, SO YOU
  181. NEED TO CLICK THE 'CHOOSE' BUTTON. DO THIS NOW!
  182. " > /tmp/pupdial.log
  183. fi
  184. fi
  185.  
  186. BAUDM="`cat /etc/wvdial.conf | grep '^Baud = ' | cut -f 3 -d ' '`"
  187.  
  188. #v4.00 HairyWill fixes for embedded $ " characters...
  189. 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
  190. INIT2M="`cat /etc/wvdial.conf | grep '^Init2 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`"
  191. INIT3M="`cat /etc/wvdial.conf | grep '^Init3 = ' | cut -f 3-12 -d ' '| sed 's/"/\\\\"/g;s/\\$/\\\\$/g;'`" #v413
  192. #v413 If first Init1 not null, move contents to Init2, and Init2 to Init3, to reserve Init1 for wireless PIN.
  193. [ "$INIT1M" != "" ] && INIT3M="$INIT2M" && INIT2M="$INIT1M" && INIT1M="" #v413
  194. #v413 Get values for Init1, 4, 6-9.
  195. WPINM="`cat /etc/wvdial.conf | grep '^Init1 = ' | tail -n 1 | cut -f 3 -d '='`"
  196. INIT4M="`cat /etc/wvdial.conf | grep '^#*Init4 =' | sed 's/"/\\"/g;;s/\$/\\$/g;s/$$//g;'`"
  197. [ "$INIT4M" = "" ] && INIT4M="#Init4 = AT+COPS=0,0,\"MYOPS\","
  198. INIT69M="`cat /etc/wvdial.conf | grep '^#*Init[6-9] =' | sed -e 's/"/\\"/g' -e 's/\$/\\$/g' -e 's/$$//'`"
  199. [ "$INIT69M" = "" ] && INIT69M="#Init6 = AT+CGEQMIN=1,4,64,384,64,384
  200. #Init7 = AT+CGEQREQ=1,4,64,384,64,384
  201. #Init8 = AT+CGDCONT?
  202. #Init9 = AT+COPS?"
  203. #v413 end
  204.  
  205. DIALM="`cat /etc/wvdial.conf | grep '^Dial Command = ' | cut -f 4 -d ' '`"
  206. [ "`echo "$DIALM" | grep -E 'X3|X1'`" != "" ] && STATEDTM="no"
  207. [ "`echo "$DIALM" | grep -E 'X2|X1'`" != "" ] && STATEBCM="no"
  208. CCM="`cat /etc/wvdial.conf | grep '^Carrier Check = ' | cut -f 4 -d ' '`"
  209. [ "$CCM" = "no" ] && STATECCM="no"
  210. [ "`echo "$DIALM" | grep 'DP'`" = "" ] && DIALTYPE="DT" || DIALTYPE="DP" #v424
  211.  
  212. #v3.99 there may be up to two of each of the above...
  213. ISPCNT=0 #v431
  214. echo -n "" > /tmp/pupdial_read
  215. cat /etc/wvdial.conf |
  216. while read ONELINE
  217. do
  218. ONELINE="`echo -n "$ONELINE" | tr '\t' ' ' | tr -s ' '`" #in case user puts in extra tabs and spaces.
  219. [ "$ONELINE" = "" -o "$ONELINE" = " " ] && continue
  220. #v431 begin
  221. case $ONELINE in
  222. "[Dialer isp1]") ISPCNT=1 ;;
  223. "[Dialer isp1apn]") ISPCNT=0 ;;
  224. "[Dialer isp2]") ISPCNT=2 ;;
  225. "[Dialer isp2apn]") ISPCNT=0 ;;
  226. esac
  227. [ $ISPCNT -eq 0 ] && continue
  228. #v431 end
  229. ONEPARAM="`echo -n "$ONELINE" | cut -f 1 -d '=' | sed -e 's/ $//'`"
  230. ONEVALUE="`echo -n "$ONELINE" | cut -f 2 -d '=' | sed -e 's/^ //'`"
  231. if [ "$ONEVALUE" != "" ];then
  232. case $ONEPARAM in
  233. "Dial Prefix") echo "DIAL_PREFIX${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  234. "Login Prompt") echo "LOGIN_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  235. "Password Prompt") echo "PASSWORD_PROMPT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  236. "Stupid Mode") echo "STUPID_MODE${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  237. "Default Reply") echo "DEFAULT_REPLY${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  238. "Auto Reconnect") echo "AUTO_RECONNECT${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;;
  239. "Idle Seconds") echo "IDLE_SECONDS${ISPCNT}='${ONEVALUE}'" >> /tmp/pupdial_read ;; #v431
  240. esac
  241. fi
  242. done
  243. eval "`cat /tmp/pupdial_read`"
  244.  
  245. #v3.99
  246. ynSTUPID_MODE1=no
  247. [ "$STUPID_MODE1" = "1" -o "$STUPID_MODE1" = "yes" ] && ynSTUPID_MODE1=yes
  248. ynSTUPID_MODE2=no
  249. [ "$STUPID_MODE2" = "1" -o "$STUPID_MODE2" = "yes" ] && ynSTUPID_MODE2=yes
  250. ynAUTO_RECONNECT1=yes #default is on.
  251. [ "$AUTO_RECONNECT1" = "1" -o "$AUTO_RECONNECT1" = "yes" ] && ynAUTO_RECONNECT1=yes
  252. [ "$AUTO_RECONNECT1" = "0" -o "$AUTO_RECONNECT1" = "no" ] && ynAUTO_RECONNECT1=no
  253. ynAUTO_RECONNECT2=yes #default is on.
  254. [ "$AUTO_RECONNECT2" = "1" -o "$AUTO_RECONNECT2" = "yes" ] && ynAUTO_RECONNECT2=yes
  255. [ "$AUTO_RECONNECT2" = "0" -o "$AUTO_RECONNECT2" = "no" ] && ynAUTO_RECONNECT2=no
  256.  
  257. #v4.00 HairyWill, replaced lines (see below), fix for quotes in string...
  258. #< <default>\"${INIT2M}\"</default>
  259. #> <input>echo \"${INIT2M}\"</input>
  260. #< <default>\"${INIT3M}\"</default>
  261. #> <input>echo \"${INIT3M}\"</input>
  262.  
  263. MODEMINFO="
  264. <hbox>
  265. <frame Line status>
  266. <vbox>
  267. <checkbox>
  268. <label>Carrier check</label>
  269. <variable>CHECKCC</variable>
  270. <default>${STATECCM}</default>
  271. </checkbox>
  272. <checkbox>
  273. <label>Dialtone check</label>
  274. <variable>CHECKDT</variable>
  275. <default>${STATEDTM}</default>
  276. </checkbox>
  277. <checkbox>
  278. <label>Busy check</label>
  279. <variable>CHECKBC</variable>
  280. <default>${STATEBCM}</default>
  281. </checkbox>
  282. </vbox>
  283. </frame>
  284. <vbox>
  285. <hbox>
  286. <text><label>Initialisation string 2:</label></text>
  287. <entry>
  288. <input>echo \"${INIT2M}\"</input>
  289. <variable>ENTRYINIT2M</variable>
  290. </entry>
  291. </hbox>
  292. <hbox>
  293. <text><label>Initialisation string 3:</label></text>
  294. <entry>
  295. <input>echo \"${INIT3M}\"</input>
  296. <variable>ENTRYINIT3M</variable>
  297. </entry>
  298. </hbox>
  299. <hbox>
  300. <text><label>Max speed:</label></text>
  301. <entry>
  302. <default>\"${BAUDM}\"</default>
  303. <variable>ENTRYBAUDM</variable>
  304. </entry>
  305. <text><label>SIM PIN:</label></text>
  306. <entry invisible_char=\"x\" visibility=\"false\">
  307. <input>echo \"${WPINM}\"</input>
  308. <variable>ENTRYWPINM</variable>
  309. </entry>
  310. </hbox>
  311. </vbox>
  312. <frame Test/Select>
  313. <vbox>
  314. <button>
  315. <label>${TESTMSG}</label>
  316. <visible>${STATETEST}</visible>
  317. <action>/usr/sbin/modemtest ${TESTDEVM}</action>
  318. <action type=\"exit\">reload</action>
  319. </button>
  320. <button>
  321. <label>CHOOSE</label>
  322. <action>/usr/sbin/modemprobe</action>
  323. <action>cat /tmp/logwvdialprobe > /tmp/pupdial.log 2> /dev/null</action>
  324. <action type=\"exit\">reload</action>
  325. </button>
  326. </vbox>
  327. </frame>
  328. </hbox>
  329. "
  330.  
  331.  
  332. export MAINDIALOG="
  333. <window title=\"PupDial modem Internet dialer\" icon-name=\"gtk-connect\">
  334. <vbox>
  335. <frame Modem setup>
  336. <text use-markup=\"true\"><label>\"<b>$MSG1</b>\"</label></text>
  337. ${MODEMINFO}
  338. </frame>
  339. <hbox>
  340. <frame Account 1>
  341. <vbox>
  342. <hbox>
  343. <text><label>Phone/Access number:</label></text>
  344. <entry>
  345. <default>\"${ACC1ISP}\"</default>
  346. <variable>ENTRYACC1ISP</variable>
  347. </entry>
  348. </hbox>
  349. <hbox>
  350. <text><label>Username:</label></text>
  351. <entry>
  352. <default>\"${ACC1USER}\"</default>
  353. <variable>ENTRYACC1USER</variable>
  354. </entry>
  355. </hbox>
  356. <hbox>
  357. <text><label>Password:</label></text>
  358. <entry invisible_char=\"x\" visibility=\"false\">
  359. <default>\"${ACC1PASS}\"</default>
  360. <variable>ENTRYACC1PASS</variable>
  361. </entry>
  362. </hbox>
  363. <hbox>
  364. <text><label>Wireless APN:</label></text>
  365. <entry>
  366. <default>\"${ACC1APN}\"</default>
  367. <variable>ENTRYACC1APN</variable>
  368. </entry>
  369. </hbox>
  370.  
  371. <hbox>
  372. <checkbox>
  373. <label>Stupid mode</label>
  374. <variable>ynSTUPID_MODE1</variable>
  375. <default>${ynSTUPID_MODE1}</default>
  376. </checkbox>
  377. <text><label>\" \"</label></text>
  378. <checkbox>
  379. <label>Auto Reconnect</label>
  380. <variable>ynAUTO_RECONNECT1</variable>
  381. <default>${ynAUTO_RECONNECT1}</default>
  382. </checkbox>
  383. <text><label>\" \"</label></text>
  384. <button>
  385. <label>CONNECT</label>
  386. <visible>${STATECONa}</visible>
  387. <action type=\"exit\">CONNECT1</action>
  388. </button>
  389. </hbox>
  390.  
  391. </vbox>
  392. </frame>
  393. <frame Account 2>
  394. <vbox>
  395. <hbox>
  396. <text><label>Phone/Access number:</label></text>
  397. <entry>
  398. <default>\"${ACC2ISP}\"</default>
  399. <variable>ENTRYACC2ISP</variable>
  400. </entry>
  401. </hbox>
  402. <hbox>
  403. <text><label>Username:</label></text>
  404. <entry>
  405. <default>\"${ACC2USER}\"</default>
  406. <variable>ENTRYACC2USER</variable>
  407. </entry>
  408. </hbox>
  409. <hbox>
  410. <text><label>Password:</label></text>
  411. <entry invisible_char=\"x\" visibility=\"false\">
  412. <default>\"${ACC2PASS}\"</default>
  413. <variable>ENTRYACC2PASS</variable>
  414. </entry>
  415. </hbox>
  416. <hbox>
  417. <text><label>Wireless APN:</label></text>
  418. <entry>
  419. <default>\"${ACC2APN}\"</default>
  420. <variable>ENTRYACC2APN</variable>
  421. </entry>
  422. </hbox>
  423.  
  424. <hbox>
  425. <checkbox>
  426. <label>Stupid mode</label>
  427. <variable>ynSTUPID_MODE2</variable>
  428. <default>${ynSTUPID_MODE2}</default>
  429. </checkbox>
  430. <text><label>\" \"</label></text>
  431. <checkbox>
  432. <label>Auto Reconnect</label>
  433. <variable>ynAUTO_RECONNECT2</variable>
  434. <default>${ynAUTO_RECONNECT2}</default>
  435. </checkbox>
  436. <text><label>\" \"</label></text>
  437. <button>
  438. <label>CONNECT</label>
  439. <visible>${STATECONa}</visible>
  440. <action type=\"exit\">CONNECT2</action>
  441. </button>
  442. </hbox>
  443.  
  444. </vbox>
  445. </frame>
  446. </hbox>
  447.  
  448. <frame>
  449. <hbox>
  450. <button>
  451. <label>HELP on WvDial executable</label>
  452. <action>Xdialog --wmclass \"pupdial\" --title \"WvDial documentation\" --no-cancel --fixed-font --textbox /usr/share/doc/wvdial/wvdial.txt 0 0 &</action>
  453. </button>
  454. <button>
  455. <label>HELP on WvDial config file</label>
  456. <action>Xdialog --wmclass \"pupdial\" --title \"WvDial documentation\" --no-cancel --fixed-font --textbox /usr/share/doc/wvdial/wvdial.conf.txt 0 0 &</action>
  457. </button>
  458. <text><label>\" \"</label></text>
  459. <button>
  460. <label>DISCONNECT from Internet</label>
  461. <visible>${STATECONb}</visible>
  462. <action>/usr/sbin/modemdisconnect</action>
  463. <action>rm -f /tmp/pupdial.log</action>
  464. <action type=\"exit\">EXIT</action>
  465. </button>
  466. <text><label>\" \"</label></text>
  467. <button>
  468. <label>EXIT</label>
  469. <action type=\"exit\">EXIT</action>
  470. </button>
  471. </hbox>
  472. </frame>
  473.  
  474. <frame Connection status log>
  475. <edit editable=\"false\">
  476. <variable>INFO</variable>
  477. <input file>/tmp/pupdial.log</input>
  478. <width>600</width>
  479. <height>170</height>
  480. </edit>
  481. </frame>
  482.  
  483. </vbox>
  484. </window>
  485. "
  486.  
  487. # <action>wvdial &> /tmp/pupdial.log &</action>
  488. # <action>sleep 2</action>
  489. # <action>tail /tmp/pupdial.log > /tmp/pupdial.log.tail</action>
  490. # <action type=\"refresh\">INFO</action>
  491.  
  492. #mono text for log box...
  493. echo 'style "specialmono"
  494. {
  495. font_name="Mono 12"
  496. }
  497.  
  498. class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono
  499. export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0
  500.  
  501. kill $X1PID #v413
  502.  
  503.  
  504.  
  505. #RETSTRING="`echo "$MAINDIALOG" | gtkdialog3 --stdin`"
  506. RETSTRING="`gtkdialog3 --program=MAINDIALOG`"
  507.  
  508. #v4.00 to handle embedded quote, extract ENTRYINIT2M and ENTRYINIT3M separately...
  509. ENTRYINIT2M="`echo "$RETSTRING" | grep '^ENTRYINIT2M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
  510. ENTRYINIT3M="`echo "$RETSTRING" | grep '^ENTRYINIT3M=' | cut -f 2-9 -d '"' | sed -e 's/"$//'`" #'geany
  511. ENTRYWPINM="`echo "$RETSTRING" | grep '^ENTRYWPINM=' | cut -f 2-9 -d '"' | sed -e 's/"$//' | tr -d ' '`" #no spaces
  512. RETSTRING="`echo "$RETSTRING" | grep -v '^ENTRYINIT3M=' | grep -v '^ENTRYINIT2M=' | grep -v '^ENTRYWPINM='`"
  513.  
  514. #v405 getting some weird stuff on stdout from gtkdialog3, fix...
  515. #all lines must have format variable="value"... v406 add '_'...
  516. xRETSTRING="`echo "$RETSTRING" | grep -E '^[a-zA-Z0-9_]+=\".*\"$'`" # | grep -v '^INFO='
  517.  
  518. eval "$xRETSTRING"
  519.  
  520. [ ! -f /etc/wvdial.conf ] && exit
  521. if [ "$EXIT" = "abort" -o "$EXIT" = "" ];then
  522. rm -f /tmp/pupdial.log #v3.91
  523. exit
  524. fi
  525.  
  526. [ "$EXIT" = "reload" ] && exec pupdial
  527.  
  528. rm -f /tmp/pupdial.log #v3.91
  529.  
  530. #v3.99
  531. STUPID_MODE1=""
  532. STUPID_MODE2=""
  533. [ "$ynSTUPID_MODE1" = "true" ] && STUPID_MODE1="yes"
  534. [ "$ynSTUPID_MODE2" = "true" ] && STUPID_MODE2="yes"
  535. [ "$ynAUTO_RECONNECT1" = "true" ] && AUTO_RECONNECT1=yes
  536. [ "$ynAUTO_RECONNECT1" = "false" ] && AUTO_RECONNECT1=no
  537. [ "$ynAUTO_RECONNECT2" = "true" ] && AUTO_RECONNECT2=yes
  538. [ "$ynAUTO_RECONNECT2" = "false" ] && AUTO_RECONNECT2=no
  539.  
  540. USEREXTRA1="" #v3.99 bug fix...
  541. [ "$DIAL_PREFIX1" != "" ] && USEREXTRA1="${USEREXTRA1}Dial Prefix = ${DIAL_PREFIX1}
  542. "
  543. [ "$LOGIN_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Login Prompt = ${LOGIN_PROMPT1}
  544. "
  545. [ "$PASSWORD_PROMPT1" != "" ] && USEREXTRA1="${USEREXTRA1}Password Prompt = ${PASSWORD_PROMPT1}
  546. "
  547. [ "$STUPID_MODE1" != "" ] && USEREXTRA1="${USEREXTRA1}Stupid Mode = ${STUPID_MODE1}
  548. "
  549. [ "$DEFAULT_REPLY1" != "" ] && USEREXTRA1="${USEREXTRA1}Default Reply = ${DEFAULT_REPLY1}
  550. "
  551. [ "$AUTO_RECONNECT1" != "" ] && USEREXTRA1="${USEREXTRA1}Auto Reconnect = ${AUTO_RECONNECT1}
  552. "
  553. [ "$IDLE_SECONDS1" != "" ] && USEREXTRA1="${USEREXTRA1}Idle Seconds = ${IDLE_SECONDS1}
  554. "
  555.  
  556. USEREXTRA2="" #v3.99 bugfix...
  557. [ "$DIAL_PREFIX2" != "" ] && USEREXTRA2="${USEREXTRA2}Dial Prefix = ${DIAL_PREFIX2}
  558. "
  559. [ "$LOGIN_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Login Prompt = ${LOGIN_PROMPT2}
  560. "
  561. [ "$PASSWORD_PROMPT2" != "" ] && USEREXTRA2="${USEREXTRA2}Password Prompt = ${PASSWORD_PROMPT2}
  562. "
  563. [ "$STUPID_MODE2" != "" ] && USEREXTRA2="${USEREXTRA2}Stupid Mode = ${STUPID_MODE2}
  564. "
  565. [ "$DEFAULT_REPLY2" != "" ] && USEREXTRA2="${USEREXTRA2}Default Reply = ${DEFAULT_REPLY2}
  566. "
  567. [ "$AUTO_RECONNECT2" != "" ] && USEREXTRA2="${USEREXTRA2}Auto Reconnect = ${AUTO_RECONNECT2}
  568. "
  569. [ "$IDLE_SECONDS2" != "" ] && USEREXTRA2="${USEREXTRA2}Idle Seconds = ${IDLE_SECONDS2}
  570. "
  571.  
  572. [ "$CHECKCC" = "true" ] && CHECKCC="yes"
  573. [ "$CHECKCC" = "false" ] && CHECKCC="no"
  574. #v424 Retain original dial type, in case edited to DP.
  575. DIALSTR="AT"
  576. [ "$CHECKDT" = "true" -a "$CHECKBC" = "true" ] && DIALSTR="AT"
  577. [ "$CHECKDT" = "false" -a "$CHECKBC" = "true" ] && DIALSTR="ATX3"
  578. [ "$CHECKDT" = "false" -a "$CHECKBC" = "false" ] && DIALSTR="ATX1"
  579. [ "$CHECKDT" = "true" -a "$CHECKBC" = "false" ] && DIALSTR="ATX2"
  580. DIALSTR="${DIALSTR}${DIALTYPE}"
  581. [ "$DEVMALT" = "" ] && DEVMALTLINE="" || DEVMALTLINE="#Modem = /dev/${DEVMALT}
  582. "
  583.  
  584. echo '[Dialer Defaults]' > /etc/wvdial.conf
  585. echo -n "Modem = /dev/${DEVM}
  586. ${DEVMALTLINE}Baud = ${ENTRYBAUDM}
  587. Init1 =
  588. Init2 = ${ENTRYINIT2M}
  589. Init3 = ${ENTRYINIT3M}
  590. Carrier Check = ${CHECKCC}
  591. Dial Command = ${DIALSTR}
  592.  
  593. [Dialer isp1]
  594. Phone = ${ENTRYACC1ISP}
  595. Username = ${ENTRYACC1USER}
  596. Password = ${ENTRYACC1PASS}
  597. ${USEREXTRA1}
  598. [Dialer isp1apn]
  599. Init5 = AT+CGDCONT=${ACC1PRFL},\"IP\",\"${ENTRYACC1APN}\"
  600.  
  601. [Dialer isp2]
  602. Phone = ${ENTRYACC2ISP}
  603. Username = ${ENTRYACC2USER}
  604. Password = ${ENTRYACC2PASS}
  605. ${USEREXTRA2}
  606. [Dialer isp2apn]
  607. Init5 = AT+CGDCONT=${ACC2PRFL},\"IP\",\"${ENTRYACC2APN}\"
  608.  
  609. [Dialer pin]
  610. Init1 = AT+CPIN=${ENTRYWPINM}
  611.  
  612. [Dialer wireless]
  613. #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.
  614. ${INIT4M}
  615. #Init6-Init9 lines are available for user purposes; the commented examples can be used as described:
  616. #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).
  617. #To list all the APNs stored in the modem, uncomment the Init8 line; check the Connection status log for lines beginning with +CGDCONT:.
  618. #To list the operator identifier stored in the modem, uncomment the Init9 line; check the Connection status log for a line beginning with +COPS:.
  619. ${INIT69M}" >> /etc/wvdial.conf
  620.  
  621. [ "$EXIT" = "EXIT" ] && exit
  622.  
  623. if [ "$EXIT" = "CONNECT1" -o "$EXIT" = "CONNECT2" ];then
  624. [ "$EXIT" = "CONNECT1" ] && WVISP="isp1" || WVISP="isp2"
  625. ln -snf $WVISP /var/local/pupdial/isp #v433 for stats
  626.  
  627. #v3.98 put this in, now remove... v408 back in...
  628. #v3.98 something wrong with wvdial, it is supposed to automatically write
  629. #to /etc/ppp/chap-secrets and pap-secrets but isn't...
  630. if [ "$WVISP" = "isp1" ];then
  631. echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/chap-secrets
  632. echo -e "${ENTRYACC1USER}\t*\t${ENTRYACC1PASS}" > /etc/ppp/pap-secrets
  633. else
  634. echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/chap-secrets
  635. echo -e "${ENTRYACC2USER}\t*\t${ENTRYACC2PASS}" > /etc/ppp/pap-secrets
  636. fi
  637. #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.
  638. WVWRLS=""; WVPIN=""; WVAPN=""
  639. 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
  640. WVWRLS="wireless" #Include optional user-edited init strings
  641. if [ "$WVISP" = "isp1" ];then
  642. [ "$ENTRYACC1APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC1APN" #v431
  643. else
  644. [ "$ENTRYACC2APN" != "" ] && WVAPN="${WVISP}apn" && APNSTRING="$ENTRYACC2APN" #v431
  645. fi
  646. if [ "$ENTRYWPINM" != "" ] && [ ! -e /tmp/.pupdial_pin_sent ];then
  647. WVPIN="pin"
  648. touch /tmp/.pupdial_pin_sent
  649. fi
  650. fi
  651. rm -f /tmp/pupdial.log
  652.  
  653. #v3.98 put this in, now remove...
  654. #v3.98 /etc/ppp/options can cause conflict for wvdial.
  655. #(i think 'options' is used by roaring penguin) hide it...
  656. # mv -f /etc/ppp/options /etc/ppp/optionsHIDE
  657.  
  658. #/etc/ppp/peers/wvdial and wvdial-pipe are part of wvdial pkg, but these files
  659. #conflict with Gkdial. Therefore, in the Unleashed wvdial pkg these files are
  660. #kept in /etc/ppp/ and moved into peers/ as needed...
  661. cp -f /etc/ppp/wvdial /etc/ppp/peers/
  662. #v433 Substitute bluetooth wvdial options...
  663. if which rfcomm >/dev/null && which hcitool >/dev/null \
  664. && [ "`echo "$DEVM" | grep '^rfcomm[0-9]'`" != "" ];then
  665. [ -f /etc/wvdial_options/BT-wvdial ] \
  666. && cp -f /etc/wvdial_options/BT-wvdial /etc/ppp/peers/wvdial
  667. BDADDR="`rfcomm show $DEVM | grep 'connected' | cut -f 2 -d > | cut -f 2 -d ' '`"
  668. if [ "$BDADDR" != "" ];then
  669. BDNAME="`hcitool name $BDADDR | tr -s ' ' | tr ' ' _ | tr / _ | tr '$' _`"
  670. if [ "$BDNAME" != "" ];then
  671. [ -f /etc/wvdial_options/BT-$BDNAME ] \
  672. && cp -f /etc/wvdial_options/BT-$BDNAME /etc/ppp/peers/wvdial \
  673. || cp -f /etc/ppp/peers/wvdial /etc/wvdial_options/BT-$BDNAME
  674. fi
  675. fi
  676. echo -e "pupdial BT: DEVM: $DEVM BDADDR: $BDADDR /peers/wvdial:\n`cat /etc/ppp/peers/wvdial`" >> /tmp/udevtrace-modem.log #DEBUG
  677. fi #433 end
  678. [ "${WVAPN}" != "" ] \
  679. && [ -f /etc/wvdial_options/APN-${APNSTRING} ] \
  680. && echo "`cat /etc/wvdial_options/APN-${APNSTRING}`" >> /etc/ppp/peers/wvdial #431
  681. [ -f /etc/ppp/wvdial-pipe ] \
  682. && cp -f /etc/ppp/wvdial-pipe /etc/ppp/peers/ #v3.98
  683. wvdial ${WVISP} ${WVPIN} ${WVAPN} ${WVWRLS} &> /tmp/pupdial.log & #v413
  684. [ ! -f /tmp/pupdial.log ] && sleep 1
  685. [ ! -f /tmp/pupdial.log ] && sleep 1
  686. 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
  687. if [ $? -eq 0 ];then
  688. /usr/sbin/modemdisconnect #v433
  689. echo '' >> /tmp/pupdial.log
  690. echo '------------------------------------------------------' >> /tmp/pupdial.log
  691. echo '' >> /tmp/pupdial.log
  692. exec pupdial #v3.91 go back to main window.
  693. fi
  694. fi
  695.  
  696. ###END###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement