diff mbox

[LEDE-DEV,v3,1/4] base-files: generate /etc/config/wireless, if it doesn't exist

Message ID 4f69ed95593be50265c586c8f4be50ca3eca885c.1476631806.git.chunkeey@gmail.com
State Accepted
Delegated to: Felix Fietkau
Headers show

Commit Message

Christian Lamparter Oct. 17, 2016, 1:59 p.m. UTC
From: Mathias Kresin <dev@kresin.me>

This patch adds a check in "wifi detect" to test if the wireless
configuration file does exist. If it doesn't exist, an empty
/etc/config/wireless file will be created.

This is necessary because uci doesn't create new files,
instead the tool just exits with "uci: Entry not found".

Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 package/base-files/files/sbin/wifi | 2 ++
 1 file changed, 2 insertions(+)

Comments

Bastian Bittorf Oct. 18, 2016, 10:05 a.m. UTC | #1
* Christian Lamparter <chunkeey@googlemail.com> [18.10.2016 08:41]:
>  wifi_detect() {
> +	[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
> +
>  	for driver in $DRIVERS; do (
>  		if eval "type detect_$driver" 2>/dev/null >/dev/null; then
>  			eval "detect_$driver" || echo "$driver: Detect failed" >&2

maybe move it down, otherwise also on
boards without wifi we touch '/etc/config/wireless':

if eval "detect_$driver" 2>/dev/null >/dev/null; then
  [ -f /etc/config/wireless ] || touch /etc/config/wireless
   ...
else
  ...
fi

bye, bastian
Christian Lamparter Oct. 18, 2016, 12:22 p.m. UTC | #2
On Tuesday, October 18, 2016 12:05:43 PM CEST Bastian Bittorf wrote:
> * Christian Lamparter <chunkeey@googlemail.com> [18.10.2016 08:41]:
> >  wifi_detect() {
> > +	[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
> > +
> >  	for driver in $DRIVERS; do (
> >  		if eval "type detect_$driver" 2>/dev/null >/dev/null; then
> >  			eval "detect_$driver" || echo "$driver: Detect failed" >&2
> 
> maybe move it down, otherwise also on
> boards without wifi we touch '/etc/config/wireless':
> 
> if eval "detect_$driver" 2>/dev/null >/dev/null; then
>   [ -f /etc/config/wireless ] || touch /etc/config/wireless
>    ...
> else
>   ...
> fi

Ah there's a reason behind this exact location.

Patch 3/4 makes it so that wifi config is run as part of the
ieee80211/net(broadcom-wl) hotplug handler. So boards without
wifi will never run /sbin/wifi config and hence don't create
/etc/config/wireless. This also means that they always will
spend 1 Second sleeping in /etc/init.d/boot... But this is what
we currently do anyway.

Regards,
Christian
diff mbox

Patch

diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi
index 6bd3544..2ef333a 100755
--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -146,6 +146,8 @@  wifi_reload() {
 }
 
 wifi_detect() {
+	[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
+
 	for driver in $DRIVERS; do (
 		if eval "type detect_$driver" 2>/dev/null >/dev/null; then
 			eval "detect_$driver" || echo "$driver: Detect failed" >&2