From 27871c0dc3697fd16ef845b3808b8c032ca6ba43 Mon Sep 17 00:00:00 2001
From: Daniel Ehlers <danielehlers@mindeye.net>
Date: Mon, 20 Jan 2014 00:10:05 +0100
Subject: [PATCH] gluon-autoupdater: Enable list of mirrors for manifest and
 firmware.

Instead of a single url this patch allows to have a list of urls. So in case
of network instability a router can still reach local mesh-cloud server to pull
a update from. In this stage the autoupdater simply tries every mirror until
one passes all tests.
---
 .../gluon-autoupdater/files/usr/sbin/autoupdater    | 13 +++++++++++--
 package/gluon-autoupdater/invariant.pl              |  6 +++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/package/gluon-autoupdater/files/usr/sbin/autoupdater b/package/gluon-autoupdater/files/usr/sbin/autoupdater
index 99ff78f42..773d67c7d 100755
--- a/package/gluon-autoupdater/files/usr/sbin/autoupdater
+++ b/package/gluon-autoupdater/files/usr/sbin/autoupdater
@@ -19,7 +19,7 @@ if test "a$1" != "a-f"; then
   fi
 fi
 
-BASE=$(uci get autoupdater.${BRANCH}.url)
+MIRRORS=$(uci get autoupdater.${BRANCH}.mirror)
 PUBKEYS=$(uci get autoupdater.${BRANCH}.pubkey)
 GOOD_SIGNATURES=$(uci get autoupdater.${BRANCH}.good_signatures)
 
@@ -166,4 +166,13 @@ fi
 
 my_version="$(cat "$VERSION_FILE")"
 
-autoupdate $BASE && exit 0
+for mirror in $MIRRORS; do
+
+  autoupdate $mirror && exit 0
+
+  unset fw_version
+  unset fw_md5
+  unset fw_file
+
+done
+
diff --git a/package/gluon-autoupdater/invariant.pl b/package/gluon-autoupdater/invariant.pl
index 31848133c..493eb299f 100644
--- a/package/gluon-autoupdater/invariant.pl
+++ b/package/gluon-autoupdater/invariant.pl
@@ -28,10 +28,14 @@ delete autoupdater.$name
 set autoupdater.$name=branch
 END
 
-  for (qw(url probability good_signatures)) {
+  for (qw(probability good_signatures)) {
     print "set autoupdater.$name.$_=$branch->{$_}\n";
   }
 
+  for (@{$branch->{mirrors}}) {
+    print "add_list autoupdater.$name.mirror=$_\n";
+  }
+
   for (@{$branch->{pubkeys}}) {
     print "add_list autoupdater.$name.pubkey=$_\n";
   }
-- 
GitLab