<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zigi004</id>
	<title>WebOS Internals - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zigi004"/>
	<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/wiki/Special:Contributions/Zigi004"/>
	<updated>2026-04-15T05:57:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21881</id>
		<title>Advanced Wifi/wrapper</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21881"/>
		<updated>2012-11-06T11:10:21Z</updated>

		<summary type="html">&lt;p&gt;Zigi004: changed formatting so sed [[ expressions would not get mangled&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This shell wrapper around wpa_supplicant inject custom wifi settings into running wpa_supplicant.&lt;br /&gt;
More informations about topic can be found at [[Advanced_Wifi]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
## This is wrapper around wpa_supplicant binary.&lt;br /&gt;
##&lt;br /&gt;
## version 0.0.1 proof of concept&lt;br /&gt;
## no responsibility, no warranty, works for me (Veer 8G, WebOS 2.1.2), YMMV&lt;br /&gt;
##&lt;br /&gt;
## author: Matej Zagiba&lt;br /&gt;
## license: any version of GPL&lt;br /&gt;
##&lt;br /&gt;
## Installation and usage:&lt;br /&gt;
## 1. turn off wifi&lt;br /&gt;
## 2. connect to Your WebOS device and copy original binary file:&lt;br /&gt;
##    # cp /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant.real&lt;br /&gt;
## 3. put this file on wpa_supplicant's place and rename it:&lt;br /&gt;
##    # cp /media/internal/wpa_supplicant.wrapper /usr/sbin/wpa_supplicant&lt;br /&gt;
## 4. put customized config in /media/internal/.wpa_supplicant.conf&lt;br /&gt;
##    or any other convenient place. Remember - passwords are stored&lt;br /&gt;
##    in that file. Update configuration file location in WPA_CONFIG variable&lt;br /&gt;
## 5. from http://packages.debian.org/wheezy/wpasupplicant download package&lt;br /&gt;
##    with correct architecture (HP veer uses armel) extract wpa_cli binary&lt;br /&gt;
##    and copy it in place e.g.:&lt;br /&gt;
##    # cp /media/internal/wpa_cli /usr/sbin&lt;br /&gt;
## 6. correct permisions:&lt;br /&gt;
##    # chmod 755 /usr/sbin/wpa_supplicant /usr/sbin/wpa_cli&lt;br /&gt;
##&lt;br /&gt;
## Installation is now completed&lt;br /&gt;
##&lt;br /&gt;
## All networks defined in original wifi application will continue working&lt;br /&gt;
## and can be managed through original interface. Network settings in custom&lt;br /&gt;
## config file will overwrite definitions in built-in application.&lt;br /&gt;
## So for any configuration change in custom networks edit configuration&lt;br /&gt;
## file by Your favorite editor&lt;br /&gt;
##&lt;br /&gt;
## To use it:&lt;br /&gt;
## - first define new network(s) in the configuration file,&lt;br /&gt;
##   use any option You wish, use wpa_supplicant config file format:&lt;br /&gt;
##     every option on single line&lt;br /&gt;
##     &amp;quot;network={&amp;quot; and &amp;quot;}&amp;quot; and comment also on single line,&lt;br /&gt;
##   best way for now is to export settings from another system&lt;br /&gt;
## - then turn on wifi&lt;br /&gt;
## - from WiFi Preferences applet select &amp;quot;Join network&amp;quot; and enter name of the network&lt;br /&gt;
##   You just configured, select security type - Open&lt;br /&gt;
## - Enjoy new wifi connection&lt;br /&gt;
## - If there are more than one network in the area, pease turn wifi off and on between&lt;br /&gt;
##   each new network definition in GUI&lt;br /&gt;
&lt;br /&gt;
WPA_CONFIG=&amp;quot;/media/internal/.wpa_supplicant.conf&amp;quot;&lt;br /&gt;
WPA_CLI=&amp;quot;/usr/sbin/wpa_cli&amp;quot;&lt;br /&gt;
&lt;br /&gt;
## no user editable settings belove here&lt;br /&gt;
OIFS=&amp;quot;$IFS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
## define functions&lt;br /&gt;
&lt;br /&gt;
merge_wifi_settings ()&lt;br /&gt;
{&lt;br /&gt;
  IFS=&amp;quot;&lt;br /&gt;
&amp;quot;&lt;br /&gt;
  READING_NETWORK=0&lt;br /&gt;
&lt;br /&gt;
  # read and apply user configuration&lt;br /&gt;
  #&lt;br /&gt;
  for LINE_IN in `cat &amp;quot;$WPA_CONFIG&amp;quot;`; do&lt;br /&gt;
    IFS=&amp;quot;$OIFS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # get rid of leading and trailing blanks and remove comments&lt;br /&gt;
    LINE_IN=`sed -e &amp;quot;s/^[[:space:]]*//&amp;quot; -e &amp;quot;s/[[:space:]]*$//&amp;quot; -e &amp;quot;s/^#.*$//&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
$LINE_IN`&lt;br /&gt;
&lt;br /&gt;
    # skip empty lines&lt;br /&gt;
    [ &amp;quot;o$LINE_IN&amp;quot; = &amp;quot;o&amp;quot; ] &amp;amp;&amp;amp; continue&lt;br /&gt;
&lt;br /&gt;
    OPTION=&amp;quot;${LINE_IN%%=*}&amp;quot;&lt;br /&gt;
    VALUE=&amp;quot;${LINE_IN#*=}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$LINE_IN&amp;quot; in&lt;br /&gt;
        # start of network block&lt;br /&gt;
	&amp;quot;network={&amp;quot;*)&lt;br /&gt;
		READING_NETWORK=1&lt;br /&gt;
		;;&lt;br /&gt;
	# SSID of the network, fun starts here&lt;br /&gt;
	# we expect ssid to be first thing set in network block&lt;br /&gt;
	&amp;quot;ssid=&amp;quot;*)&lt;br /&gt;
		NET_SSID=&amp;quot;${VALUE#\&amp;quot;}&amp;quot;&lt;br /&gt;
		NET_SSID=&amp;quot;${NET_SSID%\&amp;quot;}&amp;quot;&lt;br /&gt;
		# is such a network allready know by wpa_supplicant?&lt;br /&gt;
		NET_ENTRY=`$WPA_CLI list_networks | grep &amp;quot;$NET_SSID&amp;quot;`&lt;br /&gt;
		if [ &amp;quot;o$NET_ENTRY&amp;quot; = &amp;quot;o&amp;quot; ]; then&lt;br /&gt;
		  # skipp this network, until it's configured via GUI&lt;br /&gt;
		  READING_NETWORK=0&lt;br /&gt;
		else&lt;br /&gt;
		  NET_ID=&amp;quot;${NET_ENTRY%%	*}&amp;quot;&lt;br /&gt;
		  NET_STATUS=&amp;quot;${NET_ENTRY##*	}&amp;quot;&lt;br /&gt;
		  # are we connected to this network?&lt;br /&gt;
		  if [ &amp;quot;o$NET_STATUS&amp;quot; = 'o[CURRENT]' ]; then&lt;br /&gt;
		    # if yes, no need to reconfigure wpa_supplicant&lt;br /&gt;
		    READING_NETWORK=0&lt;br /&gt;
		  else&lt;br /&gt;
		    # if no, we disable network to be able modify setting&lt;br /&gt;
		    &amp;quot;$WPA_CLI&amp;quot; &amp;quot;DISABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
		  fi&lt;br /&gt;
		fi&lt;br /&gt;
		;;&lt;br /&gt;
	# end of network block - enable network, if needed and reset variables&lt;br /&gt;
	&amp;quot;}&amp;quot;)&lt;br /&gt;
		if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
		  &amp;quot;$WPA_CLI&amp;quot; &amp;quot;ENABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
		fi&lt;br /&gt;
		READING_NETWORK=0&lt;br /&gt;
		unset NET_ENTRY NET_ID NET_STATUS OPTION VALUE&lt;br /&gt;
		;;&lt;br /&gt;
	# update current option if reading network definition&lt;br /&gt;
	*)&lt;br /&gt;
		if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
		fi&lt;br /&gt;
		;;&lt;br /&gt;
    esac&lt;br /&gt;
  done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
## PmWiFiService will send SIGKILL to wpa_supplicant process, which could&lt;br /&gt;
## leave wpa_supplicant.real running and cause problems later.&lt;br /&gt;
## so we do some magic with processes...&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SETUP-WAIT-AND-CLEANUP&amp;quot; ]; then&lt;br /&gt;
  shift&lt;br /&gt;
&lt;br /&gt;
  ##just to be sure&lt;br /&gt;
  if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
    &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
  else&lt;br /&gt;
    pkill wpa_supplicant&lt;br /&gt;
  fi&lt;br /&gt;
&lt;br /&gt;
  # SET UP THINGS&lt;br /&gt;
  if [ -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
    echo &amp;quot;&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
    echo &amp;quot;update_config=1&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
    /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
    merge_wifi_settings&lt;br /&gt;
  else&lt;br /&gt;
    /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
  fi&lt;br /&gt;
&lt;br /&gt;
  /usr/sbin/wpa_supplicant --SLEEP-AND-UPDATE &amp;amp;&lt;br /&gt;
&lt;br /&gt;
  # WAIT&lt;br /&gt;
  wait&lt;br /&gt;
  # and CLEAN UP&lt;br /&gt;
  if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
    &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
  else&lt;br /&gt;
    pkill wpa_supplicant&lt;br /&gt;
  fi&lt;br /&gt;
  rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SLEEP-AND-UPDATE&amp;quot; ]; then&lt;br /&gt;
  # check some basic stuff - is there executable wpa_cli?&lt;br /&gt;
  # and does user configuration exists?&lt;br /&gt;
  if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
    ## - can we reach wpa_supplicant?&lt;br /&gt;
    &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?&lt;br /&gt;
&lt;br /&gt;
    while true; do&lt;br /&gt;
      sleep 5&lt;br /&gt;
      merge_wifi_settings&lt;br /&gt;
    done&lt;br /&gt;
  else&lt;br /&gt;
    # we still want to be here and do nothing&lt;br /&gt;
    # just waiting to be killed by PmWiFiService ...&lt;br /&gt;
    while true; do&lt;br /&gt;
      sleep 30&lt;br /&gt;
    done&lt;br /&gt;
  fi&lt;br /&gt;
elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--UPDATE&amp;quot; ]; then&lt;br /&gt;
  # check some basic stuff - is there executable wpa_cli?                            &lt;br /&gt;
  # and does user configuration exists?                                              &lt;br /&gt;
  if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then                                     &lt;br /&gt;
    ## - can we reach wpa_supplicant?                                                &lt;br /&gt;
    &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?                                          &lt;br /&gt;
&lt;br /&gt;
    merge_wifi_settings&lt;br /&gt;
  fi&lt;br /&gt;
else&lt;br /&gt;
  rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
  ln -s /usr/sbin/wpa_supplicant /tmp/.wpa_supplicant.tmp&lt;br /&gt;
  exec /tmp/.wpa_supplicant.tmp --SETUP-WAIT-AND-CLEANUP &amp;quot;$@&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--[[User:Zigi004|Zigi004]] 03:10, 6 November 2012 (PST)&lt;/div&gt;</summary>
		<author><name>Zigi004</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21879</id>
		<title>Advanced Wifi/wrapper</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21879"/>
		<updated>2012-11-06T10:22:06Z</updated>

		<summary type="html">&lt;p&gt;Zigi004: changes to the script missing $ corrected...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This shell wrapper around wpa_supplicant inject custom wifi settings into running wpa_supplicant.&lt;br /&gt;
More informations about topic can be found at [[Advanced_Wifi]] page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
  &lt;br /&gt;
 ## This is wrapper around wpa_supplicant binary.&lt;br /&gt;
 ##&lt;br /&gt;
 ## version 0.0.1 proof of concept&lt;br /&gt;
 ## no responsibility, no warranty, works for me (Veer 8G, WebOS 2.1.2), YMMV&lt;br /&gt;
 ##&lt;br /&gt;
 ## author: Matej Zagiba&lt;br /&gt;
 ## license: any version of GPL&lt;br /&gt;
 ##&lt;br /&gt;
 ## Installation and usage:&lt;br /&gt;
 ## 1. turn off wifi&lt;br /&gt;
 ## 2. connect to Your WebOS device and copy original binary file:&lt;br /&gt;
 ##    # cp /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant.real&lt;br /&gt;
 ## 3. put this file on wpa_supplicant's place and rename it:&lt;br /&gt;
 ##    # cp /media/internal/wpa_supplicant.wrapper /usr/sbin/wpa_supplicant&lt;br /&gt;
 ## 4. put customized config in /media/internal/.wpa_supplicant.conf&lt;br /&gt;
 ##    or any other convenient place. Remember - passwords are stored&lt;br /&gt;
 ##    in that file. Update configuration file location in WPA_CONFIG variable&lt;br /&gt;
 ## 5. from http://packages.debian.org/wheezy/wpasupplicant download package&lt;br /&gt;
 ##    with correct architecture (HP veer uses armel) extract wpa_cli binary&lt;br /&gt;
 ##    and copy it in place e.g.:&lt;br /&gt;
 ##    # cp /media/internal/wpa_cli /usr/sbin&lt;br /&gt;
 ## 6. correct permisions:&lt;br /&gt;
 ##    # chmod 755 /usr/sbin/wpa_supplicant /usr/sbin/wpa_cli&lt;br /&gt;
 ##&lt;br /&gt;
 ## Installation is now completed&lt;br /&gt;
 ##&lt;br /&gt;
 ## All networks defined in original wifi application will continue working&lt;br /&gt;
 ## and can be managed through original interface. Network settings in custom&lt;br /&gt;
 ## config file will overwrite definitions in built-in application.&lt;br /&gt;
 ## So for any configuration change in custom networks edit configuration&lt;br /&gt;
 ## file by Your favorite editor&lt;br /&gt;
 ##&lt;br /&gt;
 ## To use it:&lt;br /&gt;
 ## - first define new network(s) in the configuration file,&lt;br /&gt;
 ##   use any option You wish, use wpa_supplicant config file format:&lt;br /&gt;
 ##     every option on single line&lt;br /&gt;
 ##     &amp;quot;network={&amp;quot; and &amp;quot;}&amp;quot; and comment also on single line,&lt;br /&gt;
 ##   best way for now is to export settings from another system&lt;br /&gt;
 ## - then turn on wifi&lt;br /&gt;
 ## - from WiFi Preferences applet select &amp;quot;Join network&amp;quot; and enter name of the network&lt;br /&gt;
 ##   You just configured, select security type - Open&lt;br /&gt;
 ## - Enjoy new wifi connection&lt;br /&gt;
 ## - If there are more than one network in the area, pease turn wifi off and on between&lt;br /&gt;
 ##   each new network definition in GUI&lt;br /&gt;
 &lt;br /&gt;
 WPA_CONFIG=&amp;quot;/media/internal/.wpa_supplicant.conf&amp;quot;&lt;br /&gt;
 WPA_CLI=&amp;quot;/usr/sbin/wpa_cli&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## no user editable settings belove here&lt;br /&gt;
 OIFS=&amp;quot;$IFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## define functions&lt;br /&gt;
 &lt;br /&gt;
 merge_wifi_settings ()&lt;br /&gt;
 {&lt;br /&gt;
   IFS=&amp;quot;&lt;br /&gt;
 &amp;quot;&lt;br /&gt;
   READING_NETWORK=0&lt;br /&gt;
 &lt;br /&gt;
   # read and apply user configuration&lt;br /&gt;
   #&lt;br /&gt;
   for LINE_IN in `cat &amp;quot;$WPA_CONFIG&amp;quot;`; do&lt;br /&gt;
     IFS=&amp;quot;$OIFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     # get rid of leading and trailing blanks and remove comments&lt;br /&gt;
     LINE_IN=`sed -e &amp;quot;s/^[[:space:]]*//&amp;quot; -e &amp;quot;s/[[:space:]]*$//&amp;quot; -e &amp;quot;s/^#.*$//&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
 $LINE_IN`&lt;br /&gt;
 &lt;br /&gt;
     # skip empty lines&lt;br /&gt;
     [ &amp;quot;o$LINE_IN&amp;quot; = &amp;quot;o&amp;quot; ] &amp;amp;&amp;amp; continue&lt;br /&gt;
 &lt;br /&gt;
     OPTION=&amp;quot;${LINE_IN%%=*}&amp;quot;&lt;br /&gt;
     VALUE=&amp;quot;${LINE_IN#*=}&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     case &amp;quot;$LINE_IN&amp;quot; in&lt;br /&gt;
         # start of network block&lt;br /&gt;
 	&amp;quot;network={&amp;quot;*)&lt;br /&gt;
 		READING_NETWORK=1&lt;br /&gt;
 		;;&lt;br /&gt;
         # SSID of the network, fun starts here&lt;br /&gt;
         # we expect to ssid be first thing set in network block&lt;br /&gt;
 	&amp;quot;ssid=&amp;quot;*)&lt;br /&gt;
 		NET_SSID=&amp;quot;${VALUE#\&amp;quot;}&amp;quot;&lt;br /&gt;
 		NET_SSID=&amp;quot;${NET_SSID%\&amp;quot;}&amp;quot;&lt;br /&gt;
                 # is such a network allready know by wpa_supplicant?&lt;br /&gt;
 		NET_ENTRY=`$WPA_CLI list_networks | grep &amp;quot;$NET_SSID&amp;quot;`&lt;br /&gt;
 		if [ &amp;quot;o$NET_ENTRY&amp;quot; = &amp;quot;o&amp;quot; ]; then&lt;br /&gt;
 		  # skipp this network, until it'sconfigured via GUI&lt;br /&gt;
 		  READING_NETWORK=0&lt;br /&gt;
 		else&lt;br /&gt;
 		  NET_ID=&amp;quot;${NET_ENTRY%%	*}&amp;quot;&lt;br /&gt;
 		  NET_STATUS=&amp;quot;${NET_ENTRY##*	}&amp;quot;&lt;br /&gt;
                   # are we connected to this network?&lt;br /&gt;
                   if [ &amp;quot;o$NET_STATUS&amp;quot; = 'o[CURRENT]' ]; then&lt;br /&gt;
                     # yes, so no need to reconfigure wpa_supplicant&lt;br /&gt;
                     READING_NETWORK=0&lt;br /&gt;
                   else&lt;br /&gt;
                     # no, so we disable network to to be able modify setting&lt;br /&gt;
 		    &amp;quot;$WPA_CLI&amp;quot; &amp;quot;DISABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		  fi&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
         # end of network block - enable network, if needed and reset variables&lt;br /&gt;
 	&amp;quot;}&amp;quot;)&lt;br /&gt;
                 if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; &amp;quot;ENABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		READING_NETWORK=0&lt;br /&gt;
 		unset NET_ENTRY NET_ID NET_STATUS OPTION VALUE&lt;br /&gt;
 		;;&lt;br /&gt;
         # update current option if reading network definition&lt;br /&gt;
 	*)&lt;br /&gt;
 		if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
     esac&lt;br /&gt;
   done&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ## PmWiFiService will send SIGKILL to wpa_supplicant process, which could&lt;br /&gt;
 ## leave wpa_supplicant.real running and cause problems later.&lt;br /&gt;
 ## so we do some magic with processes...&lt;br /&gt;
 &lt;br /&gt;
 if [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SETUP-WAIT-AND-CLEANUP&amp;quot; ]; then&lt;br /&gt;
   shift&lt;br /&gt;
 &lt;br /&gt;
   ##just to be sure&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   # SET UP THINGS&lt;br /&gt;
   if [ -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
     echo &amp;quot;update_config=1&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
 echo &amp;quot;params: $@&amp;quot; &amp;gt;&amp;gt;/tmp/aaa_params&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
     merge_wifi_settings&lt;br /&gt;
   else&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   /usr/sbin/wpa_supplicant --SLEEP-AND-UPDATE &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
   # WAIT&lt;br /&gt;
   wait&lt;br /&gt;
   # and CLEAN UP&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
   rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
 &lt;br /&gt;
 elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SLEEP-AND-UPDATE&amp;quot; ]; then&lt;br /&gt;
   # check some basic stuff - is there executable wpa_cli?&lt;br /&gt;
   # and does user configuration exists?&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     ## - can we reach wpa_supplicant?&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?&lt;br /&gt;
 &lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 5&lt;br /&gt;
       merge_wifi_settings&lt;br /&gt;
     done&lt;br /&gt;
   else&lt;br /&gt;
     # we still want to be here and do nothing&lt;br /&gt;
     # just waiting to be killed by PmWiFiService ...&lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 30&lt;br /&gt;
     done&lt;br /&gt;
   fi&lt;br /&gt;
 elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--UPDATE&amp;quot; ]; then&lt;br /&gt;
   # check some basic stuff - is there executable wpa_cli?                            &lt;br /&gt;
   # and does user configuration exists?                                              &lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then                                     &lt;br /&gt;
     ## - can we reach wpa_supplicant?                                                &lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?                                          &lt;br /&gt;
 &lt;br /&gt;
     merge_wifi_settings&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   ln -s /usr/sbin/wpa_supplicant /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   exec /tmp/.wpa_supplicant.tmp --SETUP-WAIT-AND-CLEANUP &amp;quot;$@&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Zigi004|Zigi004]] 11:04, 1 November 2012 (PDT)&lt;/div&gt;</summary>
		<author><name>Zigi004</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21877</id>
		<title>Advanced Wifi/wrapper</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21877"/>
		<updated>2012-11-01T18:04:39Z</updated>

		<summary type="html">&lt;p&gt;Zigi004: some typos corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This shell wrapper around wpa_supplicant inject custom wifi settings into running wpa_supplicant.&lt;br /&gt;
More informations about topic can be found at [[Advanced_Wifi]] page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 ## This is wrapper around wpa_supplicant binary.&lt;br /&gt;
 ##&lt;br /&gt;
 ## version 0.0.1 proof of concept&lt;br /&gt;
 ## no responsibility, no warranty, works for me (Veer 8G, WebOS 2.1.2), YMMV&lt;br /&gt;
 ##&lt;br /&gt;
 ## author: Matej Zagiba&lt;br /&gt;
 ## license: any version of GPL&lt;br /&gt;
 ##&lt;br /&gt;
 ## Installation and usage:&lt;br /&gt;
 ## 1. turn off wifi&lt;br /&gt;
 ## 2. connect to Your WebOS device and copy original binary file:&lt;br /&gt;
 ##    # cp /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant.real&lt;br /&gt;
 ## 3. put this file on wpa_supplicant's place and rename it:&lt;br /&gt;
 ##    # cp /media/internal/wpa_supplicant.wrapper /usr/sbin/wpa_supplicant&lt;br /&gt;
 ## 4. put customized config in /media/internal/.wpa_supplicant.conf&lt;br /&gt;
 ##    or any other convenient place. Remember - passwords are stored&lt;br /&gt;
 ##    in that file. Update configuration file location in WPA_CONFIG variable&lt;br /&gt;
 ## 5. from http://packages.debian.org/wheezy/wpasupplicant download package&lt;br /&gt;
 ##    with correct architecture (HP veer uses armel) extract wpa_cli binary&lt;br /&gt;
 ##    and copy it in place e.g.:&lt;br /&gt;
 ##    # cp /media/internal/wpa_cli /usr/sbin&lt;br /&gt;
 ## 6. correct permisions:&lt;br /&gt;
 ##    # chmod 755 /usr/sbin/wpa_supplicant /usr/sbin/wpa_cli&lt;br /&gt;
 ##&lt;br /&gt;
 ## Installation is now completed&lt;br /&gt;
 ##&lt;br /&gt;
 ## All networks defined in original wifi application will continue working&lt;br /&gt;
 ## and can be managed through original interface. Network settings in custom&lt;br /&gt;
 ## config file will overwrite definitions in built-in application.&lt;br /&gt;
 ## So for any configuration change in custom networks edit configuration&lt;br /&gt;
 ## file by Your favorite editor&lt;br /&gt;
 ##&lt;br /&gt;
 ## To use it:&lt;br /&gt;
 ## - first define new network in the configuration file,&lt;br /&gt;
 ##   use any option You wish, use wpa_supplicant config file format:&lt;br /&gt;
 ##     every option on single line&lt;br /&gt;
 ##     &amp;quot;network={&amp;quot; and &amp;quot;}&amp;quot; and comment also on single line,&lt;br /&gt;
 ##   best way for now is to export settings from another system&lt;br /&gt;
 ## - then turn on wifi&lt;br /&gt;
 ## - from WiFi Preferences applet select &amp;quot;Join network&amp;quot; and enter name of the network&lt;br /&gt;
 ##   You just configured, select security type - Open&lt;br /&gt;
 ## - Enjoy new wifi connection&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 WPA_CONFIG=&amp;quot;/media/internal/.wpa_supplicant.conf&amp;quot;&lt;br /&gt;
 WPA_CLI=&amp;quot;/usr/sbin/wpa_cli&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## no user editable settings belove here&lt;br /&gt;
 OIFS=&amp;quot;$IFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## define functions&lt;br /&gt;
 &lt;br /&gt;
 merge_wifi_settings ()&lt;br /&gt;
 {&lt;br /&gt;
   IFS=&amp;quot;&lt;br /&gt;
 &amp;quot;&lt;br /&gt;
   READING_NETWORK=0&lt;br /&gt;
   UNKNOWN_NET=0&lt;br /&gt;
 &lt;br /&gt;
   # read and apply user configuration&lt;br /&gt;
   #&lt;br /&gt;
   for LINE_IN in `cat &amp;quot;$WPA_CONFIG&amp;quot;`; do&lt;br /&gt;
     IFS=&amp;quot;$OIFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     # get rid of leading and trailing blanks and remove comments&lt;br /&gt;
     LINE_IN=`sed -e &amp;quot;s/^[[:space:]]*//&amp;quot; -e &amp;quot;s/[[:space:]]*$//&amp;quot; -e &amp;quot;s/^#.*$//&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
 $LINE_IN`&lt;br /&gt;
 &lt;br /&gt;
     # skip empty lines&lt;br /&gt;
     [ &amp;quot;o$LINE_IN&amp;quot; = &amp;quot;o&amp;quot; ] &amp;amp;&amp;amp; continue&lt;br /&gt;
 &lt;br /&gt;
     OPTION=&amp;quot;${LINE_IN%%=*}&amp;quot;&lt;br /&gt;
     VALUE=&amp;quot;${LINE_IN#*=}&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     case &amp;quot;$LINE_IN&amp;quot; in&lt;br /&gt;
         # start of network block&lt;br /&gt;
 	&amp;quot;network={&amp;quot;*)&lt;br /&gt;
 		READING_NETWORK=1&lt;br /&gt;
 		;;&lt;br /&gt;
         # SSID of the network, fun starts here&lt;br /&gt;
         # we expect to ssid be first thing set in network block&lt;br /&gt;
 	&amp;quot;ssid=&amp;quot;*)&lt;br /&gt;
 		NET_SSID=&amp;quot;${VALUE#\&amp;quot;}&amp;quot;&lt;br /&gt;
 		NET_SSID=&amp;quot;${NET_SSID%\&amp;quot;}&amp;quot;&lt;br /&gt;
                 # is such a network allready know by wpa_supplicant?&lt;br /&gt;
 		NET_ENTRY=`$WPA_CLI list_networks | grep &amp;quot;$NET_SSID&amp;quot;`&lt;br /&gt;
 		if [ &amp;quot;o$NET_ENTRY&amp;quot; = &amp;quot;o&amp;quot; ]; then&lt;br /&gt;
 		  UNKNOWN_NET=1&lt;br /&gt;
 		  NET_ID=`&amp;quot;$WPA_CLI&amp;quot; ADD_NETWORK | tail -n1`&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		else&lt;br /&gt;
 		  NET_ID=&amp;quot;${NET_ENTRY%%	*}&amp;quot;&lt;br /&gt;
 		  NET_STATUS=&amp;quot;${NET_ENTRY##*	}&amp;quot;&lt;br /&gt;
                   # are we connected to this network?&lt;br /&gt;
                   if [ &amp;quot;o$NET_STATUS&amp;quot; = 'o[CURRENT]' ]; then&lt;br /&gt;
                     # yes, so no need to reconfigure wpa_supplicant&lt;br /&gt;
                     READING_NETWORK=0&lt;br /&gt;
                   else&lt;br /&gt;
                     # no, so we disable network to to be able modify setting&lt;br /&gt;
 		    &amp;quot;$WPA_CLI&amp;quot; &amp;quot;DISABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		  fi&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
         # end of network block - enable network, if needed and reset variables&lt;br /&gt;
 	&amp;quot;}&amp;quot;)&lt;br /&gt;
                 if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; &amp;quot;ENABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		READING_NETWORK=0&lt;br /&gt;
 		UNKNOWN_NET=0&lt;br /&gt;
 		unset NET_ENTRY NET_ID NET_STATUS OPTION VALUE&lt;br /&gt;
 		;;&lt;br /&gt;
         # update current option if reading network definition&lt;br /&gt;
 	*)&lt;br /&gt;
 		if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
     esac&lt;br /&gt;
   done&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ## PmWiFiService will send SIGKILL to wpa_supplicant process, which could&lt;br /&gt;
 ## leave wpa_supplicant.real running and cause problems later.&lt;br /&gt;
 ## so we do some magic with processes...&lt;br /&gt;
 &lt;br /&gt;
 if [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SETUP-WAIT-AND-CLEANUP&amp;quot; ]; then&lt;br /&gt;
   shift&lt;br /&gt;
   /usr/sbin/wpa_supplicant --SLEEP-AND-UPDATE &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
   ##just to be sure&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   # SET UP THINGS&lt;br /&gt;
   if [ -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
     echo &amp;quot;update_config=1&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
     merge_wifi_settings&lt;br /&gt;
   else&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   # WAIT&lt;br /&gt;
   wait&lt;br /&gt;
   # and CLEAN UP&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
     rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
 &lt;br /&gt;
 elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SLEEP-AND-UPDATE&amp;quot; ]; then&lt;br /&gt;
   # check some basic stuff - is there executable wpa_cli?&lt;br /&gt;
   # and does user configuration exists?&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     ## - can we reach wpa_supplicant?&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?&lt;br /&gt;
 &lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 5&lt;br /&gt;
       merge_wifi_settings || exit&lt;br /&gt;
     done&lt;br /&gt;
   else&lt;br /&gt;
     # we still want to be here and do nothing&lt;br /&gt;
     # just waiting to be killed by PmWiFiService ...&lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 30&lt;br /&gt;
     done&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   ln -s /usr/sbin/wpa_supplicant /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   exec /tmp/.wpa_supplicant.tmp --SETUP-WAIT-AND-CLEANUP &amp;quot;$@&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Zigi004|Zigi004]] 11:04, 1 November 2012 (PDT)&lt;/div&gt;</summary>
		<author><name>Zigi004</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Advanced_Wifi&amp;diff=21875</id>
		<title>Advanced Wifi</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Advanced_Wifi&amp;diff=21875"/>
		<updated>2012-11-01T17:56:26Z</updated>

		<summary type="html">&lt;p&gt;Zigi004: extended automatization section + link to wrapper script&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about advanced Wifi configurations. You should know some Terminal and Linux for this.&lt;br /&gt;
&lt;br /&gt;
= Disclaimer =&lt;br /&gt;
Most of you won't need this guide as the pre connects to the usual Wireless networks. This guide is for those of you who know what you are doing. This guide comes as is, I have no resposibility if anything happens during using this guide including impact of meteorites and the return of the dinosaurs.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Our university uses '''eduroam''' for wireless lan access. This is a Enterprise WPA(2) network with TTLS as authentication, featuring an anonymous identity and whatever else.&lt;br /&gt;
As Palm obviously did not think of working on WPA Enterprise authentication, I had to do it myself. BTW, iOS connects flawlessly.&lt;br /&gt;
&lt;br /&gt;
= Connecting =&lt;br /&gt;
== Command line wpa_supplicant ==&lt;br /&gt;
Connection via wpa_supplicant works as follows:&lt;br /&gt;
&lt;br /&gt;
 # # kill the running wpa_supplicant&lt;br /&gt;
 # killall wpa_supplicant&lt;br /&gt;
 # # start a new one&lt;br /&gt;
 # wpa_supplicant -i eth0 -D wext -c /tmp/wpa_supplicant.conf&lt;br /&gt;
 # # obtain IP Adress&lt;br /&gt;
 # dhclient eth0&lt;br /&gt;
 # # Some DNS problems may occur, so for testing add google DNS Servers:&lt;br /&gt;
 # echo nameserver 8.8.8.8 &amp;gt; /etc/resolv.conf&lt;br /&gt;
&lt;br /&gt;
This is everything you need to test connection via wpa_supplicant. For an example configuration read the manpage or check the configuration at the end of this article.&lt;br /&gt;
&lt;br /&gt;
== Problem with webOS ==&lt;br /&gt;
Connection via command line works for the system underneath, but you will receive the &amp;quot;No network connection&amp;quot; message when you try to use some webOS internet app without another ( i.e. 3G ) connection.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We need to &amp;quot;inject&amp;quot; the wpa_supplicant configuration while webOS connects to the network. This sounds somewhat crazy but it works.&lt;br /&gt;
Create a working configuration and a small script. Also you need some debian packages.&lt;br /&gt;
&lt;br /&gt;
=== Packages ===&lt;br /&gt;
Go to http://packages.debian.org and download the wpasupplicant packages. You only need the /sbin/wpa_cli binary from there. Also you need the file libreadline.so.6. Download the ''arm'' binaries, as this is the architecture of the pre.&lt;br /&gt;
&lt;br /&gt;
=== Script ===&lt;br /&gt;
Create a script somewhere with the following contents:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 cp .wpa_supplicant.conf /tmp&lt;br /&gt;
 chmod a-w /tmp/.wpa_supplicant.conf&lt;br /&gt;
 ./wpacli reconfigure&lt;br /&gt;
&lt;br /&gt;
You need to be able to execute it quickly.&lt;br /&gt;
&lt;br /&gt;
=== Testrun ===&lt;br /&gt;
Fire up the Palm Wifi Manager. Click the network you want to connect to. As username/password you need to enter anything, as these won't be used anyway. ''IMMEDIATELY'' switch to a terminal on your pre and execute the above script. You may need some tries to get the timing. Afterwards your pre should connect to the network AND think he's connected. Congratulations.&lt;br /&gt;
&lt;br /&gt;
=== Automatization ===&lt;br /&gt;
While this simple approach may work, it is not an long-run solution. At least on WebOS 2.1.2 process called PmWiFiService injects it's own configuration at random intervals and eventually will mess things up.&lt;br /&gt;
&lt;br /&gt;
So we need a better way to inject our own configuration, and insist on it. Thus I wrote small wrapper&lt;br /&gt;
[[Advanced_Wifi/wrapper|wpa_supplicant.wrapper]]&lt;br /&gt;
&lt;br /&gt;
Installation and usage:&lt;br /&gt;
&lt;br /&gt;
# turn off wifi&lt;br /&gt;
# connect to Your WebOS device and copy original binary file:&lt;br /&gt;
#: # cp /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant.real'&lt;br /&gt;
# put this file on wpa_supplicant's place and rename it:&lt;br /&gt;
#: # cp /media/internal/wpa_supplicant.wrapper /usr/sbin/wpa_supplicant&lt;br /&gt;
# put customized config in /media/internal/.wpa_supplicant.conf or any other convenient place. Remember - passwords are stored in that file.&lt;br /&gt;
# Update configuration file location in WPA_CONFIG variable&lt;br /&gt;
# from [http://packages.debian.org/wheezy/wpasupplicant] download package with correct architecture (HP veer uses armel)&lt;br /&gt;
# extract wpa_cli binary and copy it in place e.g.:&lt;br /&gt;
#: # cp /media/internal/wpa_cli /usr/sbin&lt;br /&gt;
# correct permisions:&lt;br /&gt;
#: # chmod 755 /usr/sbin/wpa_supplicant /usr/sbin/wpa_cli&lt;br /&gt;
&lt;br /&gt;
Instalation is now completed&lt;br /&gt;
&lt;br /&gt;
All networks defined in original wifi application will continue working&lt;br /&gt;
and can be managed through original interface. Network settings in custom&lt;br /&gt;
config file will overwrite definitions in built-in application.&lt;br /&gt;
So for any configuration change in custom networks edit configuration&lt;br /&gt;
file by Your favorite editor&lt;br /&gt;
&lt;br /&gt;
To use it:&lt;br /&gt;
* first define new network in the configuration file, use any option You wish, use wpa_supplicant config file format:&lt;br /&gt;
** every option on single line,&lt;br /&gt;
** &amp;quot;network={&amp;quot; and &amp;quot;}&amp;quot; and comment also in single line&lt;br /&gt;
*; best way for now is to export settings from another system&lt;br /&gt;
* then turn on wifi&lt;br /&gt;
* from WiFi Preferences applet select &amp;quot;Join network&amp;quot;&lt;br /&gt;
** enter name of the network You just configured&lt;br /&gt;
** select security type - Open&lt;br /&gt;
&lt;br /&gt;
Enjoy new wifi connection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sample Configuration ==&lt;br /&gt;
&lt;br /&gt;
 network={&lt;br /&gt;
 ssid=&amp;quot;eduroam&amp;quot;&lt;br /&gt;
 mode=0&lt;br /&gt;
 proto=WPA2&lt;br /&gt;
 key_mgmt=WPA-EAP&lt;br /&gt;
 auth_alg=OPEN&lt;br /&gt;
 eap=TTLS&lt;br /&gt;
 identity=&amp;quot;xxxxxxxxxxxxxxx&amp;quot;&lt;br /&gt;
 anonymous_identity=&amp;quot;anonymous@university.xx&amp;quot;&lt;br /&gt;
 password=&amp;quot;xxxxxxxxxxxxxxx&amp;quot;&lt;br /&gt;
 ca_cert=&amp;quot;/home/root/cert.pem&amp;quot;&lt;br /&gt;
 phase2=&amp;quot;auth=PAP&amp;quot;&lt;br /&gt;
 priority=5&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Zigi004</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21873</id>
		<title>Advanced Wifi/wrapper</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Advanced_Wifi/wrapper&amp;diff=21873"/>
		<updated>2012-11-01T17:02:04Z</updated>

		<summary type="html">&lt;p&gt;Zigi004: Created page with &amp;quot;=Advanced WiFi wrapper=  This shell wrapper arround wpa_supplicant inject custom wifi settings intorunning wpa_supplicant. More informations about topic can be found at [[Advance...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Advanced WiFi wrapper=&lt;br /&gt;
&lt;br /&gt;
This shell wrapper arround wpa_supplicant inject custom wifi settings intorunning wpa_supplicant.&lt;br /&gt;
More informations about topic can be found at [[Advanced_Wifi]] page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 ## This is wrapper around wpa_supplicant binary.&lt;br /&gt;
 ##&lt;br /&gt;
 ## vesion 0.0.1 proof of concept&lt;br /&gt;
 ## no responsibity, no warranty, works for me (Veer 8G, WebOS 2.1.2), YMMV&lt;br /&gt;
 ##&lt;br /&gt;
 ## author: Matej Zagiba&lt;br /&gt;
 ## license: any version of GPL&lt;br /&gt;
 ##&lt;br /&gt;
 ## Installation and usage:&lt;br /&gt;
 ## 1. turn off wifi&lt;br /&gt;
 ## 2. connect to Your WebOS device and copy original binary file:&lt;br /&gt;
 ##    # cp /usr/sbin/wpa_supplicant /usr/sbin/wpa_supplicant.real&lt;br /&gt;
 ## 3. put this file on wpa_suppilcant's place and rename it:&lt;br /&gt;
 ##    # cp /media/internal/wpa_supplicant.wrapper /usr/sbin/wpa_supplicant&lt;br /&gt;
 ## 4. put customized config in /media/internal/.wpa_supplicant.conf&lt;br /&gt;
 ##    or any other convenient place. Remember - passwords are stored&lt;br /&gt;
 ##    in that file. Update configuration file location in WPA_CONFIG variable&lt;br /&gt;
 ## 5. from http://packages.debian.org/wheezy/wpasupplicant download package&lt;br /&gt;
 ##    with correct archtecture (HP veer uses armel) extract wpa_cli binary&lt;br /&gt;
 ##    and copy it in place e.g.:&lt;br /&gt;
 ##    # cp /media/internal/wpa_cli /usr/sbin&lt;br /&gt;
 ## 6. correct premisions:&lt;br /&gt;
 ##    # chmod 755 /usr/sbin/wpa_supplicant /usr/sbin/wpa_cli&lt;br /&gt;
 ##&lt;br /&gt;
 ## Instalation is now completed&lt;br /&gt;
 ##&lt;br /&gt;
 ## All networks defined in original wifi application will continue workung&lt;br /&gt;
 ## and can be managed throu original iterface. Network settings in custom&lt;br /&gt;
 ## config file will overwrite definitions in built-in application.&lt;br /&gt;
 ## So for any configuration change in custom networks edit configuration&lt;br /&gt;
 ## file by Your favorite editor&lt;br /&gt;
 ##&lt;br /&gt;
 ## To use it:&lt;br /&gt;
 ## - first define new network in the configuration file,&lt;br /&gt;
 ##   use any option You wish, use wpa_supplicant config file format:&lt;br /&gt;
 ##   every option on single line, &amp;quot;network={&amp;quot; and &amp;quot;}&amp;quot; and comment also&lt;br /&gt;
 ##   in single line, best way for now is to export settings from another system&lt;br /&gt;
 ## - then turn on wifi&lt;br /&gt;
 ## - from WiFi Preferences applet select &amp;quot;Join network&amp;quot; and enter name of the network&lt;br /&gt;
 ##   You just configured, select security type - Open&lt;br /&gt;
 ## - Enjoin new wifi connection&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 WPA_CONFIG=&amp;quot;/media/internal/.wpa_supplicant.conf&amp;quot;&lt;br /&gt;
 WPA_CLI=&amp;quot;/usr/sbin/wpa_cli&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## no user editable settings belove here&lt;br /&gt;
 OIFS=&amp;quot;$IFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 ## define functions&lt;br /&gt;
 &lt;br /&gt;
 merge_wifi_settings ()&lt;br /&gt;
 {&lt;br /&gt;
   IFS=&amp;quot;&lt;br /&gt;
 &amp;quot;&lt;br /&gt;
   READING_NETWORK=0&lt;br /&gt;
   UNKNOWN_NET=0&lt;br /&gt;
 &lt;br /&gt;
   # read and apply user configuration&lt;br /&gt;
   #&lt;br /&gt;
   for LINE_IN in `cat &amp;quot;$WPA_CONFIG&amp;quot;`; do&lt;br /&gt;
     IFS=&amp;quot;$OIFS&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     # get rid of leading and trailing blanks and remove comments&lt;br /&gt;
     LINE_IN=`sed -e &amp;quot;s/^[[:space:]]*//&amp;quot; -e &amp;quot;s/[[:space:]]*$//&amp;quot; -e &amp;quot;s/^#.*$//&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
 $LINE_IN`&lt;br /&gt;
 &lt;br /&gt;
     # skip empty lines&lt;br /&gt;
     [ &amp;quot;o$LINE_IN&amp;quot; = &amp;quot;o&amp;quot; ] &amp;amp;&amp;amp; continue&lt;br /&gt;
 &lt;br /&gt;
     OPTION=&amp;quot;${LINE_IN%%=*}&amp;quot;&lt;br /&gt;
     VALUE=&amp;quot;${LINE_IN#*=}&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
     case &amp;quot;$LINE_IN&amp;quot; in&lt;br /&gt;
         # start of network block&lt;br /&gt;
 	&amp;quot;network={&amp;quot;*)&lt;br /&gt;
 		READING_NETWORK=1&lt;br /&gt;
 		;;&lt;br /&gt;
         # SSID of the network, fun starts here&lt;br /&gt;
         # we expect to ssid be first thing set in network block&lt;br /&gt;
 	&amp;quot;ssid=&amp;quot;*)&lt;br /&gt;
 		NET_SSID=&amp;quot;${VALUE#\&amp;quot;}&amp;quot;&lt;br /&gt;
 		NET_SSID=&amp;quot;${NET_SSID%\&amp;quot;}&amp;quot;&lt;br /&gt;
                 # is such a network allready know by wpa_supplicant?&lt;br /&gt;
 		NET_ENTRY=`$WPA_CLI list_networks | grep &amp;quot;$NET_SSID&amp;quot;`&lt;br /&gt;
 		if [ &amp;quot;o$NET_ENTRY&amp;quot; = &amp;quot;o&amp;quot; ]; then&lt;br /&gt;
 		  UNKNOWN_NET=1&lt;br /&gt;
 		  NET_ID=`&amp;quot;$WPA_CLI&amp;quot; ADD_NETWORK | tail -n1`&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		else&lt;br /&gt;
 		  NET_ID=&amp;quot;${NET_ENTRY%%	*}&amp;quot;&lt;br /&gt;
 		  NET_STATUS=&amp;quot;${NET_ENTRY##*	}&amp;quot;&lt;br /&gt;
                   # are we connected to this network?&lt;br /&gt;
                   if [ &amp;quot;o$NET_STATUS&amp;quot; = 'o[CURRENT]' ]; then&lt;br /&gt;
                     # yes, so no need to reconfigure wpa_supplicant&lt;br /&gt;
                     READING_NETWORK=0&lt;br /&gt;
                   else&lt;br /&gt;
                     # no, so we disable network to to be able modify setting&lt;br /&gt;
 		    &amp;quot;$WPA_CLI&amp;quot; &amp;quot;DISABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		  fi&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
         # end of network block - enable network, if needed and reset variables&lt;br /&gt;
 	&amp;quot;}&amp;quot;)&lt;br /&gt;
                 if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; &amp;quot;ENABLE_NETWORK&amp;quot; &amp;quot;$NET_ID&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		READING_NETWORK=0&lt;br /&gt;
 		UNKNOWN_NET=0&lt;br /&gt;
 		unset NET_ENTRY NET_ID NET_STATUS OPTION VALUE&lt;br /&gt;
 		;;&lt;br /&gt;
         # update current option if reading network definition&lt;br /&gt;
 	*)&lt;br /&gt;
 		if [ &amp;quot;o$READING_NETWORK&amp;quot; = &amp;quot;o1&amp;quot; ]; then&lt;br /&gt;
 		  &amp;quot;$WPA_CLI&amp;quot; SET_NETWORK &amp;quot;$NET_ID&amp;quot; &amp;quot;$OPTION&amp;quot; &amp;quot;$VALUE&amp;quot; &amp;gt;/dev/null&lt;br /&gt;
 		fi&lt;br /&gt;
 		;;&lt;br /&gt;
     esac&lt;br /&gt;
   done&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ## PmWiFiService will send SIGKILL to wpa_supplicant process, which could&lt;br /&gt;
 ## leave wpa_supplicant.real running and cause problems later.&lt;br /&gt;
 ## so we do some magic with processeses...&lt;br /&gt;
 &lt;br /&gt;
 if [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SETUP-WAIT-AND-CLEANUP&amp;quot; ]; then&lt;br /&gt;
   shift&lt;br /&gt;
   /usr/sbin/wpa_supplicant --SLEEP-AND-UPDATE &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
   ##just to be sure&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   # SET UP THINGS&lt;br /&gt;
   if [ -f &amp;quot;$WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
     echo &amp;quot;update_config=1&amp;quot; &amp;gt;&amp;gt;/tmp/.wpa_supplicant.conf&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
     merge_wifi_settings&lt;br /&gt;
   else&lt;br /&gt;
     /usr/sbin/wpa_supplicant.real &amp;quot;$@&amp;quot; -B&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   # WAIT&lt;br /&gt;
   wait&lt;br /&gt;
   # and CLEAN UP&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; ]; then&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; terminate &amp;gt;/dev/null&lt;br /&gt;
   else&lt;br /&gt;
     pkill wpa_supplicant&lt;br /&gt;
   fi&lt;br /&gt;
     rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
 &lt;br /&gt;
 elif [ &amp;quot;o$1&amp;quot; = &amp;quot;o--SLEEP-AND-UPDATE&amp;quot; ]; then&lt;br /&gt;
   # check some basic stuff - is there executable wpa_cli?&lt;br /&gt;
   # and does user configuration exists?&lt;br /&gt;
   if [ -x &amp;quot;$WPA_CLI&amp;quot; -a -f &amp;quot;WPA_CONFIG&amp;quot; ]; then&lt;br /&gt;
     ## - can we reach wpa_supplicant?&lt;br /&gt;
     &amp;quot;$WPA_CLI&amp;quot; status &amp;gt;/dev/null || exit $?&lt;br /&gt;
 &lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 5&lt;br /&gt;
       merge_wifi_settings || exit&lt;br /&gt;
     done&lt;br /&gt;
   else&lt;br /&gt;
     # we still want to be here and do nothing&lt;br /&gt;
     # just waiting to be killed by PmWiFiService ...&lt;br /&gt;
     while true; do&lt;br /&gt;
       sleep 30&lt;br /&gt;
     done&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   rm -rf /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   ln -s /usr/sbin/wpa_supplicant /tmp/.wpa_supplicant.tmp&lt;br /&gt;
   exec /tmp/.wpa_supplicant.tmp --SETUP-WAIT-AND-CLEANUP &amp;quot;$@&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Zigi004|Zigi004]] 10:02, 1 November 2012 (PDT)&lt;/div&gt;</summary>
		<author><name>Zigi004</name></author>
	</entry>
</feed>