connectwizard 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. #v411 commandline param, this section irrelevant...
  30. DEFAULTCONNECT="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  31. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && DEFAULTCONNECT='pgprs-connect'
  32. [ "$DEFAULTCONNECT" = "gkdial" ] && DEFAULTCONNECT="pupdial" #for older pups.
  33. #radiobuttons...
  34. DEFGNOMEPPP="no"
  35. DEFPUPDIAL="no"
  36. DEFRPPPPOE="no"
  37. DEFMTGPRS="no"
  38. DEFICW="no"
  39. DEFPPPOECONF="no" #v409
  40. DEFPWIRELESS="no" #100227
  41. DEFFRISBEE="no" #120823
  42. DEFNETWIZCLASSIC="no" #100227
  43. DEFNETWIZARD="no" #100227
  44. DEFSNS="no" #100310
  45. case $DEFAULTCONNECT in
  46. gnome-ppp)
  47. DEFGNOMEPPP="yes"
  48. ;;
  49. pupdial)
  50. DEFPUPDIAL="yes"
  51. ;;
  52. pppoe_gui)
  53. DEFRPPPPOE="yes"
  54. ;;
  55. pgprs-connect)
  56. DEFMTGPRS="yes"
  57. ;;
  58. pppoeconf) #v409
  59. DEFPPPOECONF="yes"
  60. ;;
  61. Pwireless2) #100227
  62. DEFPWIRELESS="yes"
  63. ;;
  64. frisbee) #120823 130111
  65. DEFFRISBEE="yes"
  66. ;;
  67. net_wiz_classic) #100227
  68. DEFNETWIZCLASSIC="yes"
  69. ;;
  70. net-setup.sh) #100227
  71. DEFNETWIZARD="yes"
  72. ;;
  73. sns) #100310 Simple Network Setup.
  74. DEFSNS="yes"
  75. ;;
  76. *)
  77. DEFICW="yes"
  78. ;;
  79. esac
  80. #101002 rerwin: Wait for initialization scripts to complete... 101122 breakout.
  81. BRKCNT=0 ; BRKPID=0
  82. while [ "`ps aux | grep 'rc.services' | grep -v 'grep'`" != "" ];do
  83. if [ $BRKCNT -eq 1 ];then
  84. /usr/lib/gtkdialog/box_splash -placement center -close never -fontsize large -text "Please wait..." &
  85. BRKPID=$! #120823
  86. fi
  87. sleep 1
  88. BRKCNT=$(($BRKCNT + 1))
  89. [ $BRKCNT -gt 10 ] && break
  90. done
  91. [ $BRKPID -ne 0 ] && kill $BRKPID
  92. #v405
  93. MSGNETIFS="`gettext 'No network interfaces detected'`"
  94. M_if1=$(gettext 'Available network interfaces:')
  95. SHOWNETIFS="`ls -1 /sys/class/net | grep -v -E '^lo|^wmaster' | tr '\n' ' '`"
  96. if [ `echo -n "$SHOWNETIFS" | wc -w` -gt 0 ];then
  97. MSGNETIFS="${M_if1} $SHOWNETIFS"
  98. fi
  99. #v433...
  100. MSGMODEM="`gettext 'No dialup modem detected'`"
  101. if [ -h /dev/modem ];then
  102. DEVMODEM="`readlink /dev/modem`"
  103. if [ -e /dev/modem ];then
  104. MSGMODEM="$(gettext 'Dialup modem detected at port') $DEVMODEM"
  105. else
  106. MSGMODEM="$(gettext 'Dialup modem at port') $DEVMODEM $(gettext 'not found')"
  107. fi
  108. fi
  109. FLAGGNOMEPPP=""
  110. if [ ! "`which gnome-ppp`" = "" ];then
  111. FLAGGNOMEPPP="<radiobutton><label>$(gettext 'GnomePPP (modem dialup)')</label><variable>RADIOGNOMEPPP</variable><default>$DEFGNOMEPPP</default></radiobutton>"
  112. fi
  113. FLAGROARINGPENGUIN=""
  114. CONNECTROARINGPENGUIN="" #v409
  115. if [ "`which pppoe_gui`" != "" ];then
  116. FLAGROARINGPENGUIN="<radiobutton><label>$(gettext 'Roaring Penguin (PPPoE)')</label><variable>RADIORPPPPOE</variable><default>$DEFRPPPPOE</default></radiobutton>"
  117. CONNECTROARINGPENGUIN='
  118. <hbox space-expand="true" space-fill="true">
  119. <button space-expand="false" space-fill="false">
  120. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  121. <action>/usr/sbin/pppoe_gui &</action>
  122. <action type="exit">exit</action>
  123. </button>
  124. <text space-expand="false" space-fill="false"><label>'$(gettext "'Roaring Penguin' PPPOE")'</label></text>
  125. <text space-expand="true" space-fill="true"><label>""</label></text>
  126. </hbox>' #v409
  127. fi
  128. #v411...
  129. FLAGPPPOECONF=""
  130. CONNECTPPPOECONF=""
  131. if [ "`which pppoeconf`" != "" ];then
  132. FLAGPPPOECONF="<radiobutton><label>$(gettext 'Pppoeconf (PPPOE)')</label><variable>RADIOPPPOECONF</variable><default>$DEFPPPOECONF</default></radiobutton>"
  133. CONNECTPPPOECONF='
  134. <hbox space-expand="true" space-fill="true">
  135. <button space-expand="false" space-fill="false">
  136. '"`/usr/lib/gtkdialog/xml_button-icon internet_connect.svg big`"'
  137. <action>/usr/sbin/pppoeconf &</action>
  138. <action type="exit">exit</action>
  139. </button>
  140. <text space-expand="false" space-fill="false"><label>'$(gettext "'Pppoeconf' PPPOE")'</label></text>
  141. <text space-expand="true" space-fill="true"><label>""</label></text>
  142. </hbox>'
  143. fi
  144. #FLAGMTGPRS=""
  145. #if [ "`which pgprs-setup`" != "" ];then
  146. CONNECTMTGPRS='
  147. <hbox space-expand="true" space-fill="true">
  148. <button space-expand="false" space-fill="false">
  149. '"`/usr/lib/gtkdialog/xml_button-icon wireless.svg big`"'
  150. <action>/usr/sbin/pgprs-shell &</action>
  151. <action type="exit">exit</action>
  152. </button>
  153. <text space-expand="false" space-fill="false"><label>'$(gettext "Wireless GPRS modem")'</label></text>
  154. <text space-expand="true" space-fill="true"><label>""</label></text>
  155. </hbox>'
  156. FLAGMTGPRS="<radiobutton><label>$(gettext "GPRS Connect")</label><variable>RADIOMTGPRS</variable><default>$DEFMTGPRS</default></radiobutton>"
  157. #fi
  158. if [ -d /usr/local/Pwireless2 ];then #100227 Jemimah's wireless connection gui.
  159. FLAGPWIRELESS="<radiobutton><label>$(gettext "Pwireless (wireless networking)")</label><variable>RADIOPWIRELESS</variable><default>$DEFPWIRELESS</default></radiobutton>"
  160. fi
  161. if [ -f /usr/local/bin/frisbee ];then #100227 121112 130111 Jemimah's wireless connection gui.
  162. FLAGFRISBEE="<radiobutton><label>$(gettext "Frisbee (wireless networking)")</label><variable>RADIOFRISBEE</variable><default>$DEFFRISBEE</default></radiobutton>"
  163. fi
  164. if [ -f /usr/local/net_setup/usr/sbin/net-setup.sh ];then #100227 wizard used in older puppies.
  165. FLAGNETWIZCLASSIC="<radiobutton><label>$(gettext "Network Wizard Classic")</label><variable>RADIONETWIZCLASSIC</variable><default>$DEFNETWIZCLASSIC</default></radiobutton>"
  166. fi
  167. if [ -f /usr/sbin/net-setup.sh ];then #100227 wizard developed by Dougal.
  168. FLAGNETWIZARD="<radiobutton><label>$(gettext "Dougal's Network Wizard")</label><variable>RADIONETWIZARD</variable><default>$DEFNETWIZARD</default></radiobutton>"
  169. fi
  170. if [ -d /usr/local/simple_network_setup ];then #100310
  171. FLAGSNS="<radiobutton><label>$(gettext "Barry's Simple Network Setup")</label><variable>RADIOSNS</variable><default>$DEFSNS</default></radiobutton>"
  172. fi
  173. #v411...
  174. CHOOSEDEFAULT='
  175. <vbox space-expand="true" space-fill="true">
  176. '"`/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.")"`"'
  177. <vbox space-expand="true" space-fill="true">
  178. <frame '$(gettext "Connect action")'>
  179. <vbox space-expand="true" space-fill="true">
  180. <radiobutton><label>'$(gettext "PupDial (modem dialup)")'</label><variable>RADIOPUPDIAL</variable><default>'$DEFPUPDIAL'</default></radiobutton>
  181. '$FLAGSNS'
  182. '$FLAGNETWIZARD'
  183. '$FLAGPWIRELESS'
  184. '$FLAGFRISBEE'
  185. '$FLAGNETWIZCLASSIC'
  186. '$FLAGMTGPRS'
  187. '$FLAGGNOMEPPP'
  188. '$FLAGPPPOECONF'
  189. '$FLAGROARINGPENGUIN'
  190. <radiobutton><label>'$(gettext "Internet Connection Wizard")'</label><variable>RADIOICW</variable><default>'$DEFICW'</default></radiobutton>
  191. </vbox>
  192. </frame>
  193. </vbox>
  194. </vbox>'
  195. [ $1 ] && CHOOSEDEFAULT=""
  196. HOSTNAME="`cat /etc/hostname`" #111106 do not use $HOSTNAME, as hostname-set may have just been run.
  197. export InternetConnectionWizard='
  198. <window title="'$(gettext "Internet Connection Wizard")'" icon-name="gtk-connect">
  199. <vbox space-expand="true" space-fill="true">
  200. <notebook labels="'$(gettext 'Connection')'|'$(gettext 'Desktop / Tray')'">
  201. <vbox space-expand="true" space-fill="true">
  202. '"`/usr/lib/gtkdialog/xml_info fixed internet_connect.svg 60 "$MSGNETIFS" "$MSGMODEM" "<b>$(gettext "Help button for more info")</b>"`"'
  203. <hbox space-expand="true" space-fill="true">
  204. <vbox space-expand="true" space-fill="true">
  205. <frame '$(gettext "Connect to Internet by")'>
  206. <vbox space-expand="false" space-fill="false">
  207. <hbox space-expand="true" space-fill="true">
  208. <button space-expand="false" space-fill="false">
  209. '"`/usr/lib/gtkdialog/xml_button-icon network_connect.svg big`"'
  210. <action>/usr/sbin/connectwizard_2nd & </action>
  211. <action type="exit">true_exit</action>
  212. </button>
  213. <text space-expand="false" space-fill="false"><label>'$(gettext "Wired or wireless LAN")'</label></text>
  214. <text space-expand="true" space-fill="true"><label>""</label></text>
  215. </hbox>
  216. <hbox space-expand="true" space-fill="true">
  217. <button space-expand="false" space-fill="false">
  218. '"`/usr/lib/gtkdialog/xml_button-icon modem.svg big`"'
  219. <action>/usr/sbin/pupdial & </action>
  220. <action type="exit">true_exit</action>
  221. </button>
  222. <text space-expand="false" space-fill="false"><label>'$(gettext "Dialup analog or wireless modem (2g/3g)")'</label></text>
  223. <text space-expand="true" space-fill="true"><label>""</label></text>
  224. </hbox>
  225. '${CONNECTMTGPRS}'
  226. '${CONNECTPPPOECONF}'
  227. '${CONNECTROARINGPENGUIN}'
  228. </vbox>
  229. </frame>
  230. </vbox>
  231. <vbox space-expand="true" space-fill="true">
  232. <frame '$(gettext 'Tools')'>
  233. <vbox space-expand="false" space-fill="false">
  234. <hbox space-expand="true" space-fill="true">
  235. <text space-expand="false" space-fill="false"><label>'$(gettext "Setup a firewall")'</label></text>
  236. <button space-expand="false" space-fill="false">
  237. '"`/usr/lib/gtkdialog/xml_button-icon firewall.svg big`"'
  238. <action>rxvt -e /usr/sbin/firewallinstallshell &</action>
  239. <action type="exit">exit</action>
  240. </button>
  241. </hbox>
  242. <hbox space-expand="true" space-fill="true">
  243. <text space-expand="false" space-fill="false"><label>'$(gettext "Setup a proxy server")'</label></text>
  244. <button space-expand="false" space-fill="false">
  245. '"`/usr/lib/gtkdialog/xml_button-icon shield_internet.svg big`"'
  246. <action>/usr/local/simple_network_setup/proxy-setup &</action>
  247. <action type="exit">exit</action>
  248. </button>
  249. </hbox>
  250. <hbox space-expand="true" space-fill="true" tooltip-text="'$(gettext 'This gives detailed network interface information')'">
  251. <text space-expand="false" space-fill="false"><label>'$(gettext "Network information")'</label></text>
  252. <button space-expand="false" space-fill="false">
  253. '"`/usr/lib/gtkdialog/xml_button-icon info.svg big`"'
  254. <action>ipinfo & </action>
  255. </button>
  256. </hbox>
  257. <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.')'">
  258. <text width-request="30" space-expand="true" space-fill="true"><label>""</label></text>
  259. <vbox>
  260. <text space-expand="false" space-fill="false"><label>'$(gettext 'Change hostname')'</label></text>
  261. <entry width-chars="15">
  262. <input>echo -n "'$HOSTNAME'"</input>
  263. <variable>ENTRY_HOSTNAME</variable>
  264. </entry>
  265. </vbox>
  266. <button space-expand="false" space-fill="false">
  267. '"`/usr/lib/gtkdialog/xml_button-icon apply.svg big`"'
  268. <action>/usr/sbin/hostname-set $ENTRY_HOSTNAME</action>
  269. </button>
  270. </hbox>
  271. </vbox>
  272. </frame>
  273. </vbox>
  274. </hbox>
  275. </vbox>
  276. '${CHOOSEDEFAULT}'
  277. </notebook>
  278. <hbox space-expand="false" space-fill="false">
  279. <button space-expand="false" space-fill="false">
  280. <label>'$(gettext "Help")'</label>
  281. '"`/usr/lib/gtkdialog/xml_button-icon help`"'
  282. <action>/usr/local/apps/Connect/connect_help & </action>
  283. </button>
  284. <text space-expand="true" space-fill="true"><label>""</label></text>
  285. <button space-expand="false" space-fill="false">
  286. <label>'$(gettext "Ok")'</label>
  287. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  288. <action>exit:OK</action>
  289. </button>
  290. </hbox>
  291. </vbox>
  292. </window>'
  293. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  294. RETSTR="`gtkdialog -p InternetConnectionWizard`"
  295. [ $1 ] && exit #v411
  296. [ "`echo "$RETSTR" | grep 'true_exit'`" != "" ] && exit #100412 after return from sns. 100902 and pupdial.
  297. RADIOBUT="`echo "$RETSTR" | grep '^RADIO' | grep '"true"' | cut -f 1 -d '='`"
  298. [ "$RADIOBUT" = "RADIOGNOMEPPP" ] && echo -e '#!/bin/sh\nexec gnomepppshell' > /usr/local/bin/defaultconnect
  299. [ "$RADIOBUT" = "RADIOPUPDIAL" ] && echo -e '#!/bin/sh\nexec pupdial' > /usr/local/bin/defaultconnect
  300. [ "$RADIOBUT" = "RADIORPPPPOE" ] && echo -e '#!/bin/sh\nexec pppoe_gui' > /usr/local/bin/defaultconnect
  301. [ "$RADIOBUT" = "RADIOMTGPRS" ] && echo -e '#!/bin/sh\nexec rxvt -title "pgprs-connect PRESS CTRL+C TO DISCONNECT" -e pgprs-connect' > /usr/local/bin/defaultconnect
  302. [ "$RADIOBUT" = "RADIOICW" ] && echo -e '#!/bin/sh\nexec connectwizard' > /usr/local/bin/defaultconnect
  303. [ "$RADIOBUT" = "RADIOPPPOECONF" ] && echo -e '#!/bin/sh\nexec pppoeconf' > /usr/local/bin/defaultconnect #v409
  304. [ "$RADIOBUT" = "RADIOPWIRELESS" ] && echo -e '#!/bin/sh\nexec Pwireless2' > /usr/local/bin/defaultconnect #100227
  305. [ "$RADIOBUT" = "RADIOFRISBEE" ] && echo -e '#!/bin/sh\nexec frisbee' > /usr/local/bin/defaultconnect #120823 130111
  306. [ "$RADIOBUT" = "RADIONETWIZCLASSIC" ] && echo -e '#!/bin/sh\nexec net_wiz_classic' > /usr/local/bin/defaultconnect #100227
  307. [ "$RADIOBUT" = "RADIONETWIZARD" ] && echo -e '#!/bin/sh\nexec net-setup.sh' > /usr/local/bin/defaultconnect #100227
  308. [ "$RADIOBUT" = "RADIOSNS" ] && echo -e '#!/bin/sh\nexec sns' > /usr/local/bin/defaultconnect #100227
  309. if [ "$FLAGFRISBEE" ];then #130111 precaution...
  310. echo -n "$RADIOBUT" | grep -q -E 'CW$|FRISBEE|PUPDIAL|MTGPRS' \
  311. || frisbee_mode_disable
  312. fi
  313. ###end###