Quellcode durchsuchen

RC "Athens" (wan wifi connection check/recover, persistence)

Danja Vasiliev vor 9 Jahren
Ursprung
Commit
18a4e7b77b

+ 3 - 0
openwrt/common/etc/rc.local

@@ -7,4 +7,7 @@
 /opt/lib/scripts/sg-data-mount.sh &
 /opt/lib/scripts/sg-data-dirs.sh &
 
+## check if wifi wan is up
+/opt/lib/scripts/wifiwan-check.sh &
+
 exit 0

+ 1 - 1
openwrt/common/etc/uci-defaults/21-gen-psk

@@ -1 +1 @@
-[ -f /etc/host.psk ] || /usr/sbin/openvpn --genkey --secret /etc/host.psk
+[ -f /etc/openvpn/host.psk ] || /usr/sbin/openvpn --genkey --secret /etc/openvpn/host.psk

+ 3 - 3
openwrt/common/opt/lib/admin/admin2.cgi

@@ -15,7 +15,7 @@
 
 readonly _WWW='/www'
 readonly _PWDFILE="/etc/lighhtpd/htpasswd"
-readonly _HOSTPSK='/etc/host.psk'
+readonly _HOSTPSK='/etc/openvpn/host.psk'
 readonly _TMP='/tmp'
 readonly _LOG="${_WWW}/log/admin.log"
 readonly _SCRIPTS='/opt/lib/scripts'
@@ -170,9 +170,9 @@ wanSet() {
       ssidChange || showMesg 'wanSet: Wireless configuration failed'
     else
       doUci commit network &&
-      doUci commit wireless &&
+      doUci commit wireless 
       dtach -n -zE $_SCRIPTS/net-restart.sh &>/dev/null
-    fi
+  fi
     _ERR=$?
     [[ $_ERR -eq 0 ]] &&
     showMesg 'Internet connection is being configured' '25' 'check your Internet connection on completion' ||

+ 4 - 0
openwrt/common/opt/lib/cgi/admin-pre-rescue.cgi

@@ -6,4 +6,8 @@ sleep 2
 /etc/init.d/network reload
 /etc/init.d/dnsmasq reload
 
+#sleep 2
+
+#/opt/lib/scripts/wifiwan-check.sh >> /tmp/wifi.log
+
 exit 0

+ 42 - 0
openwrt/common/opt/lib/scripts/sg-vpn-check.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+
+. /lib/functions/network.sh
+
+## if wan is wireless
+unset _COUNT
+while network_get_physdev _IFNAME wan && [[ ! $_IFNAME =~ 'wlan' ]]; do
+  let _COUNT++
+  if [[ $_COUNT -ge 30 ]]; then
+    echo 'wan is not wifi'
+    exit
+  fi
+  echo "waiting for wan conf.. $((30-$_COUNT))"
+  sleep 1
+done
+
+checkWan() {
+  if [[ "$(iw $_IFNAME link)" =~ 'Connected ' ]]; then
+    if [[ "$(route | grep $_IFNAME)" =~ '0.0.0.0' ]]; then
+      return 1
+    fi
+  fi
+  return 0
+}
+
+## if wan is connected and is default gw
+unset _COUNT
+while checkWan; do
+  let _COUNT++
+  if [[ $_COUNT -ge 60 ]]; then
+    echo 'wan wifi is dead, disabling'
+    uci set wireless.@wifi-iface[-1].disabled=1
+    uci commit wireless
+    wifi
+    exit
+  fi
+  echo "waiting for wan wifi.. $((60-$_COUNT))"
+  sleep 1
+done
+
+echo 'wan wifi is connected'
+exit

+ 1 - 0
openwrt/tmp/bin/dropbear

@@ -0,0 +1 @@
+../sbin/dropbear

+ 1 - 0
openwrt/tmp/sbin/dropbear

@@ -0,0 +1 @@
+dropbear-2013.59

BIN
openwrt/tmp/sbin/dropbear-2013.59


BIN
openwrt/tmp/sbin/dropbear-2014.63