From 8f5a7c90019085dd8f02f96ab0e7a905f82e1be0 Mon Sep 17 00:00:00 2001
From: Jan-Tarek Butt <tarek@ring0.de>
Date: Tue, 19 Jul 2016 02:53:48 +0200
Subject: [PATCH] gluon-mesh-batman-adv-core: stop WLAN and batman-adv before
 autoupdater upgrades

[Matthias Schiffer:
  - improve commit message
  - add pidof check
  - also call `wifi down`
]
---
 package/gluon-mesh-batman-adv-core/Makefile                | 1 +
 .../files/usr/lib/autoupdater/abort.d/10start-network      | 5 +++++
 .../files/usr/lib/autoupdater/upgrade.d/10stop-network     | 7 +++++++
 3 files changed, 13 insertions(+)
 create mode 100755 package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/abort.d/10start-network
 create mode 100755 package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/upgrade.d/10stop-network

diff --git a/package/gluon-mesh-batman-adv-core/Makefile b/package/gluon-mesh-batman-adv-core/Makefile
index ec845341a..bd6ab4906 100644
--- a/package/gluon-mesh-batman-adv-core/Makefile
+++ b/package/gluon-mesh-batman-adv-core/Makefile
@@ -27,6 +27,7 @@ define Build/Compile
 endef
 
 define Package/gluon-mesh-batman-adv-core/install
+	$(CP) ./files/* $(1)/
 	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
 	$(INSTALL_DIR) $(1)/lib/gluon/respondd
 	$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/mesh-batman-adv-core.so
diff --git a/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/abort.d/10start-network b/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/abort.d/10start-network
new file mode 100755
index 000000000..f04d55cc7
--- /dev/null
+++ b/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/abort.d/10start-network
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+pidof netifd >/dev/null || start_enabled network
diff --git a/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/upgrade.d/10stop-network b/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/upgrade.d/10stop-network
new file mode 100755
index 000000000..a3ae8d040
--- /dev/null
+++ b/package/gluon-mesh-batman-adv-core/files/usr/lib/autoupdater/upgrade.d/10stop-network
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+wifi down
+stop network
+ip link del bat0
-- 
GitLab