On 6/5/11 10:54 AM, Peter Wagner wrote:
> 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
You misunderstand me. I'm saying that "wifi detect" should generate an output
file regardless of whether /etc/config/wireless exists or not. Capture the
output into /tmp, and if it's different from what's in /etc/config/wireless
then copy it over.
-Philip
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel