Am Montag, 6. Mai 2011, 07:09:43 schrieb Philip Prindeville:
> On 6/5/11 11:10 AM, Peter Wagner wrote:
> > Am Sonntag, 5. Mai 2011, 20:02:13 schrieb Peter Wagner:
> >> 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
> > 
> > sorry for the noise but as the file is created one line befor the test it
> > can be assumend the file is there so . this version was correct ...
> > 
> > regards
> > peter
> 
> +             cat /tmp/wireless.tmp >> /etc/config/wireless
> 
> 
> Why ">>" and not ">" ?
> 
> -Philip
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel


okay i read throug the source of wifi and i think it works like this:
when there are at least this lines

config wifi-device  radio0
        option macaddr  fe:fe:fe:fe:fe:fe

and the only card that is on the pc/router has this mac adress wifi detect 
ouputs nothing ...
if the mac address of the wifi card is different, it will outbut something.

so testing if the file (/etc/config/wireless) is there is no good idea at all. 

i cant really test what happens when there are two cards attached, as i only 
have one ...but i think that if a second card is attached and the first one is 
allready configured, it would overwrite the whole config with default setting 
for the second card and the settings for the first card would be lost, on the 
next boot it would overwrite the file again with settings for the first card 
and the settings for the second one would be lost. therefoor no ">" instead of 
">>".

- Peter


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to