From 882c31231d5ae91af274e227f95403858ff62c01 Mon Sep 17 00:00:00 2001
From: Saverio Proto <saverio.proto@switch.ch>
Date: Mon, 30 Jan 2017 11:30:35 +0100
Subject: [PATCH] Fix BASEDIR to package Kolla with snapcraft.io

Change-Id: Ifc2af94e30183c86166ec2946d107becd53fd82f
---
 tools/kolla-ansible | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index c49d8f19fe..8c9aeb51ec 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -5,12 +5,16 @@
 function find_base_dir {
     local real_path=$(python -c "import os;print(os.path.realpath('$0'))")
     local dir_name="$(dirname "$real_path")"
-    if [[ ${dir_name} == "/usr/bin" ]]; then
-        BASEDIR=/usr/share/kolla
-    elif [[ ${dir_name} == "/usr/local/bin" ]]; then
-        BASEDIR=/usr/local/share/kolla
+    if [ -z "$SNAP" ]; then
+        if [[ ${dir_name} == "/usr/bin" ]]; then
+            BASEDIR=/usr/share/kolla
+        elif [[ ${dir_name} == "/usr/local/bin" ]]; then
+            BASEDIR=/usr/local/share/kolla
+        else
+            BASEDIR="$(dirname ${dir_name})"
+        fi
     else
-        BASEDIR="$(dirname ${dir_name})"
+        BASEDIR="$SNAP/share/kolla"
     fi
 }