Am Sonntag, 5. Mai 2011, 19:54:22 schrieb Peter Wagner:
> Am Freitag, 3. Mai 2011, 04:11:43 schrieb Philip Prindeville:
> > On 5/31/11 10:48 AM, Peter Wagner wrote:
> > > Am Dienstag, 31. Mai 2011, 17:52:58 schrieb Philip Prindeville:
> > >> On 5/30/11 4:00 PM, Peter Wagner wrote:
> > >>> Hi,
> > >>> 
> > >>> while i was reading some init files i stumbled upon this:
> > >>> 
> > >>> /sbin/wifi detect >> /etc/config/wireless
> > >>> 
> > >>> grep -qs config /etc/config/wireless && {
> > >>> 
> > >>>         /sbin/wifi up
> > >>> 
> > >>> } || {
> > >>> 
> > >>>         rm -f /etc/config/wireless
> > >>> 
> > >>> }
> > >>> 
> > >>> this means:
> > >>>> /sbin/wifi detect >> /etc/config/wireless
> > >>> 
> > >>> /sbin/wifi only outputs something if /etc/config/wireless doesnt
> > >>> exist but even if the files exist /etc/config/wireless modification
> > >>> time gets updated. this means even when the wifi is allready
> > >>> configured the modtime of the file gets updated everytime the system
> > >>> boots.
> > >>> 
> > >>> i created this patch - maybe there is a better way to fix this.
> > >> 
> > >> I would test for the file changing with respect to the existing copy,
> > >> rather than non-zero length.
> > >> 
> > >> If you change out hardware, or if you had a wireless interface but now
> > >> have removed it, you don't want to retain invalid information.
> > >> 
> > >> I'd use "cmp -s" to compare the two files.
> > > 
> > > this wont work - because if the file wireless exists the script output
> > > nothing ... so if you attach a new wifi card - you would have to remove
> > > the file and restart the router or do a wifi detect >
> > > /etc/config/wireless ...
> > > 
> > > and if the file is empty (the one wifi detect created) cmp will also
> > > return something != 0...
> > 
> > That's a glitch. Why should "wifi detect" care if there's a file already
> > present or not? It should ignore it.
> 
> yeah but if i have a /etc/config/wireless file and do a wifi detect i get
> no output - when i delete the file it gives me the standard file... like
> 
> server /root # ls -la /etc/config/wireless
> -rw-r--r--    1 root     root           321 Jan 27 00:27
> /etc/config/wireless server /root # wifi detect
> server /root # rm /etc/config/wireless
> server /root # wifi detect
> config wifi-device  radio0
>         option type     mac80211
>         option channel  11
>         option macaddr  xx:xx:xx:xx:xx:xx
>         option hwmode   11g
> 
>         # REMOVE THIS LINE TO ENABLE WIFI:
>         option disabled 1
> 
> config wifi-iface
>         option device   radio0
>         option network  lan
>         option mode     ap
>         option ssid     OpenWrt
>         option encryption none
> 
> 
> i modified the patch, now it doesnt use wc anymore ....
> 
> 
> regards
> Peter
> 
> > _______________________________________________
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/mailman/listinfo/openwrt-devel

no this patch wont work .... the old one with wc -l is the working one ;)

regards
diff --git a/package/base-files/files/etc/init.d/network b/package/base-files/files/etc/init.d/network
index c2095a4..906e3a3 100755
--- a/package/base-files/files/etc/init.d/network
+++ b/package/base-files/files/etc/init.d/network
@@ -9,12 +9,15 @@ boot() {
 
 	include /lib/network
 	setup_switch
-	/sbin/wifi detect >> /etc/config/wireless
+
+	/sbin/wifi detect > /tmp/wireless.tmp
+	[ $(cat /tmp/wireless.tmp|wc -l) != 0 ] && {
+		cat /tmp/wireless.tmp >> /etc/config/wireless
+	}
 	grep -qs config /etc/config/wireless && {
 		/sbin/wifi up
-	} || {
-		rm -f /etc/config/wireless
 	}
+	rm -f /tmp/wireless.tmp
 
 	scan_interfaces
 
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to