Bladeren bron

- wifi config added
- kernel fetched from GfA public repo

Reinhard Russinger 6 jaren geleden
bovenliggende
commit
bfce2ade7c
28 gewijzigde bestanden met toevoegingen van 1562 en 61 verwijderingen
  1. 12 12
      Make-bb-kernel_Qt5.7.sh
  2. 1 1
      board/GfA/Display001/BUILD
  3. 19 11
      board/GfA/Display001/post-build_4.4.sh
  4. 0 26
      board/GfA/Display001/rootfs/etc/init.d/M99_wlan_usb
  5. 51 0
      board/GfA/Display001/rootfs/etc/netplug.d/netplug
  6. 2 0
      board/GfA/Display001/rootfs/etc/netplug/netplugd.conf
  7. 1 0
      board/GfA/Display001/rootfs/etc/network/if-down.d/wpasupplicant
  8. 1 0
      board/GfA/Display001/rootfs/etc/network/if-post-down.d/wpasupplicant
  9. 21 0
      board/GfA/Display001/rootfs/etc/network/if-pre-up.d/wait_iface
  10. 1 0
      board/GfA/Display001/rootfs/etc/network/if-pre-up.d/wpasupplicant
  11. 1 0
      board/GfA/Display001/rootfs/etc/network/if-up.d/wpasupplicant
  12. 7 9
      board/GfA/Display001/rootfs/etc/network/interfaces
  13. 1 0
      board/GfA/Display001/rootfs/etc/network/run
  14. 7 0
      board/GfA/Display001/rootfs/etc/udev/rules.d/70-persistent-net.rules
  15. 2 0
      board/GfA/Display001/rootfs/etc/udev/rules.d/80-wifi.rules
  16. 50 0
      board/GfA/Display001/rootfs/etc/wpa_supplicant/action_wpa.sh
  17. 1006 0
      board/GfA/Display001/rootfs/etc/wpa_supplicant/functions.sh
  18. 172 0
      board/GfA/Display001/rootfs/etc/wpa_supplicant/ifupdown.sh
  19. 12 0
      board/GfA/Display001/rootfs/etc/wpa_supplicant/wpa_supplicant.conf
  20. 7 0
      board/GfA/Display001/rootfs/rules.d/70-persistent-net.rules
  21. 2 0
      board/GfA/Display001/rootfs/rules.d/80-wifi.rules
  22. 1 0
      board/GfA/Display001/rootfs/sbin/wpa_action
  23. 1 0
      board/GfA/Display001/rootfs/sbin/wpa_cli
  24. 1 0
      board/GfA/Display001/rootfs/sbin/wpa_passphrase
  25. 1 0
      board/GfA/Display001/rootfs/sbin/wpa_supplicant
  26. 81 0
      board/GfA/Display001/rootfs/usr/sbin/wpa_action
  27. 3 2
      configs/Display001_4.4.104_rt21_Qt5.7_defconfig
  28. 98 0
      patches/0011-wlan-autoconfig.patch

+ 12 - 12
Make-bb-kernel_Qt5.7.sh

@@ -1,20 +1,20 @@
 #!/bin/bash
 #-- build kernelsources from RCN Repos
 #--
-GFAWRKDIR=`pwd`
-cd ..
-rm -rf bb-kernel
-git clone https://github.com/RobertCNelson/bb-kernel
-cd bb-kernel
-git checkout -b GfA 4.4.104-bone-rt-r21
+##GFAWRKDIR=`pwd`
+##cd ..
+##rm -rf bb-kernel
+##git clone https://github.com/RobertCNelson/bb-kernel
+##cd bb-kernel
+##git checkout -b GfA 4.4.104-bone-rt-r21
 # -- patch kernelbuild
-patch -p1 < ../GfA/build_kernel_44104rt.sh.patch
+##patch -p1 < ../GfA/build_kernel_44104rt.sh.patch
 #---------------------------------
-./build_kernel.sh
-cd $GFAWRKDIR
-rm ~/buildroot_dl/GfAkernel57.tar.gz
-rm GfAkernel57.tar.gz
-tar -C ../bb-kernel/KERNEL --exclude=./.config --exclude=./.git  -czvf GfAkernel57.tar.gz ./
+##./build_kernel.sh
+##cd $GFAWRKDIR
+##rm ~/buildroot_dl/GfAkernel57.tar.gz
+##rm GfAkernel57.tar.gz
+##tar -C ../bb-kernel/KERNEL --exclude=./.config --exclude=./.git  -czvf GfAkernel57.tar.gz ./
 #--
 #--
 #!/bin/bash

+ 1 - 1
board/GfA/Display001/BUILD

@@ -1 +1 @@
-624
+626

+ 19 - 11
board/GfA/Display001/post-build_4.4.sh

@@ -15,6 +15,25 @@ cp -v output/staging/usr/bin/locale $TARGETDIR/usr/bin/
 mkdir -p $TARGETDIR/usr/share/i18n
 cp -a output/staging/usr/share/i18n/* $TARGETDIR/usr/share/i18n
 
+# Dateien löschen
+FILE_TO_DELETE=$TARGETDIR/etc/wpa_supplicant.conf
+if [ -f $FILE_TO_DELETE ]
+then
+	rm $FILE_TO_DELETE
+fi
+
+FILE_TO_DELETE=$TARGETDIR/etc/init.d/M99_wlan_usb
+if [ -f $FILE_TO_DELETE ]
+then
+	rm $FILE_TO_DELETE
+fi
+
+FILE_TO_DELETE=$TARGETDIR/etc/init.d/S99_wlan_usb
+if [ -f $FILE_TO_DELETE ]
+then
+	rm $FILE_TO_DELETE
+fi
+
 # Dienste auf Manuell stellen
 SERVICE=S80dhcp-relay
 NSERVICE=M80dhcp-relay
@@ -62,15 +81,4 @@ mkdir -p $TARGETDIR/usr/lib/fonts
 cp $TARGETDIR/usr/share/fonts/dejavu/* $TARGETDIR/usr/lib/fonts
 cp $TARGETDIR/usr/share/fonts/liberation/* $TARGETDIR/usr/lib/fonts
 #------------------------------------
-#-- links für EGL bibliotheken herstellen
-#WRKDIR=`pwd`
-#cd $TARGETDIR/usr/lib
-#
-#rm ./libEGL.so.1
-#rm ./libGLESv2.so.2
-#ln -s libEGL.so ./libEGL.so.1
-#ln -s libGLESv2.so ./libGLESv2.so.2
-#
-#cd $WRKDIR
-#------------------------------------
 echo "GfA-Display001 Rel 1.0 Build $BUILD ($BUILDDATE)" > $TARGETDIR/etc/BUILD

+ 0 - 26
board/GfA/Display001/rootfs/etc/init.d/M99_wlan_usb

@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Start the usb wlan network....
-#
-
-case "$1" in
-  start)
-        echo "Starting usb wlan network..."
-        wpa_supplicant -i wlan0  -D nl80211,wext -c /etc/wpa_supplicant.conf -B
-        ifup wlan0
-        ;;
-  stop)
-        echo -n "Stopping usb wlan network..."
-        ifdown wlan0
-        killall wpa_supplicant
-        ;;
-  restart|reload)
-        "$0" stop
-        "$0" start
-        ;;
-  *)
-        echo "Usage: $0 {start|stop|restart}"
-        exit 1
-esac
-
-exit $?

+ 51 - 0
board/GfA/Display001/rootfs/etc/netplug.d/netplug

@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# netplug - policy agent for netplugd
+#
+# Copyright 2003 Key Research, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2, as
+# published by the Free Software Foundation.  You are forbidden from
+# redistributing or modifying it under the terms of any other license,
+# including other versions of the GNU General Public License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+
+PATH=/usr/bin:/bin:/usr/sbin:/sbin
+export PATH
+
+dev="$1"
+action="$2"
+
+case "$action" in
+in)
+    if [ -x /sbin/ifup ]; then
+	exec /sbin/ifup --ignore-errors $dev
+    else
+	echo "Please teach me how to plug in an interface!" 1>&2
+	exit 1
+    fi
+    ;;
+out)
+    if [ -x /sbin/ifdown ]; then
+	# At least on Fedora Core 1, the call to ip addr flush infloops
+	# /sbin/ifdown $dev && exec /sbin/ip addr flush $dev
+	exec /sbin/ifdown --ignore-errors $dev
+    else
+	echo "Please teach me how to unplug an interface!" 1>&2
+	exit 1
+    fi
+    ;;
+probe)
+    exec /sbin/ip link set $dev up >/dev/null 2>&1
+    ;;
+*)
+    echo "I have been called with a funny action of '%s'!" 1>&2
+    exit 1
+    ;;
+esac

+ 2 - 0
board/GfA/Display001/rootfs/etc/netplug/netplugd.conf

@@ -0,0 +1,2 @@
+eth0
+eth1

+ 1 - 0
board/GfA/Display001/rootfs/etc/network/if-down.d/wpasupplicant

@@ -0,0 +1 @@
+../../wpa_supplicant/ifupdown.sh

+ 1 - 0
board/GfA/Display001/rootfs/etc/network/if-post-down.d/wpasupplicant

@@ -0,0 +1 @@
+../../wpa_supplicant/ifupdown.sh

+ 21 - 0
board/GfA/Display001/rootfs/etc/network/if-pre-up.d/wait_iface

@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# In case we have a slow-to-appear interface (e.g. eth-over-USB),
+# and we need to configure it, wait until it appears, but not too
+# long either. IF_WAIT_DELAY is in seconds.
+
+if [ "${IF_WAIT_DELAY}" -a ! -e "/sys/class/net/${IFACE}" ]; then
+    printf "Waiting for interface %s to appear" "${IFACE}"
+    while [ ${IF_WAIT_DELAY} -gt 0 ]; do
+        if [ -e "/sys/class/net/${IFACE}" ]; then
+            printf "\n"
+            exit 0
+        fi
+        sleep 1
+        printf "."
+        : $((IF_WAIT_DELAY -= 1))
+    done
+    printf " timeout!\n"
+    exit 1
+fi
+

+ 1 - 0
board/GfA/Display001/rootfs/etc/network/if-pre-up.d/wpasupplicant

@@ -0,0 +1 @@
+../../wpa_supplicant/ifupdown.sh

+ 1 - 0
board/GfA/Display001/rootfs/etc/network/if-up.d/wpasupplicant

@@ -0,0 +1 @@
+../../wpa_supplicant/ifupdown.sh

+ 7 - 9
board/GfA/Display001/rootfs/etc/network/interfaces

@@ -1,22 +1,20 @@
 # Configure Loopback
 auto lo
-auto eth0
-auto usb0
 iface lo inet loopback
-#
+#---
 #iface eth0 inet dhcp
 iface eth0 inet static
 	address 192.168.0.125
 	netmask 255.255.255.0
 	gateway 192.168.0.10
 	post-up echo "nameserver 192.168.0.10" > /etc/resolv.conf
-#
+
+iface eth1 inet dhcp
+#---
 iface usb0 inet static
 	address 192.168.7.2
 	netmask 255.255.255.252
+#---
+iface wlan0 inet dhcp
+	wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
 #
-iface wlan0 inet static
-	address 192.168.8.2
-	broadcast 192.168.8.255
-	netmask 255.255.255.0
-#

+ 1 - 0
board/GfA/Display001/rootfs/etc/network/run

@@ -0,0 +1 @@
+/run/network

+ 7 - 0
board/GfA/Display001/rootfs/etc/udev/rules.d/70-persistent-net.rules

@@ -0,0 +1,7 @@
+# This file was automatically generated by the /lib/udev/write_net_rules
+# program, run by the persistent-net-generator.rules rules file.
+#
+# You can modify it, as long as you keep each rule on a single
+# line, and change only the value of the NAME= key.
+
+#ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", KERNEL=="wlan*", ATTR{address}=="74:da:38:ec:a2:34", NAME="wlan0"

+ 2 - 0
board/GfA/Display001/rootfs/etc/udev/rules.d/80-wifi.rules

@@ -0,0 +1,2 @@
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/sbin/ifup %k"
+ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/sbin/ifdown %k"

+ 50 - 0
board/GfA/Display001/rootfs/etc/wpa_supplicant/action_wpa.sh

@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Action script to enable/disable wpa-roam interfaces in reaction to
+# ifplugd events.
+#
+# Copyright: Copyright (c) 2008-2010, Kel Modderman <kel@otaku42.de>
+# License:   GPL-2
+#
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+if [ ! -x /sbin/wpa_action ]; then
+	exit 0
+fi
+
+# ifplugd(8) - <iface> <action>
+#
+# If an ifplugd managed interface is brought up, disconnect any
+# wpa-roam managed interfaces so that only one "roaming" interface
+# remains active on the system.
+
+IFPLUGD_IFACE="${1}"
+
+case "${2}" in
+	up)
+		COMMAND=disconnect
+		;;
+	down)
+		COMMAND=reconnect
+		;;
+	*)
+		echo "$0: unknown arguments: ${@}" >&2
+		exit 1
+		;;
+esac
+
+for CTRL in /run/wpa_supplicant/*; do
+	[ -S "${CTRL}" ] || continue
+
+	IFACE="${CTRL#/run/wpa_supplicant/}"
+
+	# skip if ifplugd is managing this interface
+	if [ "${IFPLUGD_IFACE}" = "${IFACE}" ]; then
+		continue
+	fi
+
+	if wpa_action "${IFACE}" check; then
+		wpa_cli -i "${IFACE}" "${COMMAND}"
+	fi
+done

+ 1006 - 0
board/GfA/Display001/rootfs/etc/wpa_supplicant/functions.sh

@@ -0,0 +1,1006 @@
+#!/bin/sh
+
+#####################################################################
+## Purpose
+# This file contains common shell functions used by scripts of the
+# wpasupplicant package to allow ifupdown to manage wpa_supplicant.
+# It also contains some functions used by wpa_action(8) that allow
+# ifupdown to be managed by wpa_cli(8) action events.
+#
+# This file is provided by the wpasupplicant package.
+
+#####################################################################
+# Copyright (C) 2006 - 2009 Debian/Ubuntu wpasupplicant Maintainers 
+# <pkg-wpa-devel@lists.alioth.debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# On Debian GNU/Linux systems, the text of the GPL license,
+# version 2, can be found in /usr/share/common-licenses/GPL-2.
+
+#####################################################################
+## global variables
+# wpa_supplicant variables
+WPA_SUP_BIN="/sbin/wpa_supplicant"
+WPA_SUP_PNAME="wpa_supplicant"
+WPA_SUP_PIDFILE="/run/wpa_supplicant.${WPA_IFACE}.pid"
+WPA_SUP_OMIT_DIR="/run/sendsigs.omit.d"
+WPA_SUP_OMIT_PIDFILE="${WPA_SUP_OMIT_DIR}/wpasupplicant.wpa_supplicant.${WPA_IFACE}.pid"
+
+# wpa_cli variables
+WPA_CLI_BIN="/sbin/wpa_cli"
+WPA_CLI_PNAME="wpa_cli"
+WPA_CLI_PIDFILE="/run/wpa_action.${WPA_IFACE}.pid"
+WPA_CLI_TIMESTAMP="/run/wpa_action.${WPA_IFACE}.timestamp"
+WPA_CLI_IFUPDOWN="/run/wpa_action.${WPA_IFACE}.ifupdown"
+
+# default ctrl_interface socket directory
+if [ -z "$WPA_CTRL_DIR" ]; then
+	WPA_CTRL_DIR="/run/wpa_supplicant"
+fi
+
+# verbosity variables
+if [ -n "$IF_WPA_VERBOSITY" ] || [ "$VERBOSITY" = "1" ]; then
+	TO_NULL="/dev/stdout"
+	DAEMON_VERBOSITY="--verbose"
+else
+	TO_NULL="/dev/null"
+	DAEMON_VERBOSITY="--quiet"
+fi
+
+#####################################################################
+## wpa_cli wrapper
+# Path to common ctrl_interface socket and iface supplied.
+# NB: WPA_CTRL_DIR cannot be used for interactive commands, it is
+# set only in the environment that wpa_cli provides when processing
+# action events.
+#
+wpa_cli () {
+	"$WPA_CLI_BIN" -p "$WPA_CTRL_DIR" -i "$WPA_IFACE" "$@"
+
+	return "$?"
+}
+
+#####################################################################
+## verbose and stderr message wrapper
+# Ensures a standard and easily identifiable message is printed by
+# scripts using this function library.
+#
+# log		Log a message to syslog when called non-interactively
+#		by wpa_action
+#
+# verbose	To stdout when IF_WPA_VERBOSITY or VERBOSITY is true
+#
+# action	Same as verbose but without newline
+#		Useful for allowing wpa_cli commands to echo result
+#		value of 'OK' or 'FAILED'
+#
+# stderr	Echo warning or error messages to stderr
+#
+# NB: when called by wpa_action, there is no redirection (verbose)
+#
+wpa_msg () {
+	if [ "$1" = "log" ]; then
+		shift
+		case "$WPA_ACTION" in
+			"CONNECTED"|"DISCONNECTED")
+				[ -x /usr/bin/logger ] || return
+				if [ "$#" -gt 0 ]; then
+					logger -t "wpa_action" "$@"
+				else
+					logger -t "wpa_action"
+				fi
+				;;
+			*)
+				[ "$#" -gt 0 ] && echo "wpa_action: $@"
+				;;
+		esac
+		return
+	fi
+	
+	case "$1" in 
+		"verbose")
+			shift
+			echo "$WPA_SUP_PNAME: $@" >$TO_NULL
+			;;
+		"action")
+			shift
+			echo -n "$WPA_SUP_PNAME: $@ -- " >$TO_NULL
+			;;
+		"stderr")
+			shift
+			echo "$WPA_SUP_PNAME: $@" >/dev/stderr
+			;;
+		*)
+			;;
+	esac
+}
+
+#####################################################################
+## validate daemon pid files
+# Test daemon process ID files via start-stop-daemon with a signal 0
+# given the exec binary and pidfile location.
+#
+# $1	daemon
+# $2	pidfile
+#
+# Returns true when pidfile exists, the process ID exists _and_ was
+# created by the exec binary.
+#
+# If the test fails, but the pidfile exists, it is stale
+#
+test_daemon_pidfile () {
+	local DAEMON
+	local PIDFILE
+	
+	if [ -n "$1" ]; then
+		DAEMON="$1"
+	fi
+	
+	if [ -f "$2" ]; then
+		PIDFILE="$2"
+	fi
+	
+	if [ -n "$DAEMON" ] && [ -f "$PIDFILE" ]; then
+		if start-stop-daemon --stop --quiet --signal 0 \
+			--exec "$DAEMON" --pidfile "$PIDFILE"; then
+			return 0
+		else
+			rm -f "$PIDFILE"
+			return 1
+		fi
+	else
+		return 1
+	fi
+}
+
+# validate wpa_supplicant pidfile
+test_wpa_supplicant () {
+	test_daemon_pidfile "$WPA_SUP_BIN" "$WPA_SUP_PIDFILE"
+}
+
+# validate wpa_cli pidfile
+test_wpa_cli () {
+	test_daemon_pidfile "$WPA_CLI_BIN" "$WPA_CLI_PIDFILE"
+}
+
+#####################################################################
+## daemonize wpa_supplicant
+# Start wpa_supplicant via start-stop-dameon with all required
+# options. Will start if environment variable WPA_SUP_CONF is present
+#
+# Default options:
+# -B	dameonize/background process
+# -D	driver backend ('wext' if none given)
+# -P	process ID file
+# -C	path to ctrl_interface socket directory
+# -s    log to syslog
+#
+# Conditional options:
+# -c	configuration file
+# -W	wait for wpa_cli to attach to ctrl_interface socket
+# -b	bridge interface name
+# -f	path to log file
+#
+init_wpa_supplicant () {
+	[ -n "$WPA_SUP_CONF" ] || return 0
+
+	local WPA_SUP_OPTIONS
+	WPA_SUP_OPTIONS="-s -B -P $WPA_SUP_PIDFILE -i $WPA_IFACE"
+
+	if [ -n "$WPA_ACTION_SCRIPT" ]; then
+		if [ -x "$WPA_ACTION_SCRIPT" ]; then
+			WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -W"
+			wpa_msg verbose "wait for wpa_cli to attach"
+		else
+			wpa_msg stderr "action script \"$WPA_ACTION_SCRIPT\" not executable"
+			return 1
+		fi
+	fi
+
+	if [ -n "$IF_WPA_BRIDGE" ]; then
+		WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -b $IF_WPA_BRIDGE"
+		wpa_msg verbose "wpa-bridge $IF_WPA_BRIDGE"
+	fi
+
+	if [ -n "$IF_WPA_DRIVER" ]; then
+		wpa_msg verbose "wpa-driver $IF_WPA_DRIVER"
+		case "$IF_WPA_DRIVER" in
+			hostap|ipw|madwifi|ndiswrapper)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -D nl80211,wext"
+				wpa_msg stderr "\"$IF_WPA_DRIVER\" wpa-driver is unsupported"
+				wpa_msg stderr "using \"nl80211,wext\" wpa-driver instead ..."
+				;;
+			*)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -D $IF_WPA_DRIVER"
+				;;
+		esac
+	else
+		WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -D nl80211,wext"
+		wpa_msg verbose "wpa-driver nl80211,wext (default)"
+	fi
+
+	if [ -n "$IF_WPA_DEBUG_LEVEL" ]; then
+		case "$IF_WPA_DEBUG_LEVEL" in
+			3)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -t -ddd"
+				;;
+			2)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -t -dd"
+				;;
+			1)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -t -d"
+				;;
+			0)
+				# wpa_supplicant default verbosity
+				;;
+			-1)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -q"
+				;;
+			-2)
+				WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -qq"
+				;;
+		esac
+		wpa_msg verbose "using debug level: $IF_WPA_DEBUG_LEVEL"
+	fi
+
+	if [ -n "$IF_WPA_LOGFILE" ]; then
+		# custom log file
+		WPA_SUP_OPTIONS="$WPA_SUP_OPTIONS -f $IF_WPA_LOGFILE"
+		WPA_SUP_LOGFILE="$IF_WPA_LOGFILE"
+		wpa_msg verbose "logging to $IF_WPA_LOGFILE"
+	fi
+
+	wpa_msg verbose "$WPA_SUP_BIN $WPA_SUP_OPTIONS $WPA_SUP_CONF"
+		
+	start-stop-daemon --start --oknodo $DAEMON_VERBOSITY \
+		--name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \
+		-- $WPA_SUP_OPTIONS $WPA_SUP_CONF
+
+	if [ "$?" -ne 0 ]; then
+		wpa_msg stderr "$WPA_SUP_BIN daemon failed to start"
+		return 1
+	fi
+
+	local WPA_PIDFILE_WAIT
+	local MAX_WPA_PIDFILE_WAIT
+	WPA_PIDFILE_WAIT="0"
+	MAX_WPA_PIDFILE_WAIT="5"
+	until [ -s "$WPA_SUP_PIDFILE" ]; do
+		if [ "$WPA_PIDFILE_WAIT" -ge "$MAX_WPA_PIDFILE_WAIT" ]; then
+			wpa_msg stderr "timed out waiting for creation of $WPA_SUP_PIDFILE"
+			return 1
+		else
+			wpa_msg verbose "waiting for \"$WPA_SUP_PIDFILE\": " \
+				"$WPA_PIDFILE_WAIT (max. $MAX_WPA_PIDFILE_WAIT)"
+		fi
+
+		WPA_PIDFILE_WAIT=$(($WPA_PIDFILE_WAIT + 1))
+		sleep 1
+	done
+	if [ -d "${WPA_SUP_OMIT_DIR}" ]; then
+		wpa_msg verbose "creating sendsigs omission pidfile: $WPA_SUP_OMIT_PIDFILE"
+		cat "$WPA_SUP_PIDFILE" > "$WPA_SUP_OMIT_PIDFILE"
+	fi
+
+	local WPA_SOCKET_WAIT
+	local MAX_WPA_SOCKET_WAIT
+	WPA_SOCKET_WAIT="0"
+	MAX_WPA_SOCKET_WAIT="5"
+	until [ -S "$WPA_CTRL_DIR/$WPA_IFACE" ]; do
+		if [ "$WPA_SOCKET_WAIT" -ge "$MAX_WPA_SOCKET_WAIT" ]; then
+			wpa_msg stderr "ctrl_interface socket not found at $WPA_CTRL_DIR/$WPA_IFACE"
+			return 1
+		else
+			wpa_msg verbose "waiting for \"$WPA_CTRL_DIR/$WPA_IFACE\": " \
+				"$WPA_SOCKET_WAIT (max. $MAX_WPA_SOCKET_WAIT)"
+		fi
+		
+		WPA_SOCKET_WAIT=$(($WPA_SOCKET_WAIT + 1))
+		sleep 1
+	done
+	
+	wpa_msg verbose "ctrl_interface socket located at $WPA_CTRL_DIR/$WPA_IFACE"
+}
+
+#####################################################################
+## stop wpa_supplicant process
+# Kill wpa_supplicant via start-stop-daemon, given the location of
+# the pidfile or ctrl_interface socket path and interface name
+#
+kill_wpa_supplicant () {
+	test_wpa_supplicant || return 0
+
+	wpa_msg verbose "terminating $WPA_SUP_PNAME daemon via pidfile $WPA_SUP_PIDFILE"
+
+	start-stop-daemon --stop --oknodo $DAEMON_VERBOSITY \
+		--exec $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE
+
+	if [ -f "$WPA_SUP_PIDFILE" ]; then
+		rm -f "$WPA_SUP_PIDFILE"
+	fi
+
+	if [ -f "$WPA_SUP_OMIT_PIDFILE" ]; then
+		wpa_msg verbose "removing $WPA_SUP_OMIT_PIDFILE"
+		rm -f "$WPA_SUP_OMIT_PIDFILE"
+	fi
+}
+
+#####################################################################
+## reload wpa_supplicant process
+# Sending a HUP signal causes wpa_supplicant to reparse its
+# configuration file
+#
+reload_wpa_supplicant () {
+	if test_wpa_supplicant; then
+		wpa_msg verbose "reloading wpa_supplicant configuration file via HUP signal"
+		start-stop-daemon --stop --signal HUP \
+			--name "$WPA_SUP_PNAME" --pidfile "$WPA_SUP_PIDFILE"
+	else
+		wpa_msg verbose "cannot $WPA_ACTION, $WPA_SUP_PIDFILE does not exist"
+	fi
+}
+
+#####################################################################
+## daemonize wpa_cli and action script
+# If environment variable WPA_ACTION_SCRIPT is present, wpa_cli will
+# be spawned via start-stop-daemon
+#
+# Required options:
+# -a	action script => wpa_action
+# -P	process ID file
+# -B	background process
+#
+init_wpa_cli () {
+	[ -n "$WPA_ACTION_SCRIPT" ] || return 0
+
+	local WPA_CLI_OPTIONS
+	WPA_CLI_OPTIONS="-B -P $WPA_CLI_PIDFILE -i $WPA_IFACE"
+
+	wpa_msg verbose "$WPA_CLI_BIN $WPA_CLI_OPTIONS -p $WPA_CTRL_DIR -a $WPA_ACTION_SCRIPT"
+		
+	start-stop-daemon --start --oknodo $DAEMON_VERBOSITY \
+		--name $WPA_CLI_PNAME --startas $WPA_CLI_BIN --pidfile $WPA_CLI_PIDFILE \
+		-- $WPA_CLI_OPTIONS -p $WPA_CTRL_DIR -a $WPA_ACTION_SCRIPT
+
+	if [ "$?" -ne 0 ]; then
+		wpa_msg stderr "$WPA_CLI_BIN daemon failed to start"
+		return 1
+	fi
+}
+
+#####################################################################
+## stop wpa_cli process
+# Kill wpa_cli via start-stop-daemon, given the location of the
+# pidfile
+#
+kill_wpa_cli () {
+	test_wpa_cli || return 0
+	
+	wpa_msg verbose "terminating $WPA_CLI_PNAME daemon via pidfile $WPA_CLI_PIDFILE"
+	
+	start-stop-daemon --stop --oknodo $DAEMON_VERBOSITY \
+		--exec $WPA_CLI_BIN --pidfile $WPA_CLI_PIDFILE
+	
+	if [ -f "$WPA_CLI_PIDFILE" ]; then
+		rm -f "$WPA_CLI_PIDFILE"
+	fi
+
+	if [ -f "$WPA_CLI_TIMESTAMP" ]; then
+		rm -f "$WPA_CLI_TIMESTAMP"
+	fi
+
+	if [ -L "$WPA_CLI_IFUPDOWN" ]; then
+		rm -f "$WPA_CLI_IFUPDOWN"
+	fi
+}
+
+#####################################################################
+## higher level wpa_cli wrapper for variable and set_network commands
+# wpa_cli_do <value> <type> <variable> [set_network variable] <desc>
+#
+# $1	envorinment variable
+# $2	data type of variable {raw|ascii}
+# $3	wpa_cli variable, if $3 is set_network, shift and take 
+#	set_network subvariable
+# $4	wpa-* string as it would appear in interfaces file, enhances
+#	verbose messages
+#
+wpa_cli_do () {
+	if [ -z "$1" ]; then
+		return 0
+	fi
+	
+	local WPACLISET_VALUE
+	local WPACLISET_VARIABLE
+	local WPACLISET_DESC
+	
+	case "$2" in
+		ascii)
+			# Double quote
+			WPACLISET_VALUE="\"$1\""
+			;;
+		raw|*)
+			# Provide raw value
+			WPACLISET_VALUE="$1"
+			;;
+	esac
+	
+	case "$3" in
+		set_network)
+			if [ -z "$WPA_ID" ]; then
+				return 1
+			fi
+			shift
+			WPACLISET_VARIABLE="set_network $WPA_ID $3"
+			;;
+		*)
+			WPACLISET_VARIABLE="$3"
+			;;
+	esac
+	
+	case "$4" in
+		*-psk|*-passphrase|*-passwd*|*-password*|*-wep-key*)
+			WPACLISET_DESC="$4 *****"
+			;;
+		*)
+			WPACLISET_DESC="$4 $WPACLISET_VALUE"
+			;;
+	esac
+
+	wpa_msg action "$WPACLISET_DESC"
+	
+	wpa_cli $WPACLISET_VARIABLE "$WPACLISET_VALUE" >$TO_NULL
+
+	if [ "$?" -ne 0 ]; then
+		wpa_msg stderr "$WPACLISET_DESC failed!"
+	fi
+}
+
+#####################################################################
+## check value data type in plaintext or hex
+# returns 0 if input consists of hexadecimal digits only, 1 otherwise
+#
+ishex () {
+	if [ -z "$1" ]; then 
+		return 0
+	fi
+	
+	case "$1" in
+		*[!0-9a-fA-F]*)
+			# plaintext
+			return 1
+			;;
+		*)
+			# hexadecimal
+			return 0
+			;;
+	esac
+}
+
+#####################################################################
+## sanity check and set psk|passphrase
+# Warn about strange psk|passphrase values
+#
+# $1	psk or passphrase value
+# 
+# If psk is surrounded by quotes strip them.
+#
+# If psk contains all hexadecimal characters and string length is 64:
+#	is 256bit hexadecimal
+# else:
+# 	is plaintext
+#
+# plaintext passphrases must be 8 - 63 characters in length
+# 256-bit hexadecimal key must be 64 characters in length
+#
+wpa_key_check_and_set () {
+	if [ "$#" -ne 3 ]; then
+		return 0
+	fi
+
+	local KEY
+	local KEY_LEN
+	local KEY_TYPE
+	local ENC_TYPE
+	
+	case "$1" in
+		'"'*'"')
+			# Strip surrounding quotation marks
+			KEY=$(echo -n "$1" | sed 's/^"//;s/"$//')
+			;;
+		*)
+			KEY="$1"
+			;;
+	esac
+
+	KEY_LEN="${#KEY}"
+
+	case "$2" in
+		wep_key*)
+			ENC_TYPE="WEP"
+			;;
+		psk)
+			ENC_TYPE="WPA"
+			;;
+		*)
+			return 0
+			;;
+	esac
+
+	if [ "$ENC_TYPE" = "WEP" ]; then
+		if ishex "$KEY"; then
+			case "$KEY_LEN" in
+				10|26|32|58)
+					# 64/128/152/256-bit WEP
+					KEY_TYPE="raw"
+					;;
+				*)
+					KEY_TYPE="ascii"
+					;;
+			esac
+		else
+			KEY_TYPE="ascii"
+		fi
+
+		if [ "$KEY_TYPE" = "ascii" ]; then
+			if [ "$KEY_LEN" -lt "5" ]; then
+				wpa_msg stderr "WARNING: plaintext or ascii WEP key has $KEY_LEN characters,"
+				wpa_msg stderr "it must have at least 5 to be valid."
+			fi
+		fi
+	elif [ "$ENC_TYPE" = "WPA" ]; then
+		if ishex "$KEY"; then
+			case "$KEY_LEN" in
+				64)
+					# 256-bit WPA
+					KEY_TYPE="raw"
+					;;
+				*)
+					KEY_TYPE="ascii"
+					;;
+			esac
+		else
+			KEY_TYPE="ascii"
+		fi
+
+		if [ "$KEY_TYPE" = "ascii" ]; then
+			if [ "$KEY_LEN" -lt "8" ] || [ "$KEY_LEN" -gt "63" ]; then
+				wpa_msg stderr "WARNING: plaintext or ascii WPA key has $KEY_LEN characters,"
+				wpa_msg stderr "it must have between 8 and 63 to be valid."
+				wpa_msg stderr "If the WPA key is a 256-bit hexadecimal key, it must have"
+				wpa_msg stderr "exactly 64 characters."
+			fi
+		fi
+	fi
+
+	wpa_cli_do "$KEY" "$KEY_TYPE" set_network "$2" "$3"
+}
+
+#####################################################################
+## formulate a usable configuration from interfaces(5) wpa- lines
+# A series of wpa_cli commands corresponding to environment variables
+# created as a result of wpa- lines in an interfaces stanza.
+#
+# NB: no-act when roaming daemon is used (to avoid prematurely
+# attaching to ctrl_interface socket)
+#
+conf_wpa_supplicant () {
+	if [ -n "$WPA_ACTION_SCRIPT" ]; then
+		return 0
+	fi
+
+	if [ "$IF_WPA_DRIVER" = "wired" ]; then
+		IF_WPA_AP_SCAN="0"
+		wpa_msg verbose "forcing ap_scan=0 (required for wired IEEE8021X auth)"
+	fi
+
+	if [ -n "$IF_WPA_ESSID" ]; then
+		# #403316, be similar to wireless tools
+		IF_WPA_SSID="$IF_WPA_ESSID"
+	fi
+	
+	wpa_cli_do "$IF_WPA_AP_SCAN" raw \
+		ap_scan wpa-ap-scan
+	
+	wpa_cli_do "$IF_WPA_PREAUTHENTICATE" raw \
+		preauthenticate wpa-preauthenticate
+		
+	if [ -n "$IF_WPA_SSID" ] || [ "$IF_WPA_DRIVER" = "wired" ] || \
+		[ -n "$IF_WPA_KEY_MGMT" ]; then
+		
+		case "$IF_WPA_SSID" in
+			'"'*'"')
+				IF_WPA_SSID=$(echo -n "$IF_WPA_SSID" | sed 's/^"//;s/"$//')
+				;;
+			*)
+				;;
+		esac
+		
+		WPA_ID=$(wpa_cli add_network)
+
+		wpa_msg verbose "configuring network block -- $WPA_ID"
+		
+		wpa_cli_do "$IF_WPA_SSID" ascii \
+			set_network ssid wpa-ssid
+		
+		wpa_cli_do "$IF_WPA_PRIORITY" raw \
+			set_network priority wpa-priority
+		
+		wpa_cli_do "$IF_WPA_BSSID" raw \
+			set_network bssid wpa-bssid
+		
+		if [ -s "$IF_WPA_PSK_FILE" ]; then
+			IF_WPA_PSK=$(cat "$IF_WPA_PSK_FILE")
+		fi
+		
+		# remain compat with wpa-passphrase-file
+		if [ -s "$IF_WPA_PASSPHRASE_FILE" ]; then
+			IF_WPA_PSK=$(cat "$IF_WPA_PASSPHRASE_FILE")
+		fi
+		
+		# remain compat with wpa-passphrase
+		if [ -n "$IF_WPA_PASSPHRASE" ]; then
+			IF_WPA_PSK="$IF_WPA_PASSPHRASE"
+		fi
+	
+		if [ -n "$IF_WPA_PSK" ]; then
+			wpa_key_check_and_set "$IF_WPA_PSK" \
+				psk wpa-psk
+		fi
+		
+		wpa_cli_do "$IF_WPA_PAIRWISE" raw \
+			set_network pairwise wpa-pairwise
+		
+		wpa_cli_do "$IF_WPA_GROUP" raw \
+			set_network group wpa-group
+
+		wpa_cli_do "$IF_WPA_MODE" raw \
+			set_network mode wpa-mode
+
+		wpa_cli_do "$IF_WPA_FREQUENCY" raw \
+			set_network frequency wpa-frequency
+
+		wpa_cli_do "$IF_WPA_SCAN_FREQ" raw \
+			set_network scan_freq wpa-scan-freq
+
+		wpa_cli_do "$IF_WPA_FREQ_LIST" raw \
+			set_network freq_list wpa-freq-list
+		
+		wpa_cli_do "$IF_WPA_KEY_MGMT" raw \
+			set_network key_mgmt wpa-key-mgmt
+		
+		wpa_cli_do "$IF_WPA_PROTO" raw \
+			set_network proto wpa-proto
+		
+		wpa_cli_do "$IF_WPA_AUTH_ALG" raw \
+			set_network auth_alg wpa-auth-alg
+		
+		wpa_cli_do "$IF_WPA_SCAN_SSID" raw \
+			set_network scan_ssid wpa-scan-ssid
+		
+		wpa_cli_do "$IF_WPA_IDENTITY" ascii \
+			set_network identity wpa-identity
+		
+		wpa_cli_do "$IF_WPA_ANONYMOUS_IDENTITY" ascii \
+			set_network anonymous_identity wpa-anonymous-identity
+		
+		wpa_cli_do "$IF_WPA_EAP" raw \
+			set_network eap wpa-eap
+		
+		wpa_cli_do "$IF_WPA_EAPPSK" raw \
+			set_network eappsk wpa-eappsk
+
+		wpa_cli_do "$IF_WPA_NAI" ascii \
+			set_network nai wpa-nai
+
+		wpa_cli_do "$IF_WPA_PASSWORD" ascii \
+			set_network password wpa-password
+
+		wpa_cli_do "$IF_WPA_CA_CERT" ascii \
+			set_network ca_cert wpa-ca-cert
+
+		wpa_cli_do "$IF_WPA_CA_PATH" ascii \
+			set_network ca_path wpa-ca-path
+
+		wpa_cli_do "$IF_WPA_CLIENT_CERT" ascii \
+			set_network client_cert wpa-client-cert
+
+		wpa_cli_do "$IF_WPA_PRIVATE_KEY" ascii \
+			set_network private_key wpa-private-key
+
+		wpa_cli_do "$IF_WPA_PRIVATE_KEY_PASSWD" ascii \
+			set_network private_key_passwd wpa-private-key-passwd
+		
+		wpa_cli_do "$IF_WPA_DH_FILE" ascii \
+			set_network dh_file wpa-dh-file
+
+		wpa_cli_do "$IF_WPA_SUBJECT_MATCH" ascii \
+			set_network subject_match wpa-subject-match
+
+		wpa_cli_do "$IF_WPA_ALTSUBJECT_MATCH" ascii \
+			set_network altsubject_match wpa-altsubject-match
+
+		wpa_cli_do "$IF_WPA_CA_CERT2" ascii \
+			set_network ca_cert2 wpa-ca-cert2
+
+		wpa_cli_do "$IF_WPA_CA_PATH2" ascii \
+			set_network ca_path2 wpa-ca-path2
+
+		wpa_cli_do "$IF_WPA_CLIENT_CERT2" ascii \
+			set_network client_cert2 wpa-client-cert2
+
+		wpa_cli_do "$IF_WPA_PRIVATE_KEY2" ascii \
+			set_network private_key2 wpa-private-key2
+
+		wpa_cli_do "$IF_WPA_PRIVATE_KEY_PASSWD2" ascii \
+			set_network private_key_passwd2 wpa-private-key-passwd2
+		
+		wpa_cli_do "$IF_WPA_DH_FILE2" ascii \
+			set_network dh_file2 wpa-dh-file2
+
+		wpa_cli_do "$IF_WPA_SUBJECT_MATCH2" ascii \
+			set_network subject_match2 wpa-subject-match2
+
+		wpa_cli_do "$IF_WPA_ALTSUBJECT_MATCH2" ascii \
+			set_network altsubject_match2 wpa-altsubject-match2
+		
+		wpa_cli_do "$IF_WPA_EAP_METHODS" raw \
+			set_network eap_methods wpa-eap-methods
+
+		wpa_cli_do "$IF_WPA_PHASE1" ascii \
+			set_network phase1 wpa-phase1
+
+		wpa_cli_do "$IF_WPA_PHASE2" ascii \
+			set_network phase2 wpa-phase2
+
+		wpa_cli_do "$IF_WPA_PCSC" raw \
+			set_network pcsc wpa-pcsc
+
+		wpa_cli_do "$IF_WPA_PIN" ascii \
+			set_network pin wpa-pin
+
+		wpa_cli_do "$IF_WPA_ENGINE" raw \
+			set_network engine wpa-engine
+
+		wpa_cli_do "$IF_WPA_ENGINE_ID" ascii \
+			set_network engine_id wpa-engine-id
+
+		wpa_cli_do "$IF_WPA_KEY_ID" ascii \
+			set_network key_id wpa-key-id
+
+		wpa_cli_do "$IF_WPA_EAPOL_FLAGS" raw \
+			set_network eapol_flags wpa-eapol-flags
+		
+		if [ -n "$IF_WPA_WEP_KEY0" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY0" \
+				wep_key0 wpa-wep-key0
+		fi
+		
+		if [ -n "$IF_WPA_WEP_KEY1" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY1" \
+				wep_key1 wpa-wep-key1
+		fi
+
+		if [ -n "$IF_WPA_WEP_KEY2" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY2" \
+				wep_key2 wpa-wep-key2
+		fi
+
+		if [ -n "$IF_WPA_WEP_KEY3" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY3" \
+				wep_key3 wpa-wep-key3
+		fi
+		
+		wpa_cli_do "$IF_WPA_WEP_TX_KEYIDX" raw \
+			set_network wep_tx_keyidx wpa-wep-tx-keyidx
+		
+		wpa_cli_do "$IF_WPA_PROACTIVE_KEY_CACHING" raw \
+			set_network proactive_key_caching wpa-proactive-key-caching
+			
+		wpa_cli_do "$IF_WPA_PAC_FILE" ascii \
+			set_network pac_file wpa-pac-file
+		
+		wpa_cli_do "$IF_WPA_PEERKEY" raw \
+			set_network peerkey wpa-peerkey
+			
+		wpa_cli_do "$IF_FRAGMENT_SIZE" raw \
+			set_network fragment_size wpa-fragment-size
+
+		wpa_cli_do "$IF_WPA_ID_STR" ascii \
+			set_network id_str wpa-id-str
+		
+		wpa_cli_do "$WPA_ID" raw \
+			enable_network "enabling network block"
+	fi
+}
+
+#####################################################################
+## Log wpa_cli environment variables
+wpa_log_env () {
+	wpa_msg log "WPA_IFACE=$WPA_IFACE WPA_ACTION=$WPA_ACTION"
+	wpa_msg log "WPA_ID=$WPA_ID WPA_ID_STR=$WPA_ID_STR WPA_CTRL_DIR=$WPA_CTRL_DIR"
+}
+
+#####################################################################
+## hysteresis checking
+# Networking tools such as dhcp clients used with ifupdown can
+# synthesize artificial ACTION events, particularly just after a
+# DISCONNECTED/CONNECTED events are experienced in quick succession.
+# This can lead to infinite event loops, and in extreme cases has the
+# potential to cause system instability.
+#
+wpa_hysteresis_event () {
+	echo "$(date +%s)" > "$WPA_CLI_TIMESTAMP" 2>/dev/null
+}
+
+wpa_hysteresis_check () {
+	if [ -f "$WPA_CLI_TIMESTAMP" ]; then
+		local TIME
+		local TIMESTAMP
+		local TIMEWAIT
+		TIME=$(date +%s)
+		# current time minus 4 second event buffer
+		TIMEWAIT=$(($TIME-4))
+		# get time of last event
+		TIMESTAMP=$(cat $WPA_CLI_TIMESTAMP)
+		# compare values, allowing new action to be processed 
+		# only if last action was more than 4 seconds ago
+		if [ "$TIMEWAIT" -le "$TIMESTAMP" ]; then
+			wpa_msg log "$WPA_ACTION event blocked by hysteresis check"
+			return 1
+		fi
+	fi
+
+	return 0
+}
+
+#####################################################################
+## ifupdown locking functions
+# A collection of rudimentary locking functions to lock ifup/ifdown
+# actions.
+#
+
+ifupdown_lock () {
+	ln -s lock "$WPA_CLI_IFUPDOWN"
+}
+
+ifupdown_locked () {
+	[ -L "$WPA_CLI_IFUPDOWN" ] && return 0
+
+	return 1
+}
+
+ifupdown_unlock () {
+	rm -f "$WPA_CLI_IFUPDOWN"
+}
+
+#####################################################################
+## apply mapping logic and ifup logical interface
+# Apply mapping logic via id_str or external mapping script, check
+# state of IFACE with respect to ifupdown and ifup logical interaface
+#
+ifup () {
+	local INTERFACES_FILE
+	local IFSTATE_FILE
+	local IFUP_RETVAL
+	local WPA_LOGICAL_IFACE
+
+	if [ -e /etc/network/interfaces ]; then
+		INTERFACES_FILE="/etc/network/interfaces"
+	else
+		wpa_msg log "/etc/network/interfaces does not exist, $WPA_IFACE will not be configured"
+		return 1
+	fi
+
+	if [ -e /etc/network/run/ifstate ]; then
+		# debian's ifupdown
+		IFSTATE_FILE="/etc/network/run/ifstate"
+	elif [ -e /run/network/ifstate ]; then
+		# ubuntu's
+		IFSTATE_FILE="/run/network/ifstate"
+	else
+		unset IFSTATE_FILE
+	fi
+	
+	if [ -z "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -n "$WPA_ID_STR" ]; then
+		WPA_LOGICAL_IFACE="$WPA_ID_STR"
+	fi
+	
+	if [ -z "$WPA_LOGICAL_IFACE" ] && [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
+		local WPA_MAP_STDIN
+		
+		WPA_MAP_STDIN=$(set | sed -n 's/^\(IF_WPA_MAP[0-9]*\)=.*/echo \$\1/p')
+		
+		if [ -n "$WPA_MAP_STDIN" ]; then
+			WPA_LOGICAL_IFACE=$(eval "$WPA_MAP_STDIN" | "$IF_WPA_MAPPING_SCRIPT" "$WPA_IFACE")
+		else		
+			WPA_LOGICAL_IFACE=$("$IF_WPA_MAPPING_SCRIPT" "$WPA_IFACE")
+		fi
+		
+		if [ -n "$WPA_LOGICAL_IFACE" ]; then
+			wpa_msg log "mapping script result: $WPA_LOGICAL_IFACE"
+		else
+			wpa_msg log "mapping script failed."
+		fi
+	fi
+
+	if [ -z "$WPA_LOGICAL_IFACE" ]; then
+		if [ -n "$IF_WPA_ROAM_DEFAULT_IFACE" ]; then
+			WPA_LOGICAL_IFACE="$IF_WPA_ROAM_DEFAULT_IFACE"
+		else
+			WPA_LOGICAL_IFACE="default"
+		fi
+	fi
+
+	if [ -n "$WPA_LOGICAL_IFACE" ]; then
+		if egrep -q "^iface[[:space:]]+${WPA_LOGICAL_IFACE}[[:space:]]+inet" "$INTERFACES_FILE"; then
+			: # logical network is defined
+		else
+			wpa_msg log "network settings not defined for $WPA_LOGICAL_IFACE in $INTERFACES_FILE"
+			WPA_LOGICAL_IFACE="default"
+		fi
+
+		wpa_msg log "ifup $WPA_IFACE=$WPA_LOGICAL_IFACE"
+
+		ifupdown_lock
+
+		if [ -n "$IFSTATE_FILE" ] && grep -q "^$WPA_IFACE=$WPA_IFACE" "$IFSTATE_FILE"; then
+			# Force settings over the unconfigured "master" IFACE
+			/sbin/ifup -v --force "$WPA_IFACE=$WPA_LOGICAL_IFACE"
+		else
+			/sbin/ifup -v "$WPA_IFACE=$WPA_LOGICAL_IFACE"
+		fi
+		IFUP_RETVAL="$?"
+
+		ifupdown_unlock
+	fi
+
+	if [ -d "${WPA_SUP_OMIT_DIR}" ]; then
+		wpa_msg log "creating sendsigs omission pidfile: $WPA_SUP_OMIT_PIDFILE"
+		cat "$WPA_SUP_PIDFILE" > "$WPA_SUP_OMIT_PIDFILE"
+	fi
+
+	return "$IFUP_RETVAL"
+}
+
+#####################################################################
+## ifdown IFACE
+# Check IFACE state and ifdown as requested.
+#
+ifdown () {
+	wpa_msg log "ifdown $WPA_IFACE"
+
+	ifupdown_lock
+
+	/sbin/ifdown -v "$WPA_IFACE"
+
+	ifupdown_unlock
+
+	wpa_msg log "removing sendsigs omission pidfile: $WPA_SUP_OMIT_PIDFILE"
+	rm -f "$WPA_SUP_OMIT_PIDFILE"
+}
+
+#####################################################################
+## keep IFACE scanning
+# After ifdown, the IFACE may be left "down", and inhibits 
+# wpa_supplicant's ability to continue roaming.
+#
+# NB: use iproute if present, flushing the IFACE first
+#
+if_post_down_up () {
+	if [ -x /bin/ip ]; then
+		ip addr flush dev "$WPA_IFACE" 2>/dev/null
+		ip link set "$WPA_IFACE" up
+	else
+		ifconfig "$WPA_IFACE" up
+	fi
+}

+ 172 - 0
board/GfA/Display001/rootfs/etc/wpa_supplicant/ifupdown.sh

@@ -0,0 +1,172 @@
+#!/bin/sh
+
+#####################################################################
+## Purpose
+# This file is executed by ifupdown in pre-up, post-up, pre-down and
+# post-down phases of network interface configuration. It allows
+# ifup(8), and ifdown(8) to manage wpa_supplicant(8) and wpa_cli(8)
+# processes running in daemon mode.
+#
+# /etc/wpa_supplicant/functions.sh is sourced by this file.
+#
+# This file is provided by the wpasupplicant package.
+
+#####################################################################
+# Copyright (C) 2006 - 2009 Debian/Ubuntu wpasupplicant Maintainers 
+# <pkg-wpa-devel@lists.alioth.debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# On Debian GNU/Linux systems, the text of the GPL license,
+# version 2, can be found in /usr/share/common-licenses/GPL-2.
+
+if [ -n "$IF_WPA_MAINT_DEBUG" ]; then
+	set -x
+fi
+
+# quit if we're called for the loopback
+if [ "$IFACE" = lo ]; then
+	exit 0
+fi
+
+# allow wpa_supplicant interface to be specified via wpa-iface
+# useful for starting wpa_supplicant on one interface of a bridge
+if [ -n "$IF_WPA_IFACE" ]; then
+	WPA_IFACE="$IF_WPA_IFACE"
+else
+	WPA_IFACE="$IFACE"
+fi
+
+# source functions
+if [ -f /etc/wpa_supplicant/functions.sh ]; then
+	. /etc/wpa_supplicant/functions.sh
+else
+	exit 0
+fi
+
+# quit if executables are not installed
+if [ ! -x "$WPA_SUP_BIN" ] || [ ! -x "$WPA_CLI_BIN" ]; then
+	exit 0
+fi
+
+do_start () {
+	if test_wpa_cli; then
+		# if wpa_action is active for this IFACE, do nothing
+		ifupdown_locked && exit 0
+
+		# if the administrator is calling ifup, say something useful
+		if [ "$PHASE" = "pre-up" ]; then
+			wpa_msg stderr "wpa_action is managing ifup/ifdown state of $WPA_IFACE"
+			wpa_msg stderr "execute \`ifdown --force $WPA_IFACE' to stop wpa_action"
+		fi
+		exit 1
+	elif ! set | grep -q "^IF_WPA"; then
+		# no wpa- option defined for IFACE, do nothing
+		exit 0
+	fi
+
+	# ensure stale ifupdown_lock marker is purged
+	ifupdown_unlock
+
+	# preliminary sanity checks for roaming daemon
+	if [ -n "$IF_WPA_ROAM" ]; then
+		if [ "$METHOD" != "manual" ]; then
+			wpa_msg stderr "wpa-roam can only be used with the \"manual\" inet METHOD"
+			exit 1
+		fi
+		if [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
+			if ! type "$IF_WPA_MAPPING_SCRIPT" >/dev/null; then
+				wpa_msg stderr "wpa-mapping-script \"$IF_WPA_MAPPING_SCRIPT\" is not valid"
+				exit 1
+			fi
+		fi
+		if [ -n "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -z "$IF_WPA_MAPPING_SCRIPT" ]; then
+			wpa_msg stderr "\"wpa-mapping-script-priority 1\" is invalid without a wpa-mapping-script"
+			exit 1
+		fi
+		IF_WPA_CONF="$IF_WPA_ROAM"
+		WPA_ACTION_SCRIPT="/sbin/wpa_action"
+	fi
+
+	# master function; determines if ifupdown.sh should do something or not
+	if [ -n "$IF_WPA_CONF" ] && [ "$IF_WPA_CONF" != "managed" ]; then
+		if [ ! -s "$IF_WPA_CONF" ]; then
+			wpa_msg stderr "cannot read contents of $IF_WPA_CONF"
+			exit 1
+		fi	
+		WPA_SUP_CONF_CTRL_DIR=$(sed -n -e 's/[[:space:]]*#.*//g' -e 's/[[:space:]]\+.*$//g' \
+			-e 's/^ctrl_interface=\(DIR=\)\?\(.*\)/\2/p' "$IF_WPA_CONF")
+		if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
+			WPA_CTRL_DIR="$WPA_SUP_CONF_CTRL_DIR"
+			WPA_SUP_CONF="-c $IF_WPA_CONF"
+		else
+			# specify the default ctrl_interface since none was defined in
+			# the given IF_WPA_CONF
+			WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_CTRL_DIR"
+		fi
+	else
+		# specify the default ctrl_interface
+		WPA_SUP_CONF="-C $WPA_CTRL_DIR"
+	fi
+}
+
+do_stop () {
+	if test_wpa_cli; then
+		# if wpa_action is active for this IFACE and calling ifdown,
+		# do nothing
+		ifupdown_locked && exit 0
+	elif test_wpa_supplicant; then
+		# wpa_supplicant process exists for this IFACE, but wpa_cli
+		# process does not. Allow stop mode to kill this process.
+		:
+	else
+		exit 0
+	fi
+}
+
+case "$MODE" in 
+	start)
+		do_start
+		case "$PHASE" in
+			pre-up)
+				kill_wpa_supplicant
+				init_wpa_supplicant	|| exit 1
+				conf_wpa_supplicant 	|| { kill_wpa_supplicant; exit 1; }
+				;;
+			post-up)
+				init_wpa_cli 		|| { kill_wpa_supplicant; exit 1; }
+				;;
+		esac
+		;;
+
+	stop)
+		do_stop
+		case "$PHASE" in
+			pre-down)
+				kill_wpa_cli
+				;;
+			post-down)
+				kill_wpa_supplicant
+				;;
+			*)
+				wpa_msg stderr "unknown phase: \"$PHASE\""
+				exit 1
+				;;
+		esac
+		;;
+	
+	*)
+		wpa_msg stderr "unknown mode: \"$MODE\""
+		exit 1
+		;;
+esac
+
+exit 0

+ 12 - 0
board/GfA/Display001/rootfs/etc/wpa_supplicant/wpa_supplicant.conf

@@ -0,0 +1,12 @@
+ctrl_interface=/var/run/wpa_supplicant
+ap_scan=1
+
+network={
+        ssid="GfAOffice"
+        scan_ssid=1
+        proto=RSN
+        key_mgmt=WPA-PSK
+        pairwise=CCMP TKIP
+        group=CCMP TKIP
+	psk=cb9c5e664b8c1a992d788aa647921de668e37ba930a979f876b6f3c63084d708
+}

+ 7 - 0
board/GfA/Display001/rootfs/rules.d/70-persistent-net.rules

@@ -0,0 +1,7 @@
+# This file was automatically generated by the /lib/udev/write_net_rules
+# program, run by the persistent-net-generator.rules rules file.
+#
+# You can modify it, as long as you keep each rule on a single
+# line, and change only the value of the NAME= key.
+
+#ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", KERNEL=="wlan*", ATTR{address}=="74:da:38:ec:a2:34", NAME="wlan0"

+ 2 - 0
board/GfA/Display001/rootfs/rules.d/80-wifi.rules

@@ -0,0 +1,2 @@
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/sbin/ifup %k"
+ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/sbin/ifdown %k"

+ 1 - 0
board/GfA/Display001/rootfs/sbin/wpa_action

@@ -0,0 +1 @@
+/usr/sbin/wpa_action

+ 1 - 0
board/GfA/Display001/rootfs/sbin/wpa_cli

@@ -0,0 +1 @@
+/usr/sbin/wpa_cli

+ 1 - 0
board/GfA/Display001/rootfs/sbin/wpa_passphrase

@@ -0,0 +1 @@
+/usr/sbin/wpa_passphrase

+ 1 - 0
board/GfA/Display001/rootfs/sbin/wpa_supplicant

@@ -0,0 +1 @@
+/usr/sbin/wpa_supplicant

+ 81 - 0
board/GfA/Display001/rootfs/usr/sbin/wpa_action

@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# Copyright (C) 2006 - 2009 Debian/Ubuntu wpasupplicant Maintainers 
+# <pkg-wpa-devel@lists.alioth.debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# On Debian GNU/Linux systems, the text of the GPL license,
+# version 2, can be found in /usr/share/common-licenses/GPL-2.
+
+if [ -n "$IF_WPA_ROAM_MAINT_DEBUG" ]; then
+	set -x
+fi
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+	echo "Usage: $0 IFACE ACTION"
+	exit 1
+fi
+
+# network interface
+WPA_IFACE="$1"
+# [CONNECTED|DISCONNECTED|stop|reload|check]
+WPA_ACTION="$2"
+
+if [ -f /etc/wpa_supplicant/functions.sh ]; then
+	. /etc/wpa_supplicant/functions.sh
+else
+	exit 0
+fi
+
+case "$WPA_ACTION" in
+	"CONNECTED")
+		wpa_log_env
+		wpa_hysteresis_check || exit 1
+		wpa_hysteresis_event
+		if ifup; then
+			wpa_cli status | wpa_msg log
+		else
+			wpa_cli status | wpa_msg log
+			wpa_cli reassociate
+		fi
+		;;
+
+	"DISCONNECTED")
+		wpa_log_env
+		wpa_hysteresis_check || exit 1
+		ifdown
+		if_post_down_up
+		;;
+
+	"stop"|"down")
+		test_wpa_cli && kill_wpa_cli
+		ifdown
+		test_wpa_supplicant && kill_wpa_supplicant
+		;;
+
+	"restart"|"reload")
+		test_wpa_supplicant || exit 1
+		reload_wpa_supplicant
+		;;
+	
+	"check")
+		test_wpa_supplicant || exit 1
+		test_wpa_cli || exit 1
+		;;
+
+	*)
+		echo "Unknown action: \"$WPA_ACTION\""
+		exit 1
+		;;
+esac
+
+exit 0

+ 3 - 2
configs/Display001_4.4.104_rt21_Qt5.7_defconfig

@@ -27,8 +27,9 @@ BR2_GENERATE_LOCALE="en_US en_GB de_DE de_AT de_CH fr_FR it_IT es_ES sv_FI sv_SE
 BR2_TARGET_LOCALTIME="Europe/Vienna"
 BR2_ROOTFS_POST_BUILD_SCRIPT="../GfA/board/GfA/Display001/post-build_4.4.sh"
 BR2_LINUX_KERNEL=y
-BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
-BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="file://$(TOPDIR)/../GfA/GfAkernel57.tar.gz  "
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://gogs.reru.org/GfA/linux_kernel.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="v4.4.104-bone-rt-r21"
 BR2_LINUX_KERNEL_PATCH="../GfA/board/GfA/Display001/linux_4.4.104_rt21"
 BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="../GfA/board/GfA/Display001/Display001_4.4.104_rt_defconfig"

+ 98 - 0
patches/0011-wlan-autoconfig.patch

@@ -0,0 +1,98 @@
+diff --git a/UpdateRootfs.sh.in b/UpdateRootfs.sh.in
+index 2ee5587dc8..a4456bf836 100644
+--- a/UpdateRootfs.sh.in
++++ b/UpdateRootfs.sh.in
+@@ -52,13 +52,32 @@ cp $TMP_PATH/u-boot.img /mnt
+ cp $TMP_PATH/uImage /mnt
+ cp $TMP_PATH/*.dtb /mnt
+ 
++mkdir -p $TMP_PATH/bu_cfg
++
++if [ -e /etc/network/interfaces ]
++then
++        cp /etc/network/interfaces $TMP_PATH/bu_cfg
++        rm /etc/network/interfaces
++fi
++
++if [ -e /etc/wpa_supplicant.conf ]
++then
++        cp /etc/wpa_supplicant.conf $TMP_PATH/bu_cfg/wpa_supplicant.conf_old
++        rm /etc/wpa_supplicant.conf
++fi
++
++if [ -e /etc/wpa_supplicant/wpa_supplicant.conf ]
++then
++        cp /etc/wpa_supplicant/wpa_supplicant.conf $TMP_PATH/bu_cfg
++        rm /etc/wpa_supplicant/wpa_supplicant.conf
++fi
++
+ #rootfs auspacken
+ tar -C / --exclude=./tmp --exclude=./etc/inittab \
+-	--exclude=./etc/network/interfaces \
+ 	--exclude=./etc/hosts --exclude=./etc/hostname \
+ 	--exclude=./etc/passwd --exclude=./etc/shadow \
+ 	--exclude=./etc/vncpwd --exclude=./etc/init.d/S99tincd \
+-	--exclude=./etc/hostapd.conf --exclude=./etc/wpa_supplicant.conf \
++	--exclude=./etc/hostapd.conf \
+ 	--exclude=./etc/init.d/M99tincd \
+ 	--exclude=./var/GfA/Display_GSM.ini \
+ 	--exclude=./var/cron/crontabs/root \
+@@ -67,6 +86,35 @@ tar -C / --exclude=./tmp --exclude=./etc/inittab \
+ echo "sync mmc be patient ...."
+ sync
+ sync
++# --- copy old eth0 configuration
++INTERFACE="eth0"
++IFCONFIG=$TMP_PATH/bu_cfg/interfaces
++
++(\
++cat << EOF
++# Configure Loopback
++auto lo
++iface lo inet loopback
++
++EOF
++) > /etc/network/interfaces
++
++awk -v par=$INTERFACE '/^iface/ && $2==par {f=1}/^iface/ && $2!=par {f=0}f && !/^\s*#/d && !/^\s*$/d  {print $0 }' $TMP_PATH/bu_cfg/interfaces \
++>> /etc/network/interfaces
++
++(\
++cat << EOF
++iface eth1 inet dhcp
++#---
++iface usb0 inet static
++        address 192.168.7.2
++        netmask 255.255.255.252
++#---
++iface wlan0 inet dhcp
++        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
++#
++EOF
++) >> /etc/network/interfaces
+ 
+ if [ -e /etc/init.d/S98usb_g_ether ]
+ then
+@@ -74,12 +122,21 @@ then
+ 	rm /etc/init.d/S98usb_g_ether
+ fi
+ 
+-
+ if [ -e /etc/init.d/S80ti-sgx ]
+ then
+ 	rm /etc/init.d/S80ti-sgx
+ fi
+         
++if [ -e /etc/init.d/M99_wlan_usb ]
++then
++	rm /etc/init.d/M99_wlan_usb
++fi
++
++if [ -e /etc/init.d/S99_wlan_usb ]
++then
++	rm /etc/init.d/S99_wlan_usb
++fi
++
+ #echo "Update Firmware"
+ #echo "."
+ #/root/spi_tivia /root/btm43_0107.bin >/dev/null