Browse Source

ffho-autoupdater-wifi-fallback: fake wpa_supplicant

and write log messages
Karsten Böddeker 8 years ago
parent
commit
a92c0d6a00

+ 1 - 1
ffho/ffho-autoupdater-wifi-fallback/Makefile

@@ -13,7 +13,7 @@ define Package/ffho-autoupdater-wifi-fallback
   SECTION:=ffho
   CATEGORY:=FFHO
   TITLE:=Implements switching to fallback mode if we are cut off from the mesh
-  DEPENDS:=+gluon-autoupdater +libiwinfo-lua +wpa-supplicant-mini
+  DEPENDS:=+gluon-autoupdater +libiwinfo-lua +iw
   MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
   URL:=https://git.c3pb.de/freifunk-pb/ffho-packages
 endef

+ 12 - 4
ffho/ffho-autoupdater-wifi-fallback/files/usr/sbin/autoupdater-wifi-fallback

@@ -64,31 +64,38 @@ local function connectivity_check()
     end
   end
 
+  io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "connectivity check failed"')
   return false
 end
 
 local function run_autoupdater()
+  io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "execute the autoupdater"')
   os.execute("/usr/sbin/autoupdater -f -b " .. branch_name)
 end
 
-local function switch_to_fallback_mode(wifiNetwork, radio)
-  print("connect to: " .. wifiNetwork .. " on " .. radio)
+local function switch_to_fallback_mode(ssid, radio)
+  print("connect to: " .. ssid .. " on " .. radio)
+  io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "going to fallback mode"')
   uci:delete_all('wireless', 'wifi-iface')
   uci:section('wireless', 'wifi-iface', 'fallback',
     {
       device = radio,
       network = 'fallback',
-      mode = 'managed',
+      mode = 'sta',
       disabled = 0,
       macaddr = gluon.generate_mac(3, 10),
       ifname = 'fallback',
       encryption = 'none',
-      ssid = wifiNetwork,
     }
   )
   uci:set('wireless', radio, 'disabled', 0)
   uci:save('wireless')
 
+  local f = io.open('/tmp/wpa-supplicant-fake', 'w')
+  f:write('#!/bin/sh\niw dev fallback connect -w ' .. ssid)
+  f:close()
+  fs.chmod('/tmp/wpa-supplicant-fake', 755)
+
   io.popen("wifi")
   os.execute("sleep 5")
   os.execute("echo \"2\" > /proc/sys/net/ipv6/conf/fallback/accept_ra")
@@ -98,6 +105,7 @@ end
 
 local function revert_to_standard_mode()
   print("Going back to standard config")
+  io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "going back to standard mode"')
   os.execute("/etc/init.d/network restart")
   os.execute("sleep 30")
 end

+ 1 - 0
ffho/ffho-autoupdater-wifi-fallback/files/usr/sbin/wpa_supplicant

@@ -0,0 +1 @@
+/tmp/wpa-supplicant-fake