[package] base-files: also regenerate wifi config if existing config contains only...
[openwrt/svn-archive/archive.git] / package / base-files / files / etc / init.d / network
index ef415957cc9a1a4595eef29405ed3d4a770f703f..43d0a842322b51e8eed9b3676d4d4da6b1702d44 100755 (executable)
@@ -2,25 +2,26 @@
 # Copyright (C) 2006 OpenWrt.org
 
 START=40
-STOP=40
+STOP=90
 
 boot() {
        setup_switch() { return 0; }
 
        include /lib/network
        setup_switch
-       [ -s /etc/config/wireless ] || \
+       grep -qs config /etc/config/wireless && {
+               /sbin/wifi up
+       } || {
+               rm -f /etc/config/wireless
                /sbin/wifi detect > /etc/config/wireless
-       /sbin/wifi up
+       }
 }
 
 start() {
-       ifup -a
-       /sbin/wifi up
-}
-
-restart() {
-       setup_switch()
+       setup_switch() { return 0; }
+       
+       include /lib/network
+       setup_switch
        ifup -a
        /sbin/wifi up
 }
@@ -28,3 +29,7 @@ restart() {
 stop() {
        ifdown -a
 }
+
+restart() {
+       start
+}