From 999956633b9eb363f00aa4fe478a8d144a4c951c Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 7 Mar 2017 17:20:03 +0000
Subject: LinHES-system: add_storage.py: if can't find last disk num falback to
 /data/storage/disk# links

---
 abs/core/LinHES-system/PKGBUILD       |  4 ++--
 abs/core/LinHES-system/add_storage.py | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 6e45a57..c6280b4 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=8.4
-pkgrel=20
+pkgrel=21
 arch=('i686' 'x86_64')
 install=system.install
 pkgdesc="Everything that makes LinHES an automated system"
@@ -101,7 +101,7 @@ md5sums=('c6e6b83a1f4c35ef4501e277657ab2ac'
          'bc69a520add58ede9b060c73e67ace13'
          '74e17d6f7453c52d56fecaed5c3f6ad5'
          '47e093e8cfe4b5b96602358e1f540832'
-         'df3d5af03954168852b7e5c66fd174c6'
+         'dbd51b9146f843acb582bb5722adbe37'
          '0c81e5cad656f6260e39cd7585b1421a'
          'e5bb027c54a2727d0bcf8d6fb357ba32'
          '2c005d95312018bef80092136f80f254'
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py
index 82de56e..c172f6f 100755
--- a/abs/core/LinHES-system/add_storage.py
+++ b/abs/core/LinHES-system/add_storage.py
@@ -564,7 +564,20 @@ def last_disk_num():
         disk_num = parser.get('storage', 'disk_num')
         num_list.append(int(disk_num))
         num_list.sort()
-    return num_list[-1]
+    try:
+        return num_list[-1]
+    except:
+        # conf file or disk_num is missing so fallback to /data/storage/disk# links
+        for disk_name in glob.glob('/data/storage/disk*'):
+            disk_num = disk_name.strip('/data/storage/disk')
+            num_list.append(int(disk_num))
+            num_list.sort()
+        try:
+            return num_list[-1]
+        except:
+            print "Couldn't find last disk number."
+            sys.exit(1)
+
 #--------------------------------------------
 
 def main(scan_only, destruction, no_mount, install_call, dir_sg):
-- 
cgit v0.12

