s243a

/usr/sbin/defaultconnect (puppylinux -- precise 5.7.1)

Apr 28th, 2015
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 13.35 KB | None | 0 0
  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.  
  27. export TEXTDOMAIN=connectwizard
  28. export OUTPUT_CHARSET=UTF-8
  29.  
  30. GTKDIALOGEXE="gtkdialog"
  31. [ "`which gtkdialog4`" ] && GTKDIALOGEXE="gtkdialog4"
  32.  
  33. #v411 commandline param, this section irrelevant...
  34. DEFAULTCONNECT="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  35. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && DEFAULTCONNECT='pgprs-connect'
  36. [ "$DEFAULTCONNECT" = "gkdial" ] && DEFAULTCONNECT="pupdial" #for older pups.
  37. #radiobuttons...
  38. DEFGNOMEPPP="no"
  39. DEFPUPDIAL="no"
  40. DEFRPPPPOE="no"
  41. DEFMTGPRS="no"
  42. DEFICW="no"
  43. DEFPPPOECONF="no" #v409
  44. DEFPWIRELESS="no" #100227
  45. DEFFRISBEE="no" #120823
  46. DEFNETWIZCLASSIC="no" #100227
  47. DEFNETWIZARD="no" #100227
  48. DEFSNS="no" #100310
  49. case $DEFAULTCONNECT in
  50.  gnome-ppp)
  51.   DEFGNOMEPPP="yes"
  52.   ;;
  53.  pupdial)
  54.   DEFPUPDIAL="yes"
  55.   ;;
  56.  pppoe_gui)
  57.   DEFRPPPPOE="yes"
  58.   ;;
  59.  pgprs-connect)
  60.   DEFMTGPRS="yes"
  61.   ;;
  62.  pppoeconf) #v409
  63.   DEFPPPOECONF="yes"
  64.   ;;
  65.  Pwireless2) #100227
  66.   DEFPWIRELESS="yes"
  67.   ;;
  68.  frisbee) #120823 130111
  69.   DEFFRISBEE="yes"
  70.   ;;
  71.  net_wiz_classic) #100227
  72.   DEFNETWIZCLASSIC="yes"
  73.   ;;
  74.  net-setup.sh) #100227
  75.   DEFNETWIZARD="yes"
  76.   ;;
  77.  sns) #100310 Simple Network Setup.
  78.   DEFSNS="yes"
  79.   ;;
  80.  *)
  81.   DEFICW="yes"
  82.   ;;
  83. esac
  84.  
  85. #101002 rerwin: Wait for initialization scripts to complete... 101122 breakout.
  86. BRKCNT=0 ; BRKPID=0
  87. while [ "`ps aux | grep 'rc.services' | grep -v 'grep'`" != "" ];do
  88.  if [ $BRKCNT -eq 1 ];then
  89.   yaf-splash -bg orange -placement center -close never -fontsize large -text "Please wait..." &
  90.   BRKPID=$! #120823
  91.  fi
  92.  sleep 1
  93.  BRKCNT=$(($BRKCNT + 1))
  94.  [ $BRKCNT -gt 10 ] && break
  95. done
  96. [ $BRKPID -ne 0 ] && kill $BRKPID
  97.  
  98. #v405
  99. MSGNETIFS="`gettext 'No network interfaces detected'`"
  100. M_if1=$(gettext 'Available network interfaces:')
  101. SHOWNETIFS="`ls -1 /sys/class/net | grep -v -E '^lo|^wmaster' | tr '\n' ' '`"
  102. if [ `echo -n "$SHOWNETIFS" | wc -w` -gt 0 ];then
  103.  MSGNETIFS="${M_if1} $SHOWNETIFS"
  104. fi
  105.  
  106. #v433...
  107. MSGMODEM="`gettext 'No dialup modem detected'`"
  108. M_m1=$(gettext 'Dialup modem detected at port')
  109. M_m2a=$(gettext 'Dialup modem at port')
  110. M_m2b=$(gettext 'not found')
  111. if [ -h /dev/modem ];then
  112.  DEVMODEM="`readlink /dev/modem`"
  113.  if [ -e /dev/modem ];then
  114.   MSGMODEM="${M_m1} $DEVMODEM"
  115.  else
  116.   MSGMODEM="${M_m2a} $DEVMODEM ${M_m2b}"
  117.  fi
  118. fi
  119.  
  120. FLAGGNOMEPPP=""
  121. M_ppp1=$(gettext 'GnomePPP (modem dialup)')
  122. if [ ! "`which gnome-ppp`" = "" ];then
  123.  FLAGGNOMEPPP="<radiobutton><label>${M_ppp1}</label><variable>RADIOGNOMEPPP</variable><default>$DEFGNOMEPPP</default></radiobutton>"
  124. fi
  125.  
  126. FLAGROARINGPENGUIN=""
  127. CONNECTROARINGPENGUIN="" #v409
  128. M_rp1=$(gettext 'Roaring Penguin (PPPoE)')
  129. M_rp2=$(gettext "'Roaring Penguin' PPPOE:")
  130. if [ "`which pppoe_gui`" != "" ];then
  131.  FLAGROARINGPENGUIN="<radiobutton><label>${M_rp1}</label><variable>RADIORPPPPOE</variable><default>$DEFRPPPPOE</default></radiobutton>"
  132.  CONNECTROARINGPENGUIN="<hbox>
  133.   <text>
  134.    <label>${M_rp2}</label>
  135.   </text>
  136.   <button>
  137.    <input file>/usr/local/lib/X11/mini-icons/mini-telnet.xpm</input>
  138.    <action>/usr/sbin/pppoe_gui &</action>
  139.    <action type=\"exit\">exit</action>
  140.   </button>
  141.  </hbox>" #v409
  142. fi
  143.  
  144. #v411...
  145. FLAGPPPOECONF=""
  146. CONNECTPPPOECONF=""
  147. M_pppoe1=$(gettext 'Pppoeconf (PPPOE)')
  148. M_pppoe2=$(gettext "'Pppoeconf' PPPOE:")
  149. if [ "`which pppoeconf`" != "" ];then
  150.  FLAGPPPOECONF="<radiobutton><label>${M_pppoe1}</label><variable>RADIOPPPOECONF</variable><default>$DEFPPPOECONF</default></radiobutton>"
  151.  CONNECTPPPOECONF="<hbox>
  152.   <text>
  153.    <label>${M_pppoe2}</label>
  154.   </text>
  155.   <button>
  156.    <input file>/usr/local/lib/X11/mini-icons/mini-telnet.xpm</input>
  157.    <action>/usr/sbin/pppoeconf &</action>
  158.    <action type=\"exit\">exit</action>
  159.   </button>
  160.  </hbox>"
  161. fi
  162.  
  163. #FLAGMTGPRS=""
  164. M_gprs1=$(gettext "GPRS Connect")
  165. M_gprs2=$(gettext "Wireless GPRS modem:")
  166. #if [ "`which pgprs-setup`" != "" ];then
  167.  CONNECTMTGPRS="  <hbox>
  168.   <text>
  169.    <label>${M_gprs2}</label>
  170.   </text>
  171.   <button>
  172.    <input file>/usr/local/lib/X11/mini-icons/Pwireless.png</input>
  173.    <action>/usr/sbin/pgprs-shell &</action>
  174.    <action type=\"exit\">exit</action>
  175.   </button>
  176.  </hbox>
  177. "
  178.  FLAGMTGPRS="<radiobutton><label>${M_gprs1}</label><variable>RADIOMTGPRS</variable><default>$DEFMTGPRS</default></radiobutton>"
  179. #fi
  180.  
  181. #v2.12 removed...
  182. #  <hbox>
  183. #   <text>
  184. #    <label>Connect to Internet by wireless interface...</label>
  185. #   </text>
  186. #   <button>
  187. #    <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input>
  188. #    <action>/usr/sbin/wirelesswizard &</action>
  189. #    <action>exit</action>
  190. #   </button>
  191. #  </hbox>
  192.  
  193. #   <button>
  194. #    <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input>
  195. #    <action>/usr/sbin/modem-wizard</action>
  196. #    <action>/usr/local/bin/gkdial &</action>
  197. #    <action>exit</action>
  198. #   </button>
  199.  
  200. #    <text>
  201. #     <label>$SHOWIPSTATE</label>
  202. #    </text>
  203.  
  204. M_pw1=$(gettext "Pwireless (wireless networking)")
  205. if [ -d /usr/local/Pwireless2 ];then #100227 Jemimah's wireless connection gui.
  206.  FLAGPWIRELESS="<radiobutton><label>${M_pw1}</label><variable>RADIOPWIRELESS</variable><default>$DEFPWIRELESS</default></radiobutton>"
  207. fi
  208.  
  209. M_fr1=$(gettext "Frisbee (wireless networking)")
  210. if [ -f /usr/local/bin/frisbee ];then #100227 121112 130111 Jemimah's wireless connection gui.
  211.  FLAGFRISBEE="<radiobutton><label>${M_fr1}</label><variable>RADIOFRISBEE</variable><default>$DEFFRISBEE</default></radiobutton>"
  212. fi
  213.  
  214. M_nwc1=$(gettext "Network Wizard Classic")
  215. if [ -f /usr/local/net_setup/usr/sbin/net-setup.sh ];then #100227 wizard used in older puppies.
  216.  FLAGNETWIZCLASSIC="<radiobutton><label>${M_nwc1}</label><variable>RADIONETWIZCLASSIC</variable><default>$DEFNETWIZCLASSIC</default></radiobutton>"
  217. fi
  218.  
  219. M_dnw1=$(gettext "Dougal's Network Wizard")
  220. if [ -f /usr/sbin/net-setup.sh ];then #100227 wizard developed by Dougal.
  221.  FLAGNETWIZARD="<radiobutton><label>${M_dnw1}</label><variable>RADIONETWIZARD</variable><default>$DEFNETWIZARD</default></radiobutton>"
  222. fi
  223.  
  224. M_sns1=$(gettext "Simple Network Setup")
  225. if [ -d /usr/local/simple_network_setup ];then #100310
  226.  FLAGSNS="<radiobutton><label>${M_sns1}</label><variable>RADIOSNS</variable><default>$DEFSNS</default></radiobutton>"
  227. fi
  228.  
  229. #v411...
  230. M_dt1=$(gettext "Desktop/tray")
  231. M_dt2=$(gettext "What you choose here will start immediately next time you click the 'connect' icon:")
  232. M_md1=$(gettext "PupDial (modem dialup)")
  233. M_icw1=$(gettext "Internet Connection Wizard")
  234. CHOOSEDEFAULT="<frame ${M_dt1}>
  235.  <vbox>
  236.  <text><label>${M_dt2}</label></text>
  237.   $FLAGGNOMEPPP
  238.   <radiobutton><label>${M_md1}</label><variable>RADIOPUPDIAL</variable><default>$DEFPUPDIAL</default></radiobutton>
  239.   $FLAGPPPOECONF
  240.   $FLAGROARINGPENGUIN
  241.   $FLAGMTGPRS
  242.   $FLAGPWIRELESS
  243.   $FLAGFRISBEE
  244.   $FLAGNETWIZCLASSIC
  245.   $FLAGNETWIZARD
  246.   $FLAGSNS
  247.   <radiobutton><label>${M_icw1}</label><variable>RADIOICW</variable><default>$DEFICW</default></radiobutton>
  248.  </vbox>
  249. </frame>"
  250. [ $1 ] && CHOOSEDEFAULT=""
  251.  
  252. M_h0=$(gettext 'Change hostname:')
  253. M_h1=$(gettext 'Type your computer name to identify in the network. Alpha-numeric without spaces. Then click button to apply the change.')
  254. M_h2=$(gettext "Your computer has been assigned a unique name, known as the 'hostname', by which it identifies itself on a network. However, you might wish to change that to a name that is more meaningful to yourself, such as 'johnsmithpc'. The hostname can have letters and numbers, no spaces.")
  255. M_h3=$(gettext 'Click button to apply hostname')
  256. M_icw2=$(gettext "Current setup/status")
  257. M_icw3=$(gettext "Detailed network interface Information:")
  258. M_icw4=$(gettext "Connect to Internet by")
  259. M_icw5=$(gettext "Dialup analog or wireless modem:")
  260. M_icw6=$(gettext "Wired or wireless LAN:")
  261. M_icw7=$(gettext "Setup a firewall:")
  262. M_icw8=$(gettext "Setup a proxy server:")
  263. M_help1=$(gettext "HELP")
  264. M_help2=$(gettext "MORE HELP")
  265.  
  266. HOSTNAME="`cat /etc/hostname`" #111106 do not use $HOSTNAME, as hostname-set may have just been run.
  267.  
  268. export InternetConnectionWizard="<window title=\"${M_icw1}\" icon-name=\"gtk-connect\" resizable=\"false\">
  269. <vbox>
  270. <hbox>
  271. <vbox>
  272. <frame ${M_icw2}>
  273.    <text><label>$MSGMODEM</label></text>
  274.    <text><label>$MSGNETIFS</label></text>
  275.    <hbox>
  276.      <text><label>${M_icw3}</label></text>
  277.      <button><input file>/usr/local/lib/X11/mini-icons/info16.xpm</input><action>ipinfo & </action></button>
  278.    </hbox>
  279. </frame>
  280. <frame ${M_icw4}>
  281.  <hbox>
  282.   <text>
  283.    <label>${M_icw5}</label>
  284.   </text>
  285.   <button>
  286.    <input file>/usr/local/lib/X11/mini-icons/phone16.xpm</input>
  287.    <action>/usr/sbin/pupdial & </action>
  288.    <action type=\"exit\">true_exit</action>
  289.   </button>
  290.  </hbox>
  291.  <hbox>
  292.   <text>
  293.    <label>${M_icw6}</label>
  294.   </text>
  295.   <button>
  296.    <input file>/usr/local/lib/X11/mini-icons/pc-2x.xpm</input>
  297.    <action>/usr/sbin/connectwizard_2nd & </action>
  298.    <action type=\"exit\">true_exit</action>
  299.   </button>
  300.  </hbox>
  301.  
  302.  ${CONNECTMTGPRS}
  303.  
  304.  ${CONNECTPPPOECONF}
  305.  
  306.  ${CONNECTROARINGPENGUIN}
  307.  
  308. </frame>
  309. </vbox>
  310. <vbox>
  311. <frame $(gettext 'Tools')>
  312.  
  313.  <hbox>
  314.   <text>
  315.    <label>${M_icw7}</label>
  316.   </text>
  317.   <button>
  318.    <input file>/usr/local/lib/X11/mini-icons/mini-firewall.xpm</input>
  319.    <action>rxvt -e /usr/sbin/firewallinstallshell &</action>
  320.    <action type=\"exit\">exit</action>
  321.   </button>
  322.  </hbox>
  323.  
  324.  <hbox>
  325.   <text>
  326.    <label>${M_icw8}</label>
  327.   </text>
  328.   <button>
  329.    <input file>/usr/local/lib/X11/mini-icons/mini-proxy.xpm</input>
  330.    <action>/usr/local/simple_network_setup/proxy-setup &</action>
  331.    <action type=\"exit\">exit</action>
  332.   </button>
  333.  </hbox>
  334.  
  335.  <hbox>
  336.   <text><label>${M_h0}</label></text>
  337.   <entry tooltip-text=\"${M_h1}\" width-chars=\"15\">
  338.   <input>echo -n \"$HOSTNAME\"</input><variable>ENTRY_HOSTNAME</variable></entry>
  339.   <button tooltip-text=\"${M_h3}\">
  340.    <input file>/usr/local/lib/X11/mini-icons/mini-hostname.xpm</input>
  341.    <action>/usr/sbin/hostname-set \$ENTRY_HOSTNAME</action>
  342.   </button>
  343.  </hbox>
  344.  
  345. </frame>
  346.  
  347. ${CHOOSEDEFAULT}
  348.  
  349. </vbox>
  350. </hbox>
  351.  
  352.  <hbox>
  353.   <button>
  354.    <label>${M_help1}</label>
  355.    <action>/usr/local/apps/Connect/connect_help & </action>
  356.   </button>
  357.   <button>
  358.    <label>${M_help2}</label>
  359.    <action>/usr/local/bin/defaulthtmlviewer file:///usr/share/doc/HOWTO_Internet.htm &</action>
  360.   </button>
  361.   <button ok></button>
  362.  </hbox>
  363.  
  364. </vbox>
  365. </window>"
  366.  
  367. #RETSTR="`echo "$WizardWizard" | gtkdialog2 --stdin`"
  368. #gtkdialog --program=WizardWizard
  369. RETSTR="`${GTKDIALOGEXE} --program=InternetConnectionWizard --center`"
  370.  
  371. [ $1 ] && exit #v411
  372. [ "`echo "$RETSTR" | grep 'true_exit'`" != "" ] && exit #100412 after return from sns. 100902 and pupdial.
  373.  
  374. RADIOBUT="`echo "$RETSTR" | grep '^RADIO' | grep '"true"' | cut -f 1 -d '='`"
  375. [ "$RADIOBUT" = "RADIOGNOMEPPP" ] && echo -e '#!/bin/sh\nexec gnomepppshell' > /usr/local/bin/defaultconnect
  376. [ "$RADIOBUT" = "RADIOPUPDIAL" ] && echo -e '#!/bin/sh\nexec pupdial' > /usr/local/bin/defaultconnect
  377. [ "$RADIOBUT" = "RADIORPPPPOE" ] && echo -e '#!/bin/sh\nexec pppoe_gui' > /usr/local/bin/defaultconnect
  378. [ "$RADIOBUT" = "RADIOMTGPRS" ] && echo -e '#!/bin/sh\nexec rxvt -title "pgprs-connect PRESS CTRL+C TO DISCONNECT" -e pgprs-connect' > /usr/local/bin/defaultconnect
  379. [ "$RADIOBUT" = "RADIOICW" ] && echo -e '#!/bin/sh\nexec connectwizard' > /usr/local/bin/defaultconnect
  380. [ "$RADIOBUT" = "RADIOPPPOECONF" ] && echo -e '#!/bin/sh\nexec pppoeconf' > /usr/local/bin/defaultconnect #v409
  381. [ "$RADIOBUT" = "RADIOPWIRELESS" ] && echo -e '#!/bin/sh\nexec Pwireless2' > /usr/local/bin/defaultconnect #100227
  382. [ "$RADIOBUT" = "RADIOFRISBEE" ] && echo -e '#!/bin/sh\nexec frisbee' > /usr/local/bin/defaultconnect #120823 130111
  383. [ "$RADIOBUT" = "RADIONETWIZCLASSIC" ] && echo -e '#!/bin/sh\nexec net_wiz_classic' > /usr/local/bin/defaultconnect #100227
  384. [ "$RADIOBUT" = "RADIONETWIZARD" ] && echo -e '#!/bin/sh\nexec net-setup.sh' > /usr/local/bin/defaultconnect #100227
  385. [ "$RADIOBUT" = "RADIOSNS" ] && echo -e '#!/bin/sh\nexec sns' > /usr/local/bin/defaultconnect #100227
  386.  
  387. if [ "$FLAGFRISBEE" ];then #130111 precaution...
  388.  echo -n "$RADIOBUT" | grep -q -E 'CW$|FRISBEE|PUPDIAL|MTGPRS' \
  389.   || frisbee_mode_disable
  390. fi
  391.  
  392. ###end###
Advertisement
Add Comment
Please, Sign In to add comment