Author: tucu
Date: Thu Apr 18 22:38:25 2013
New Revision: 1469612

URL: http://svn.apache.org/r1469612
Log:
OOZIE-670 Merge addtowar and oozie-setup scripts into one (bowenzhangusa via 
tucu)

Modified:
    oozie/trunk/distro/src/main/bin/oozie-setup.sh
    oozie/trunk/docs/src/site/twiki/AG_Install.twiki
    oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki
    oozie/trunk/release-log.txt

Modified: oozie/trunk/distro/src/main/bin/oozie-setup.sh
URL: 
http://svn.apache.org/viewvc/oozie/trunk/distro/src/main/bin/oozie-setup.sh?rev=1469612&r1=1469611&r2=1469612&view=diff
==============================================================================
--- oozie/trunk/distro/src/main/bin/oozie-setup.sh (original)
+++ oozie/trunk/distro/src/main/bin/oozie-setup.sh Thu Apr 18 22:38:25 2013
@@ -20,12 +20,8 @@
 function printUsage() {
   echo
   echo " Usage  : oozie-setup.sh <Command and OPTIONS>"
-  echo "          prepare-war [-hadoop HADOOP_VERSION HADOOP_PATH] [-extjs 
EXTJS_PATH] [-jars JARS_PATH] [-secure]"
-  echo "                      (prepare-war is to prepare war files for oozie)"
-  echo "                      (Hadoop version 
[0.20.1|0.20.2|0.20.104|0.20.200|0.23.x|2.x] and Hadoop install dir)"
-  echo "                      (EXTJS_PATH is expanded or ZIP, to enable the 
Oozie webconsole)"
-  echo "                      (JARS_PATH is multiple JAR path separated by 
':')"
-  echo "                      (-secure will configure the war file to use 
HTTPS (SSL))"
+  echo "          prepare-war [-d directory] [-secure] (-d identifies an 
alternative directory for processing jars"
+  echo "                                                -secure will configure 
the war file to use HTTPS (SSL))"
   echo "          sharelib create -fs FS_URI [-locallib SHARED_LIBRARY] 
(create sharelib for oozie,"
   echo "                                                                FS_URI 
is the fs.default.name"
   echo "                                                                for 
hdfs uri; SHARED_LIBRARY, path to the"
@@ -37,12 +33,67 @@ function printUsage() {
   echo "                                                                in 
HDFS)"
   echo "          sharelib upgrade -fs FS_URI [-locallib SHARED_LIBRARY] 
(upgrade existing sharelib, fails if there"
   echo "                                                                  is 
no existing sharelib installed in HDFS)"
+  echo "          db create|upgrade|postupgrade -run [-sqlfile <FILE>] 
(create, upgrade or postupgrade oozie db with an"
+  echo "                                                                
optional sql File)"
   echo "          (without options prints this usage information)"
   echo
   echo " EXTJS can be downloaded from 
http://www.extjs.com/learn/Ext_Version_Archives";
   echo
 }
 
+#Creating temporary directory
+function prepare() {
+  tmpDir=/tmp/oozie-war-packing-$$
+  rm -rf ${tmpDir}
+  mkdir ${tmpDir}
+  tmpWarDir=${tmpDir}/oozie-war
+  mkdir ${tmpWarDir}
+  checkExec "creating staging directory ${tmpDir}"
+}
+
+#cleans up temporary directory
+function cleanUp() {
+  if [ ! "${tmpDir}" = "" ]; then
+    rm -rf ${tmpDir}
+    checkExec "deleting staging directory ${tmpDir}"
+  fi
+}
+
+#check execution of command
+function checkExec() {
+  if [ $? -ne 0 ]
+  then
+    echo
+    echo "Failed: $1"
+    echo
+    cleanUp
+    exit -1;
+  fi
+}
+
+#check that a file/path exists
+function checkFileExists() {
+  if [ ! -e ${1} ]; then
+    echo
+    echo "File/Dir does no exist: ${1}"
+    echo
+    cleanUp
+    exit -1
+  fi
+}
+
+#check that a file/path does not exist
+function checkFileDoesNotExist() {
+  if [ -e ${1} ]; then
+    echo
+    echo "File/Dir already exists: ${1}"
+    echo
+    cleanUp
+    exit -1
+  fi
+}
+
+
 # resolve links - $0 may be a softlink
 PRG="${0}"
 
@@ -62,12 +113,10 @@ BASEDIR=`cd ${BASEDIR}/..;pwd`
 source ${BASEDIR}/bin/oozie-sys.sh -silent
 
 addExtjs=""
-addJars=""
 addHadoopJars=""
+additionalDir=""
 extjsHome=""
 jarsPath=""
-hadoopVersion=""
-hadoopPath=""
 prepareWar=""
 inputWar="${OOZIE_HOME}/oozie.war"
 outputWar="${CATALINA_BASE}/webapps/oozie.war"
@@ -77,13 +126,12 @@ secureConfigsDir="${CATALINA_BASE}/conf/
 
 while [ $# -gt 0 ]
 do
-  if [ "$1" = "sharelib" ]; then
-    shift
-    OOZIEFSCLI_OPTS="-Doozie.home.dir=${OOZIE_HOME}";
-    OOZIEFSCLI_OPTS="${OOZIEFSCLI_OPTS} -Doozie.config.dir=${OOZIE_CONFIG}";
-    OOZIEFSCLI_OPTS="${OOZIEFSCLI_OPTS} -Doozie.log.dir=${OOZIE_LOG}";
-    OOZIEFSCLI_OPTS="${OOZIEFSCLI_OPTS} -Doozie.data.dir=${OOZIE_DATA}";
-    OOZIEFSCLI_OPTS="${OOZIEFSCLI_OPTS} 
-Dderby.stream.error.file=${OOZIE_LOG}/derby.log"
+  if [ "$1" = "sharelib" ] || [ "$1" = "db" ]; then
+    OOZIE_OPTS="-Doozie.home.dir=${OOZIE_HOME}";
+    OOZIE_OPTS="${OOZIE_OPTS} -Doozie.config.dir=${OOZIE_CONFIG}";
+    OOZIE_OPTS="${OOZIE_OPTS} -Doozie.log.dir=${OOZIE_LOG}";
+    OOZIE_OPTS="${OOZIE_OPTS} -Doozie.data.dir=${OOZIE_DATA}";
+    OOZIE_OPTS="${OOZIE_OPTS} -Dderby.stream.error.file=${OOZIE_LOG}/derby.log"
 
     OOZIECPPATH=""
     OOZIECPPATH=${BASEDIR}/libtools/'*':${BASEDIR}/libext/'*'
@@ -94,52 +142,20 @@ do
       JAVA_BIN=${JAVA_HOME}/bin/java
     fi
 
-    ${JAVA_BIN} ${OOZIEFSCLI_OPTS} -cp ${OOZIECPPATH} 
org.apache.oozie.tools.OozieSharelibCLI "${@}"
-    exit 0
-  elif [ "$1" = "-extjs" ]; then
-    shift
-    if [ $# -eq 0 ]; then
-      echo
-      echo "Missing option value, ExtJS path"
-      echo
-      printUsage
-      exit -1
-    fi
-    extjsHome=$1
-    addExtjs=true
-  elif [ "$1" = "-jars" ]; then
-    shift
-    if [ $# -eq 0 ]; then
-      echo
-      echo "Missing option value, JARs path"
-      echo
-      printUsage
-      exit -1
-    fi
-    jarsPath=$1
-    addJars=true
-  elif [ "$1" = "-hadoop" ]; then
-    shift
-    if [ $# -eq 0 ]; then
-      echo
-      echo "Missing option values, HADOOP_VERSION & HADOOP_HOME_PATH"
-      echo
-      printUsage
-      exit -1
-    elif [ $# -eq 1 ]; then
-      echo
-      echo "Missing option value, HADOOP_HOME_PATH"
-      echo
-      printUsage
-      exit -1
+    if [ "$1" = "sharelib" ]; then
+      shift
+      ${JAVA_BIN} ${OOZIE_OPTS} -cp ${OOZIECPPATH} 
org.apache.oozie.tools.OozieSharelibCLI "${@}"
+    else
+      shift
+      ${JAVA_BIN} ${OOZIE_OPTS} -cp ${OOZIECPPATH} 
org.apache.oozie.tools.OozieDBCLI "${@}"
     fi
-    hadoopVersion=$1
-    shift
-    hadoopPath=$1
-    addHadoopJars=true
+    exit 0
   elif [ "$1" = "-secure" ]; then
     shift
     secure=true
+  elif [ "$1" = "-d" ]; then
+    shift
+    additionalDir=$1
   elif [ "$1" = "prepare-war" ]; then
     prepareWar=true
   else
@@ -158,7 +174,7 @@ fi
 
 echo
 
-if [ "${addExtjs}${addJars}${addHadoopJars}${prepareWar}" == "" ]; then
+if [ "${prepareWar}" == "" ]; then
   echo "no arguments given"
   printUsage
   exit -1
@@ -172,6 +188,10 @@ else
   # Adding extension JARs
 
   libext=${OOZIE_HOME}/libext
+  if [ "${additionalDir}" != "" ]; then
+    libext=${additionalDir}
+  fi
+
   if [ -d "${libext}" ]; then
     if [ `ls ${libext} | grep \.jar\$ | wc -c` != 0 ]; then
       for i in "${libext}/"*.jar; do
@@ -193,18 +213,30 @@ else
     fi
   fi
 
-  OPTIONS=""
-  if [ "${addExtjs}" != "" ]; then
-    OPTIONS="-extjs ${extjsHome}"
+  prepare
+
+  checkFileExists ${inputWar}
+  checkFileDoesNotExist ${outputWar}
+
+  if [ "${addExtjs}" = "true" ]; then
+    checkFileExists ${extjsHome}
   else
     echo "INFO: Oozie webconsole disabled, ExtJS library not specified"
   fi
-  if [ "${addJars}" != "" ]; then
-    OPTIONS="${OPTIONS} -jars ${jarsPath}"
-  fi
-  if [ "${addHadoopJars}" != "" ]; then
-    OPTIONS="${OPTIONS} -hadoop ${hadoopVersion} ${hadoopPath}"
+
+  if [ "${addJars}" = "true" ]; then
+      for jarPath in ${jarsPath//:/$'\n'}
+      do
+        checkFileExists ${jarPath}
+      done
   fi
+
+  #Unpacking original war
+  unzip ${inputWar} -d ${tmpWarDir} > /dev/null
+  checkExec "unzipping Oozie input WAR"
+
+  components=""
+
   if [ "${secure}" != "" ]; then
     OPTIONS="${OPTIONS} -secureWeb ${secureConfigsDir}/ssl-web.xml"
     #Use the SSL version of server.xml in oozie-server
@@ -215,7 +247,65 @@ else
     cp ${secureConfigsDir}/server.xml ${CATALINA_BASE}/conf/server.xml
   fi
 
-  ${OOZIE_HOME}/bin/addtowar.sh -inputwar ${inputWar} -outputwar ${outputWar} 
${OPTIONS}
+  if [ "${addExtjs}" = "true" ]; then
+    if [ ! "${components}" = "" ];then
+      components="${components}, "
+    fi
+    components="${components}ExtJS library"
+    if [ -e ${tmpWarDir}/ext-2.2 ]; then
+      echo
+      echo "Specified Oozie WAR '${inputWar}' already contains ExtJS library 
files"
+      echo
+      cleanUp
+      exit -1
+    fi
+    #If the extjs path given is a ZIP, expand it and use it from there
+    if [ -f ${extjsHome} ]; then
+      unzip ${extjsHome} -d ${tmpDir} > /dev/null
+      extjsHome=${tmpDir}/ext-2.2
+    fi
+    #Inject the library in oozie war
+    cp -r ${extjsHome} ${tmpWarDir}/ext-2.2
+    checkExec "copying ExtJS files into staging"
+  fi
+
+  if [ "${addJars}" = "true" ]; then
+    if [ ! "${components}" = "" ];then
+      components="${components}, "
+    fi
+    components="${components}JARs"
+
+    for jarPath in ${jarsPath//:/$'\n'}
+    do
+      found=`ls ${tmpWarDir}/WEB-INF/lib/${jarPath} 2> /dev/null | wc -l`
+      checkExec "looking for JAR ${jarPath} in input WAR"
+      if [ ! $found = 0 ]; then
+        echo
+        echo "Specified Oozie WAR '${inputWar}' already contains JAR 
${jarPath}"
+        echo
+        cleanUp
+        exit -1
+      fi
+      cp ${jarPath} ${tmpWarDir}/WEB-INF/lib/
+      checkExec "copying jar ${jarPath} to staging"
+    done
+  fi
+
+  #Creating new Oozie WAR
+  currentDir=`pwd`
+  cd ${tmpWarDir}
+  zip -r oozie.war * > /dev/null
+  checkExec "creating new Oozie WAR"
+  cd ${currentDir}
+
+  #copying new Oozie WAR to asked location
+  cp ${tmpWarDir}/oozie.war ${outputWar}
+  checkExec "copying new Oozie WAR"
+
+  echo
+  echo "New Oozie WAR file with added '${components}' at ${outputWar}"
+  echo
+  cleanUp
 
   if [ "$?" != "0" ]; then
     exit -1

Modified: oozie/trunk/docs/src/site/twiki/AG_Install.twiki
URL: 
http://svn.apache.org/viewvc/oozie/trunk/docs/src/site/twiki/AG_Install.twiki?rev=1469612&r1=1469611&r2=1469612&view=diff
==============================================================================
--- oozie/trunk/docs/src/site/twiki/AG_Install.twiki (original)
+++ oozie/trunk/docs/src/site/twiki/AG_Install.twiki Thu Apr 18 22:38:25 2013
@@ -63,12 +63,8 @@ The =oozie-setup.sh= script options are:
 
 <verbatim>
 Usage  : oozie-setup.sh <OPTIONS>"
-         prepare-war [-hadoop HADOOP_VERSION HADOOP_PATH] [-extjs EXTJS_PATH] 
[-jars JARS_PATH] [-secure]"
-                     (prepare-war is to prepare war files for oozie)"
-                     (Hadoop version 
[0.20.1|0.20.2|0.20.104|0.20.200|0.23.x|2.x] and Hadoop install dir)"
-                     (EXTJS_PATH is expanded or ZIP, to enable the Oozie 
webconsole)"
-                     (JARS_PATH is multiple JAR path separated by ':')"
-                     (-secure will configure the war file to use HTTPS (SSL))"
+         prepare-war [-d directory] [-secure] (-d identifies an alternative 
directory for processing jars"
+                                              -secure will configure the war 
file to use HTTPS (SSL))"
          sharelib create -fs FS_URI [-locallib SHARED_LIBRARY] (create 
sharelib for oozie,"
                                                                FS_URI is the 
fs.default.name"
                                                                for hdfs uri; 
SHARED_LIBRARY, path to the"
@@ -80,6 +76,8 @@ Usage  : oozie-setup.sh <OPTIONS>"
                                                                in HDFS)"
          sharelib upgrade -fs FS_URI [-locallib SHARED_LIBRARY] (upgrade 
existing sharelib, fails if there"
                                                                  is no 
existing sharelib installed in HDFS)"
+         db create|upgrade|postupgrade -run [-sqlfile <FILE>] (create, upgrade 
or postupgrade oozie db with an"
+                                                               optional sql 
file)"
          (without options prints usage information)"
 </verbatim>
 

Modified: oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki
URL: 
http://svn.apache.org/viewvc/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki?rev=1469612&r1=1469611&r2=1469612&view=diff
==============================================================================
--- oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki (original)
+++ oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki Thu Apr 18 22:38:25 2013
@@ -121,14 +121,19 @@ for uploading new or upgrading existing 
 and the second argument is the Oozie sharelib to install, it can be a tarball 
or the expanded version of it.
 If the second argument is omitted, the Oozie sharelib tarball from the Oozie 
installation directory will be used.
 
-"prepare-war" command is for creating war files for oozie.
+"prepare-war [-d directory]" command is for creating war files for oozie with 
an optional alternative directory other
+than libext.
+
+db create|upgrade|postupgrade -run [-sqlfile <FILE>] command is for create, 
upgrade or postupgrade oozie db with an
+optional sql file
 
 Run the =oozie-setup.sh= script to configure Oozie with all the components 
added to the *libext/* directory.
 
 <verbatim>
-$ bin/oozie-setup.sh prepare-war [-jars <PATHS>] [-extjs <PATH>] [-secure]
+$ bin/oozie-setup.sh prepare-war [-d directory] [-secure]
                      sharelib create -fs <FS_URI> [-locallib <PATH>]
                      sharelib upgrade -fs <FS_URI> [-locallib <PATH>]
+                     db create|upgrade|postupgrade -run [-sqlfile <FILE>]
 </verbatim>
 
 The =-secure= option will configure Oozie to use HTTP (SSL); refer to

Modified: oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1469612&r1=1469611&r2=1469612&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Thu Apr 18 22:38:25 2013
@@ -1,5 +1,6 @@
 -- Oozie 4.1.0 release (trunk - unreleased)
 
+OOZIE-670 Merge addtowar and oozie-setup scripts into one (bowenzhangusa via 
tucu)
 OOZIE-1326 sharelib tests failing saying error on fork after OOZIE-1311 
refactor (rohini via rkanter)
 OOZIE-1235 Client API for retrieving topic and jms connection related details 
(virag)
 OOZIE-1234 JMS Event Listeners for publishing notifications related to 
workflow and coordinator (virag)


Reply via email to