fixing onos dockerfile to lay files correctly on fs.

Change-Id: I5bb3048d6426165c93a47f60fbc9517c494c6cf0
diff --git a/compose/docker-compose-auth-test.yml b/compose/docker-compose-auth-test.yml
index edebbfe..ddc294e 100644
--- a/compose/docker-compose-auth-test.yml
+++ b/compose/docker-compose-auth-test.yml
@@ -16,7 +16,7 @@
     ipv4_address: 172.25.0.100
 
  onos:
-  image: "onosproject/onos:1.8"
+  image: "cord/onos"
   ports:
    - "8101:8101" # ssh
    - "6653:6653" # OF
diff --git a/docker/Dockerfile.onos b/docker/Dockerfile.onos
index 16ba5c8..3c5a807 100644
--- a/docker/Dockerfile.onos
+++ b/docker/Dockerfile.onos
@@ -4,28 +4,21 @@
 MAINTAINER Ali Al-Shabibi <ali.al-shabibi@onlab.us>
 MAINTAINER Nathan Knuth   <nathan.knuth@tibitcom.com>
 
-ENV ONOS_APP=/root/onos/apps ONOS=/root/onos KARAF_SYS=/root/onos/apache-karaf-3.0.5/system/org VERSION=1.2-SNAPSHOT
+ENV APPS=/root/onos/apps ONOS=/root/onos KARAF_M2=/root/onos/apache-karaf-3.0.5/system VERSION=1.2-SNAPSHOT
+ENV AUX=$APPS/aux
 
-RUN apt-get update && apt-get install -y git maven unzip && git clone http://gerrit.opencord.org/olt && \
+RUN apt-get update && apt-get install -y git maven unzip && \
+    git config --global http.sslverify false && \
+    git clone http://gerrit.opencord.org/olt && \
     git clone http://gerrit.opencord.org/aaa && \
     git clone http://gerrit.opencord.org/config 
     
-RUN cd $ONOS/olt && mvn clean install 
-RUN  mkdir $ONOS_APP/org.onosproject.olt && cd $ONOS_APP/org.onosproject.olt &&\
-            cp $ONOS/olt/app/target/*.oar org.onosproject.olt.oar && unzip *.oar && touch active &&\
-            cd $KARAF_SYS && mkdir -p opencord/olt-api/$VERSION && mkdir -p opencord/olt-app/$VERSION &&\
-            unzip -d . -j $ONOS/olt/app/target/*.oar && mv olt-api-$VERSION.jar opencord/olt-api/$VERSION &&\
-            mv olt-app-$VERSION.jar opencord/olt-app/$VERSION && mv olt-app-$VERSION-features.xml opencord/olt-app/$VERSION
-RUN cd $ONOS/config && mvn clean install
-RUN  mkdir $ONOS_APP/org.opencord.cord-config && cd $ONOS_APP/org.opencord.cord-config &&\
-            cp $ONOS/config/target/*.oar org.opencord.config.oar && unzip *.oar && touch active &&\
-            cd $KARAF_SYS && mkdir -p opencord/cord-config/$VERSION && cd opencord/cord-config/$VERSION &&\ 
-            unzip -d . -j $ONOS/config/target/*.oar 
-              
-RUN cd $ONOS/aaa && mvn clean install
-RUN  mkdir $ONOS_APP/org.opencord.aaa && cd $ONOS_APP/org.opencord.aaa &&\
-            cp $ONOS/aaa/target/*.oar org.opencord.aaa.oar && unzip *.oar && touch active &&\
-            cd $KARAF_SYS && mkdir -p opencord/aaa/$VERSION && cd opencord/aaa/$VERSION &&\
-            unzip -d . -j $ONOS/aaa/target/*.oar
+RUN cd $ONOS/olt && mvn clean install && cd $ONOS/config && mvn clean install && cd $ONOS/aaa && mvn clean install 
+
+WORKDIR $ONOS
+
+COPY config/app-install.sh .
+
+RUN sh $ONOS/app-install.sh
 
 COPY config/netcfg.json $KARAF_ROOT/../config/network-cfg.json
diff --git a/docker/config/app-install.sh b/docker/config/app-install.sh
new file mode 100644
index 0000000..bc70817
--- /dev/null
+++ b/docker/config/app-install.sh
@@ -0,0 +1,15 @@
+touch $APPS/org.onosproject.openflow-base/active
+
+find $ONOS -name "*.oar" -path "*/target/*" | while read line; do 
+    mkdir -p $AUX && cd $AUX 
+    cp $line $AUX
+    jar -xf $AUX/*.oar
+    name=$(grep "name=" $AUX/app.xml | sed 's/<app name="//g;s/".*//g')
+    mkdir -p $APPS/$name
+    cp $AUX/app.xml $APPS/$name/app.xml
+    touch $APPS/$name/active
+    [ -f $AUX/app.png ] && cp $AUX/app.png $APPS/$name/app.png
+    cp $AUX/*.oar $APPS/$name/$name.oar
+    cp -rf $AUX/m2/* $KARAF_M2
+    rm -fr $AUX
+done