connectwizard_2nd 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. #!/bin/sh
  2. #(c) Copyright 2010 Barry Kauler bkhome.org
  3. #Lesser GPL licence v2 (/usr/share/doc/legal/lgpl-2.1.txt)
  4. #called from 'connectwizard'
  5. #choose between old Network Wizard, new Network Wizard and Pwireless2.
  6. #100227 BK initial creation of script.
  7. #100306 added Barry's Simple Network Setup. 100810 moved SNS to top choice, improved messages.
  8. #120201 rodin.s: internationalized.
  9. #121029 01micko, rerwin: added/integrated Frisbee.
  10. #121122 rerwin: change indicator of frisbee; ensure frisbee stopped if not chosen.
  11. #130103 rerwin: change name of frisbee invocations for integrated version.
  12. #131216 zigbert: gui (gtkdialog) improvements.
  13. export TEXTDOMAIN=connectwizard_2nd
  14. export TEXTDOMAINDIR=/usr/share/locale
  15. export OUTPUT_CHARSET=UTF-8
  16. . gettext.sh
  17. export LANGORG=$LANG
  18. /usr/lib/gtkdialog/svg_text "Simple Network Setup" > /tmp/network_connection_wizard_1.svg
  19. /usr/lib/gtkdialog/svg_text "Pwireless2" > /tmp/network_connection_wizard_2.svg
  20. /usr/lib/gtkdialog/svg_text "Frisbee" > /tmp/network_connection_wizard_3.svg
  21. /usr/lib/gtkdialog/svg_text "Network Wizard" > /tmp/network_connection_wizard_4.svg
  22. /usr/lib/gtkdialog/svg_text "Network Wizard (classic)" > /tmp/network_connection_wizard_5.svg
  23. #100306
  24. SNS=""
  25. if [ -d /usr/local/simple_network_setup ];then
  26. SNS='
  27. <vbox>
  28. <button>
  29. '"`/usr/lib/gtkdialog/xml_button-icon /tmp/network_connection_wizard_1.svg`"'
  30. <action type="exit">FLAGSNS</action>
  31. </button>
  32. <hbox space-expand="true" space-fill="true">
  33. <text width-request="10" space-expand="false" space-fill="false"><label>""</label></text>
  34. <text use-markup="true" space-expand="false" space-fill="false"><label>"'$(gettext 'This is a simple network setup tool created by BarryK. Not as many features as the Network Wizard, for example requires the network to have a DHCP server (the vast majority of cases). The greatest feature is extreme ease of use. <b>Recommended for most people.</b>')'"</label></text>
  35. <text space-expand="true" space-fill="true"><label>""</label></text>
  36. </hbox>
  37. <text space-expand="true" space-fill="true"><label>""</label></text>
  38. </vbox>'
  39. fi
  40. PWIRELESS=""
  41. if [ -d /usr/local/Pwireless2 ];then #Jemimah's wireless connection gui.
  42. PWIRELESS='
  43. <vbox>
  44. <button>
  45. '"`/usr/lib/gtkdialog/xml_button-icon /tmp/network_connection_wizard_2.svg`"'
  46. <action type="exit">FLAGPWIRELESS</action>
  47. </button>
  48. <hbox space-expand="true" space-fill="true">
  49. <text width-request="10" space-expand="false" space-fill="false"><label>""</label></text>
  50. <text use-markup="true" space-expand="false" space-fill="false"><label>"'$(gettext 'This is a tool developed by Jemimah. Mostly for wireless connectivity for laptops, but also can handle ethernet connection. Very good for wireless roaming. Under very active development (see forum).')'"</label></text>
  51. <text space-expand="true" space-fill="true"><label>""</label></text>
  52. </hbox>
  53. <text space-expand="true" space-fill="true"><label>""</label></text>
  54. </vbox>'
  55. fi
  56. FRISBEE="" #121029...
  57. if [ -f /usr/local/bin/frisbee ];then #Jemimah's wireless connection gui. 121122 130103
  58. FRISBEE='
  59. <vbox>
  60. <button>
  61. '"`/usr/lib/gtkdialog/xml_button-icon /tmp/network_connection_wizard_3.svg`"'
  62. <action type="exit">FLAGFRISBEE</action>
  63. </button>
  64. <hbox space-expand="true" space-fill="true">
  65. <text width-request="10" space-expand="false" space-fill="false"><label>""</label></text>
  66. <text use-markup="true" space-expand="false" space-fill="false"><label>"'$(gettext 'This is a tool developed by Jemimah. Mostly for wireless connectivity for laptops, but also can handle ethernet connection. <b>Very good for wireless roaming.</b>')'"</label></text>
  67. <text space-expand="true" space-fill="true"><label>""</label></text>
  68. </hbox>
  69. <text space-expand="true" space-fill="true"><label>""</label></text>
  70. </vbox>'
  71. fi
  72. NETWIZARD=""
  73. if [ -f /usr/sbin/net-setup.sh ];then #wizard developed by Dougal.
  74. NETWIZARD='
  75. <vbox>
  76. <button>
  77. '"`/usr/lib/gtkdialog/xml_button-icon /tmp/network_connection_wizard_4.svg`"'
  78. <action type="exit">FLAGNETWIZARD</action>
  79. </button>
  80. <hbox space-expand="true" space-fill="true">
  81. <text width-request="10" space-expand="false" space-fill="false"><label>""</label></text>
  82. <text use-markup="true" space-expand="false" space-fill="false"><label>"'$(gettext "This is the most sophisticated tool for network setup in Puppy. It is based on the 'Classic' Network Wizard originally written by BarryK, but greatly enhanced by Dougal, Rarsa, Shinobar and others. It is for both wired (ethernet) and wireless connectivity, <b>with more configuration features</b> than Frisbee and SNS.")'"</label></text>
  83. <text space-expand="true" space-fill="true"><label>""</label></text>
  84. </hbox>
  85. <text space-expand="true" space-fill="true"><label>""</label></text>
  86. </vbox>'
  87. fi
  88. NETWIZCLASSIC=""
  89. if [ -f /usr/local/net_setup/usr/sbin/net-setup.sh ];then #wizard used in older puppies.
  90. NETWIZCLASSIC='
  91. <vbox>
  92. <button>
  93. '"`/usr/lib/gtkdialog/xml_button-icon /tmp/network_connection_wizard_5.svg`"'
  94. <action type="exit">FLAGNETWIZCLASSIC</action>
  95. </button>
  96. <hbox space-expand="true" space-fill="true">
  97. <text width-request="10" space-expand="false" space-fill="false"><label>""</label></text>
  98. <text use-markup="true" space-expand="false" space-fill="false"><label>"'$(gettext "The Network Wizard was originally developed by Barry Kauler, with considerable input from others.")'"</label></text>
  99. <text space-expand="true" space-fill="true"><label>""</label></text>
  100. </hbox>
  101. <text space-expand="true" space-fill="true"><label>""</label></text>
  102. </vbox>'
  103. fi
  104. export Network_Connection_Wizard='
  105. <window title="'$(gettext 'Network Connection Wizard')'" icon-name="gtk-connect">
  106. <vbox space-expand="true" space-fill="true">
  107. '"`/usr/lib/gtkdialog/xml_info fixed network_connect.svg 60 "$(gettext 'This build of Puppy has the following choices of GUI tool that you can use to connect to a network (and Internet)...')"`"'
  108. <vbox space-expand="true" space-fill="true">
  109. <frame>
  110. '${SNS}'
  111. '${PWIRELESS}'
  112. '${FRISBEE}'
  113. '${NETWIZARD}'
  114. '${NETWIZCLASSIC}'
  115. </frame>
  116. </vbox>
  117. <hbox space-expand="false" space-fill="false">
  118. <button space-expand="false" space-fill="false">
  119. <label>'$(gettext "Cancel")'</label>
  120. '"`/usr/lib/gtkdialog/xml_button-icon cancel`"'
  121. <action>exit:Cancel</action>
  122. </button>
  123. </hbox>
  124. </vbox>
  125. </window>'
  126. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  127. RETSTRING="`gtkdialog -p Network_Connection_Wizard`"
  128. if [ "`echo "$RETSTRING" | grep '^EXIT' | grep 'FLAG'`" != "" ];then
  129. CHOSENWIZ="`echo "$RETSTRING" | grep '^EXIT' | grep 'FLAG' | cut -f 2 -d '"'`"
  130. if [ "$FRISBEE" ];then #130103...
  131. [ "$CHOSENWIZ" != "FLAGFRISBEE" ] && frisbee_mode_disable
  132. fi
  133. case $CHOSENWIZ in
  134. FLAGPWIRELESS) #Pwireless2
  135. chmod 755 /etc/init.d/Pwireless2 #100304
  136. /etc/init.d/Pwireless2 start #100304
  137. /usr/local/bin/Pwireless2 > /dev/null 2>&1
  138. NWEXEC='Pwireless2'
  139. NWCHOICE="Jemimah's Pwireless2"
  140. ;;
  141. FLAGFRISBEE) #121029
  142. /usr/local/bin/frisbee > /dev/null 2>&1 #130103
  143. NWEXEC='frisbee' #130103
  144. NWCHOICE="Jemimah's Frisbee"
  145. ;;
  146. FLAGNETWIZARD) #net-setup.sh
  147. /usr/sbin/net-setup.sh > /dev/null 2>&1
  148. NWEXEC='net-setup.sh'
  149. NWCHOICE="Dougal's Network Wizard"
  150. ;;
  151. FLAGNETWIZCLASSIC) #net_wiz_classic
  152. /usr/sbin/net_wiz_classic > /dev/null 2>&1
  153. NWEXEC='net_wiz_classic'
  154. NWCHOICE="Barry's Network Wizard Classic"
  155. ;;
  156. FLAGSNS)
  157. /usr/sbin/sns
  158. NWEXEC='sns'
  159. NWCHOICE="Barry's Simple Network Setup"
  160. ;;
  161. esac
  162. IFSUP="`ifconfig | grep -E '^eth|^wlan'`"
  163. if [ "$IFSUP" != "" ];then
  164. IFSUP="`echo "$IFSUP" | cut -f 1 -d ' ' | tr '\n' ' '`"
  165. MSG1="$(gettext 'These interfaces are active:')
  166. <b>${IFSUP}</b>
  167. `gettext \"...Satisfied? Got online ok? If yes, click <u>Set as default</u> button, so Puppy will be optimised to use this tool for future boots.\"`"
  168. else
  169. MSG1="`gettext \"No interfaces are active, so was the tool unsatisfactory? If it actually was ok, click the <u>Set as default</u> button. But, it seems not, so...\"`"
  170. fi
  171. CURREXEC="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  172. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && CURREXEC='pgprs-connect'
  173. [ "$CURREXEC" = "gkdial" ] && CURREXEC="pupdial" #for older pups.
  174. case $CURREXEC in
  175. Pwireless2)
  176. CURRCHOICE="Jemimah's Pwireless2"
  177. ;;
  178. frisbee) #121029 130103
  179. CURRCHOICE="Jemimah's Frisbee"
  180. ;;
  181. net-setup.sh)
  182. CURRCHOICE="Dougal's Network Wizard"
  183. ;;
  184. net_wiz_classic)
  185. CURRCHOICE="Barry's Network Wizard Classic"
  186. ;;
  187. sns)
  188. CURRCHOICE="Barry's Simple Network Setup"
  189. ;;
  190. *)
  191. CURRCHOICE="${CURREXEC}"
  192. ;;
  193. esac
  194. [ "$NWEXEC" = "$CURREXEC" ] && exit
  195. # <text><label>Note, the current default network tool is '${CURRCHOICE}'.</label></text>
  196. export Network_Connection_Wizard='
  197. <window title="'$(gettext 'Network Connection Wizard')'" icon-name="gtk-connect">
  198. <vbox space-expand="true" space-fill="true">
  199. '"`/usr/lib/gtkdialog/xml_info fixed network_connect.svg 60 "$(gettext 'You have finished running')" "<b>${NWCHOICE}</b>"`"'
  200. <vbox space-expand="true" space-fill="true">
  201. <frame>
  202. '"`/usr/lib/gtkdialog/xml_pixmap dialog-question.svg popup`"'
  203. <text use-markup="true"><label>"'${MSG1}'
  204. <u>'$(gettext "Try a different tool")'</u> '$(gettext "if you would like to try one of the other network setup tools...")'"</label></text>
  205. </frame>
  206. <hbox space-expand="false" space-fill="false">
  207. <button space-expand="false" space-fill="false">
  208. '"`/usr/lib/gtkdialog/xml_button-icon refresh`"'
  209. <label>'$(gettext 'Try a different tool')'</label>
  210. <action type="exit">FLAGTRYDIFF</action>
  211. </button>
  212. <text space-expand="true" space-fill="true"><label>""</label></text>
  213. <button space-expand="false" space-fill="false">
  214. <label>'$(gettext "Cancel")'</label>
  215. '"`/usr/lib/gtkdialog/xml_button-icon cancel`"'
  216. <action>exit:Cancel</action>
  217. </button>
  218. <button>
  219. '"`/usr/lib/gtkdialog/xml_button-icon apply`"'
  220. <label>'$(gettext 'Set as default')'</label>
  221. <action type="exit">FLAGYES</action>
  222. </button>
  223. </hbox>
  224. </vbox>
  225. </vbox>
  226. </window>'
  227. RETSTRING="`gtkdialog -p Network_Connection_Wizard --center`"
  228. if [ "`echo "$RETSTRING" | grep '^EXIT' | grep 'FLAG'`" != "" ];then
  229. CHOSENACTION="`echo "$RETSTRING" | grep '^EXIT' | grep 'FLAG' | cut -f 2 -d '"'`" #'geany
  230. case $CHOSENACTION in
  231. FLAGYES)
  232. echo -e "#!/bin/sh\nexec ${NWEXEC}" > /usr/local/bin/defaultconnect
  233. echo "<b>${NWCHOICE} $(gettext "now set as default network tool.</b>
  234. Here are some technical notes that you might find useful:
  235. The default network tool is specified in file /usr/local/bin/defaultconnect, and if you were to look in that file now you will see that it contains '${NWEXEC}'. If you ever wanted to manually change that back to the original setting, you could edit the file and in place of '${NWEXEC}' put 'connectwizard'.
  236. If you click on the 'connect' icon on the desktop, it will directly start the '${NWEXEC}' tool. In fact, it starts whatever has been specified in /usr/local/bin/defaultconnect. You can right-click on the 'connect' icon for a menu with other run options.
  237. <b>Geek stuff</b>: If you really want to know in-depth about the inner workings, specifically how the default tool is activated at bootup, look in /etc/rc.d/rc.sysinit. Two other relevant scripts are /usr/sbin/connectwizard and /usr/sbin/connectwizard_2nd.")" > /tmp/box_help
  238. /usr/lib/gtkdialog/box_help "$(gettext 'Network Connection Wizard')" info.svg &
  239. ;;
  240. FLAGTRYDIFF)
  241. echo -e '#!/bin/sh\nexec connectwizard' > /usr/local/bin/defaultconnect
  242. exec connectwizard
  243. ;;
  244. esac
  245. fi
  246. fi
  247. ###END###