From 20e45d063feaa9a323742a32ccb30c566ae1d440 Mon Sep 17 00:00:00 2001
From: Jim Van Fleet <jim.van.fleet@levvel.io>
Date: Wed, 14 Sep 2016 11:46:58 -0400
Subject: [PATCH] Adding autoexec support

---
 Dockerfile                   |  4 +++-
 Jenkinsfile                  | 13 ++++++++++---
 common.bash                  |  2 +-
 container_files/bin/start.sh |  4 ++++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 7e14e0d2..35f18926 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM bigfleet/shibboleth_sp
+FROM tier/shibboleth_sp
 
 # Define args and set a default value
 ARG maintainer=tier
@@ -32,6 +32,8 @@ RUN mkdir -p /opt/grouper/$VERSION \
         mlocate \
       && yum clean all
 
+
+
 # The installer creates a HSQL DB which we ignore later
 
 WORKDIR /opt/grouper/$version
diff --git a/Jenkinsfile b/Jenkinsfile
index 48d38088..be887a37 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -36,7 +36,7 @@ node('docker') {
 
   stage 'Build'
     try{
-      sh 'bin/build.sh &> debug'
+      sh 'bin/rebuild.sh &> debug'
     } catch(error) {
       def error_details = readFile('./debug');
       def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}"
@@ -49,8 +49,15 @@ node('docker') {
 
   stage 'Tests'
 
-    sh 'bin/test.sh'
-    // should build a finally construct here
+    try{
+      sh 'bin/test.sh &> debug'
+    } catch(error) {
+      def error_details = readFile('./debug');
+      def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
+      sh "rm -f ./debug"
+      handleError(message)
+    }
+    
   stage 'Stop container'
 
     sh 'bin/ci-stop.sh'
diff --git a/common.bash b/common.bash
index 1f1766ff..0dc7e90e 100644
--- a/common.bash
+++ b/common.bash
@@ -1,3 +1,3 @@
-maintainer="bigfleet"
+maintainer="tier"
 imagename="grouper"
 version="2.3.0"
\ No newline at end of file
diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh
index f72508ed..48c58e44 100755
--- a/container_files/bin/start.sh
+++ b/container_files/bin/start.sh
@@ -11,12 +11,14 @@ then
   if [ "$laststatus" != "0" ]; then
       echo "Not composed non-zero exit status: $laststatus" >> $log
       echo "Not composed non-zero exit status: $laststatus"
+      /opt/autoexec/bin/firstrun.sh
       exit 1
   else
       echo "Grouper was configured" >>$log
       echo "Grouper was configured"
       echo "Starting tomcat and apache" >>$log
       echo "Starting tomcat and apache"
+      /opt/autoexec/bin/firstrun.sh
       /usr/local/bin/httpd-shib-foreground &
       /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run 
   fi
@@ -42,12 +44,14 @@ else
   if [ "$laststatus" != "0" ]; then
       echo "Composed non-zero exit status: $laststatus" >> $log
       echo "Composed non-zero exit status: $laststatus"
+      /opt/autoexec/bin/firstrun.sh
       exit 1
   else
       echo "Grouper was configured" >>$log
       echo "Grouper was configured"
       echo "Starting tomcat and apache" >>$log
       echo "Starting tomcat and apache"
+      /opt/autoexec/bin/firstrun.sh
       date >> $log
       /usr/local/bin/httpd-shib-foreground &
       /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run