connectwizard 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. #!/bin/sh
  2. #Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  3. #Barry Kauler www.puppylinux.com
  4. #Updated for Puppy 4.00, April 2008.
  5. #v405 july 2008 updated.
  6. #v409 add both Pppoeconf and Roaring Penguin PPPOE to menus.
  7. #v411 remove pppoeconf buttons from gui if pkg not installed.
  8. #v411 anythng on commandline suppresses default-connect gui (see wizardwizard).
  9. #v423 menu modification, cater to dialup wireless modem.
  10. #091218 button for ipinfo.
  11. #100227 overhaul, added Pwireless2, Network Wizards (old and new).
  12. #100310 added Simple Network Setup tool.
  13. #100412 sns related bug fix.
  14. #v433 rerwin: Add message for previously selected modem not present.
  15. #100902 new pupdial_wizard_helper script.
  16. #101002 rerwin: Wait for initialization scripts to complete. 101122 breakout.
  17. #101206 pupdial_wizard_helper now called from pupdial.
  18. #111022 added hostname-set button.
  19. #111028 put hostname entry box directly in this wizard. internationalised.
  20. #111106 do not use $HOSTNAME, as hostname-set may have just been run.
  21. #120201 one gettext translation added.
  22. #120823 rerwin: add frisbee.
  23. #120823 rerwin: get correct pid in wait loop.
  24. #121112 rerwin: change indicator of frisbee.
  25. #130111 rerwin: change name of frisbee invocation for integrated version, add disable when appropriate.
  26. #131214 zigbert: gui (gtkdialog) improvements.
  27. export TEXTDOMAIN=connectwizard
  28. export OUTPUT_CHARSET=UTF-8
  29. firewall_func() {
  30. which firewall_ng 2>&1 >/dev/null
  31. ret=$?
  32. if [ $ret -eq 0 ];then
  33. firewall_ng &
  34. else
  35. rxvt -e /usr/sbin/firewallinstallshell &
  36. fi
  37. }
  38. export -f firewall_func
  39. # test conectivity
  40. if wget -q --spider http://distro.ibiblio.org ;then # returns other than 0 we're not connected
  41. ONLINE='true'
  42. FIERWALL_LABEL=$(gettext "Setup a firewall")
  43. else
  44. ONLINE='false'
  45. FIERWALL_LABEL=$(gettext "Firewall can be setup after connection")
  46. fi
  47. #v411 commandline param, this section irrelevant...
  48. DEFAULTCONNECT="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  49. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && DEFAULTCONNECT='pgprs-connect'
  50. [ "$DEFAULTCONNECT" = "gkdial" ] && DEFAULTCONNECT="pupdial" #for older pups.
  51. #radiobuttons...
  52. DEFGNOMEPPP="no"
  53. DEFPUPDIAL="no"
  54. DEFRPPPPOE="no"
  55. DEFMTGPRS="no"
  56. DEFICW="no"
  57. DEFPPPOECONF="no" #v409
  58. DEFPWIRELESS="no" #100227
  59. DEFFRISBEE="no" #120823
  60. DEFNETWIZCLASSIC="no" #100227
  61. DEFNETWIZARD="no" #100227
  62. DEFSNS="no" #100310
  63. case $DEFAULTCONNECT in
  64. gnome-ppp)
  65. DEFGNOMEPPP="yes"
  66. ;;
  67. pupdial)
  68. DEFPUPDIAL="yes"
  69. ;;
  70. pppoe_gui)
  71. DEFRPPPPOE="yes"
  72. ;;
  73. pgprs-connect)
  74. DEFMTGPRS="yes"
  75. ;;
  76. pppoeconf) #v409
  77. DEFPPPOECONF="yes"
  78. ;;
  79. Pwireless2) #100227
  80. DEFPWIRELESS="yes"
  81. ;;
  82. frisbee) #120823 130111
  83. DEFFRISBEE="yes"
  84. ;;
  85. net_wiz_classic) #100227
  86. DEFNETWIZCLASSIC="yes"
  87. ;;
  88. net-setup.sh) #100227
  89. DEFNETWIZARD="yes"
  90. ;;
  91. sns) #100310 Simple Network Setup.
  92. DEFSNS="yes"
  93. ;;
  94. *)
  95. DEFICW="yes"
  96. ;;
  97. esac
  98. #101002 rerwin: Wait for initialization scripts to complete... 101122 breakout.
  99. BRKCNT=0 ; BRKPID=0
  100. while [ "`ps aux | grep 'rc.services' | grep -v 'grep'`" != "" ];do
  101. if [ $BRKCNT -eq 1 ];then
  102. /usr/lib/gtkdialog/box_splash -placement center -close never -fontsize large -text "Please wait..." &
  103. BRKPID=$! #120823
  104. fi
  105. sleep 1
  106. BRKCNT=$(($BRKCNT + 1))
  107. [ $BRKCNT -gt 10 ] && break
  108. done
  109. [ $BRKPID -ne 0 ] && kill $BRKPID
  110. #v405
  111. MSGNETIFS="`gettext 'No network interfaces detected'`"
  112. M_if1=$(gettext 'Available network interfaces:')
  113. SHOWNETIFS="`ls -1 /sys/class/net | grep -v -E '^lo|^wmaster' | tr '\n' ' '`"
  114. if [ `echo -n "$SHOWNETIFS" | wc -w` -gt 0 ];then
  115. MSGNETIFS="${M_if1} $SHOWNETIFS"
  116. fi
  117. #v433...
  118. MSGMODEM="`gettext 'No dialup modem detected'`"
  119. if [ -h /dev/modem ];then
  120. DEVMODEM="`readlink /dev/modem`"
  121. if [ -e /dev/modem ];then
  122. MSGMODEM="$(gettext 'Dialup modem detected at port') $DEVMODEM"
  123. else
  124. MSGMODEM="$(gettext 'Dialup modem at port') $DEVMODEM $(gettext 'not found')"
  125. fi
  126. fi
  127. FLAGGNOMEPPP=""
  128. if [ ! "`which gnome-ppp`" = "" ];then
  129. FLAGGNOMEPPP="<radiobutton><label>$(gettext 'GnomePPP (modem dialup)')</label><variable>RADIOGNOMEPPP</variable><default>$DEFGNOMEPPP</default></radiobutton>"
  130. fi
  131. FLAGROARINGPENGUIN=""
  132. CONNECTROARINGPENGUIN="" #v409
  133. if [ "`which pppoe_gui`" != "" ];then
  134. FLAGROARINGPENGUIN="<radiobutton><label>$(gettext 'Roaring Penguin (PPPoE)')</label><variable>RADIORPPPPOE</variable><default>$DEFRPPPPOE</default></radiobutton>"
  135. CONNECTROARINGPENGUIN='
  136. <hbox space-expand="true" space-fill="true">
  137. <button space-expand="false" space-fill="false">
  138. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  139. <action>/usr/sbin/pppoe_gui &</action>
  140. <action type="exit">exit</action>
  141. </button>
  142. <text space-expand="false" space-fill="false"><label>'$(gettext "'Roaring Penguin' PPPOE")'</label></text>
  143. <text space-expand="true" space-fill="true"><label>""</label></text>
  144. </hbox>' #v409
  145. fi
  146. #v411...
  147. FLAGPPPOECONF=""
  148. CONNECTPPPOECONF=""
  149. if [ "`which pppoeconf`" != "" ];then
  150. FLAGPPPOECONF="<radiobutton><label>$(gettext 'Pppoeconf (PPPOE)')</label><variable>RADIOPPPOECONF</variable><default>$DEFPPPOECONF</default></radiobutton>"
  151. CONNECTPPPOECONF='
  152. <hbox space-expand="true" space-fill="true">
  153. <button space-expand="false" space-fill="false">
  154. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  155. <action>/usr/sbin/pppoeconf &</action>
  156. <action type="exit">exit</action>
  157. </button>
  158. <text space-expand="false" space-fill="false"><label>'$(gettext "'Pppoeconf' PPPOE")'</label></text>
  159. <text space-expand="true" space-fill="true"><label>""</label></text>
  160. </hbox>'
  161. fi
  162. FLAGMTGPRS=""
  163. if [ "`which pgprs-setup`" != "" ];then
  164. CONNECTMTGPRS='
  165. <hbox space-expand="true" space-fill="true">
  166. <button space-expand="false" space-fill="false">
  167. '"`/usr/lib/gtkdialog/xml_button-icon wireless.svg big`"'
  168. <action>/usr/sbin/pgprs-shell &</action>
  169. <action type="exit">exit</action>
  170. </button>
  171. <text space-expand="false" space-fill="false"><label>'$(gettext "Wireless GPRS modem")'</label></text>
  172. <text space-expand="true" space-fill="true"><label>""</label></text>
  173. </hbox>'
  174. FLAGMTGPRS="<radiobutton><label>$(gettext "GPRS Connect")</label><variable>RADIOMTGPRS</variable><default>$DEFMTGPRS</default></radiobutton>"
  175. fi
  176. if [ -d /usr/local/Pwireless2 ];then #100227 Jemimah's wireless connection gui.
  177. FLAGPWIRELESS="<radiobutton><label>$(gettext "Pwireless (wireless networking)")</label><variable>RADIOPWIRELESS</variable><default>$DEFPWIRELESS</default></radiobutton>"
  178. fi
  179. if [ -f /usr/local/bin/frisbee ];then #100227 121112 130111 Jemimah's wireless connection gui.
  180. FLAGFRISBEE="<radiobutton><label>$(gettext "Frisbee (wireless networking)")</label><variable>RADIOFRISBEE</variable><default>$DEFFRISBEE</default></radiobutton>"
  181. fi
  182. if [ -f /usr/local/net_setup/usr/sbin/net-setup.sh ];then #100227 wizard used in older puppies.
  183. FLAGNETWIZCLASSIC="<radiobutton><label>$(gettext "Network Wizard Classic")</label><variable>RADIONETWIZCLASSIC</variable><default>$DEFNETWIZCLASSIC</default></radiobutton>"
  184. fi
  185. if [ -f /usr/sbin/net-setup.sh ];then #100227 wizard developed by Dougal.
  186. FLAGNETWIZARD="<radiobutton><label>$(gettext "Dougal's Network Wizard")</label><variable>RADIONETWIZARD</variable><default>$DEFNETWIZARD</default></radiobutton>"
  187. fi
  188. if [ -d /usr/local/simple_network_setup ];then #100310
  189. FLAGSNS="<radiobutton><label>$(gettext "Barry's Simple Network Setup")</label><variable>RADIOSNS</variable><default>$DEFSNS</default></radiobutton>"
  190. fi
  191. #v411...
  192. CHOOSEDEFAULT='
  193. <vbox space-expand="true" space-fill="true">
  194. '"`/usr/lib/gtkdialog/xml_info fixed internet_connect.svg 60 "$(gettext "What you choose here will start immediately next time you click the 'connect' icon either on the desktop or the tray.")"`"'
  195. <vbox space-expand="true" space-fill="true">
  196. <frame '$(gettext "Connect action")'>
  197. <vbox space-expand="true" space-fill="true">
  198. <radiobutton><label>'$(gettext "PupDial (modem dialup)")'</label><variable>RADIOPUPDIAL</variable><default>'$DEFPUPDIAL'</default></radiobutton>
  199. '$FLAGSNS'
  200. '$FLAGNETWIZARD'
  201. '$FLAGPWIRELESS'
  202. '$FLAGFRISBEE'
  203. '$FLAGNETWIZCLASSIC'
  204. '$FLAGMTGPRS'
  205. '$FLAGGNOMEPPP'
  206. '$FLAGPPPOECONF'
  207. '$FLAGROARINGPENGUIN'
  208. <radiobutton><label>'$(gettext "Internet Connection Wizard")'</label><variable>RADIOICW</variable><default>'$DEFICW'</default></radiobutton>
  209. </vbox>
  210. </frame>
  211. </vbox>
  212. </vbox>'
  213. [ $1 ] && CHOOSEDEFAULT=""
  214. HOSTNAME="`cat /etc/hostname`" #111106 do not use $HOSTNAME, as hostname-set may have just been run.
  215. export InternetConnectionWizard='
  216. <window title="'$(gettext "Internet Connection Wizard")'" icon-name="gtk-connect">
  217. <vbox space-expand="true" space-fill="true">
  218. <notebook labels="'$(gettext 'Connection')'|'$(gettext 'Desktop / Tray')'">
  219. <vbox space-expand="true" space-fill="true">
  220. '"`/usr/lib/gtkdialog/xml_info fixed internet_connect.svg 60 "$MSGNETIFS" "$MSGMODEM" "<b>$(gettext "Help button for more info")</b>"`"'
  221. <hbox space-expand="true" space-fill="true">
  222. <vbox space-expand="true" space-fill="true">
  223. <frame '$(gettext "Connect to Internet by")'>
  224. <vbox space-expand="false" space-fill="false">
  225. <hbox space-expand="true" space-fill="true">
  226. <button space-expand="false" space-fill="false">
  227. '"`/usr/lib/gtkdialog/xml_button-icon network_connect.svg big`"'
  228. <action>/usr/sbin/connectwizard_2nd & </action>
  229. <action type="exit">true_exit</action>
  230. </button>
  231. <text space-expand="false" space-fill="false"><label>'$(gettext "Wired or wireless LAN")'</label></text>
  232. <text space-expand="true" space-fill="true"><label>""</label></text>
  233. </hbox>
  234. <hbox space-expand="true" space-fill="true">
  235. <button space-expand="false" space-fill="false">
  236. '"`/usr/lib/gtkdialog/xml_button-icon modem.svg big`"'
  237. <action>/usr/sbin/pupdial & </action>
  238. <action type="exit">true_exit</action>
  239. </button>
  240. <text space-expand="false" space-fill="false"><label>'$(gettext "Dialup analog or wireless modem (2g/3g)")'</label></text>
  241. <text space-expand="true" space-fill="true"><label>""</label></text>
  242. </hbox>
  243. '${CONNECTMTGPRS}'
  244. '${CONNECTPPPOECONF}'
  245. '${CONNECTROARINGPENGUIN}'
  246. </vbox>
  247. </frame>
  248. </vbox>
  249. <vbox space-expand="true" space-fill="true">
  250. <frame '$(gettext 'Tools')'>
  251. <vbox space-expand="false" space-fill="false">
  252. <hbox space-expand="true" space-fill="true">
  253. <text space-expand="false" space-fill="false"><label>'"$FIERWALL_LABEL"'</label></text>
  254. <button space-expand="false" space-fill="false" sensitive="'"$ONLINE"'">
  255. '"`/usr/lib/gtkdialog/xml_button-icon firewall.svg big`"'
  256. <action>firewall_func</action>
  257. <action type="exit">exit</action>
  258. </button>
  259. </hbox>
  260. <hbox space-expand="true" space-fill="true">
  261. <text space-expand="false" space-fill="false"><label>'$(gettext "Setup a proxy server")'</label></text>
  262. <button space-expand="false" space-fill="false">
  263. '"`/usr/lib/gtkdialog/xml_button-icon shield_internet.svg big`"'
  264. <action>/usr/local/simple_network_setup/proxy-setup &</action>
  265. <action type="exit">exit</action>
  266. </button>
  267. </hbox>
  268. <hbox space-expand="true" space-fill="true" tooltip-text="'$(gettext 'This gives detailed network interface information')'">
  269. <text space-expand="false" space-fill="false"><label>'$(gettext "Network information")'</label></text>
  270. <button space-expand="false" space-fill="false">
  271. '"`/usr/lib/gtkdialog/xml_button-icon info.svg big`"'
  272. <action>ipinfo & </action>
  273. </button>
  274. </hbox>
  275. <hbox space-expand="true" space-fill="true" tooltip-text="'$(gettext 'Type your computer name to identify in the network. Alpha-numeric without spaces. Then click button to apply the change.')'">
  276. <text width-request="30" space-expand="true" space-fill="true"><label>""</label></text>
  277. <vbox>
  278. <text space-expand="false" space-fill="false"><label>'$(gettext 'Change hostname')'</label></text>
  279. <entry width-chars="15">
  280. <input>echo -n "'$HOSTNAME'"</input>
  281. <variable>ENTRY_HOSTNAME</variable>
  282. </entry>
  283. </vbox>
  284. <button space-expand="false" space-fill="false">
  285. '"`/usr/lib/gtkdialog/xml_button-icon apply.svg big`"'
  286. <action>/usr/sbin/hostname-set $ENTRY_HOSTNAME</action>
  287. </button>
  288. </hbox>
  289. </vbox>
  290. </frame>
  291. </vbox>
  292. </hbox>
  293. </vbox>
  294. '${CHOOSEDEFAULT}'
  295. </notebook>
  296. <hbox space-expand="false" space-fill="false">
  297. <button space-expand="false" space-fill="false">
  298. <label>'$(gettext "Help")'</label>
  299. '"`/usr/lib/gtkdialog/xml_button-icon help`"'
  300. <action>/usr/local/apps/Connect/connect_help & </action>
  301. </button>
  302. <text space-expand="true" space-fill="true"><label>""</label></text>
  303. <button space-expand="false" space-fill="false">
  304. <label>'$(gettext "Ok")'</label>
  305. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  306. <action>exit:OK</action>
  307. </button>
  308. </hbox>
  309. </vbox>
  310. </window>'
  311. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  312. RETSTR="`gtkdialog -p InternetConnectionWizard`"
  313. [ $1 ] && exit #v411
  314. [ "`echo "$RETSTR" | grep 'true_exit'`" != "" ] && exit #100412 after return from sns. 100902 and pupdial.
  315. RADIOBUT="`echo "$RETSTR" | grep '^RADIO' | grep '"true"' | cut -f 1 -d '='`"
  316. [ "$RADIOBUT" = "RADIOGNOMEPPP" ] && echo -e '#!/bin/sh\nexec gnomepppshell' > /usr/local/bin/defaultconnect
  317. [ "$RADIOBUT" = "RADIOPUPDIAL" ] && echo -e '#!/bin/sh\nexec pupdial' > /usr/local/bin/defaultconnect
  318. [ "$RADIOBUT" = "RADIORPPPPOE" ] && echo -e '#!/bin/sh\nexec pppoe_gui' > /usr/local/bin/defaultconnect
  319. [ "$RADIOBUT" = "RADIOMTGPRS" ] && echo -e '#!/bin/sh\nexec rxvt -title "pgprs-connect PRESS CTRL+C TO DISCONNECT" -e pgprs-connect' > /usr/local/bin/defaultconnect
  320. [ "$RADIOBUT" = "RADIOICW" ] && echo -e '#!/bin/sh\nexec connectwizard' > /usr/local/bin/defaultconnect
  321. [ "$RADIOBUT" = "RADIOPPPOECONF" ] && echo -e '#!/bin/sh\nexec pppoeconf' > /usr/local/bin/defaultconnect #v409
  322. [ "$RADIOBUT" = "RADIOPWIRELESS" ] && echo -e '#!/bin/sh\nexec Pwireless2' > /usr/local/bin/defaultconnect #100227
  323. [ "$RADIOBUT" = "RADIOFRISBEE" ] && echo -e '#!/bin/sh\nexec frisbee' > /usr/local/bin/defaultconnect #120823 130111
  324. [ "$RADIOBUT" = "RADIONETWIZCLASSIC" ] && echo -e '#!/bin/sh\nexec net_wiz_classic' > /usr/local/bin/defaultconnect #100227
  325. [ "$RADIOBUT" = "RADIONETWIZARD" ] && echo -e '#!/bin/sh\nexec net-setup.sh' > /usr/local/bin/defaultconnect #100227
  326. [ "$RADIOBUT" = "RADIOSNS" ] && echo -e '#!/bin/sh\nexec sns' > /usr/local/bin/defaultconnect #100227
  327. if [ "$FLAGFRISBEE" ];then #130111 precaution...
  328. echo -n "$RADIOBUT" | grep -q -E 'CW$|FRISBEE|PUPDIAL|MTGPRS' \
  329. || frisbee_mode_disable
  330. fi
  331. ###end###