1 # Create a script to run controller inside a dynamic jenkins slave
3 CONTROLLERFEATURES="odl-integration-compatible-with-all"
6 if [ ${BUNDLEURL} == 'last' ]; then
7 NEXUSPATH="https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
8 # Extract the BUNDLEVERSION from the pom.xml
9 BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
10 echo "Bundle version is ${BUNDLEVERSION}"
11 # Acquire the timestamp information from maven-metadata.xml
12 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
13 TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
14 echo "Nexus timestamp is ${TIMESTAMP}"
15 BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
16 BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
17 BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
19 BUNDLE="$(echo ${BUNDLEURL} | awk -F '/' '{ print $(NF) }')"
20 echo "Finding out Bundle folder..."
21 wget --no-verbose ${BUNDLEURL}
22 BUNDLEFOLDER="$(unzip -qql ${BUNDLE} | head -n1 | tr -s ' ' | cut -d' ' -f5- | rev | cut -c 2- | rev)"
26 echo "Distribution bundle URL is ${BUNDLEURL}"
27 echo "Distribution bundle is ${BUNDLE}"
28 echo "Distribution folder is ${BUNDLEFOLDER}"
30 echo "Downloading the distribution from ${BUNDLEURL}"
31 wget --no-verbose ${BUNDLEURL}
33 echo "Extracting the new controller..."
36 echo "Configuring the startup features..."
37 cd ${BUNDLEFOLDER}/etc
38 CFG=org.apache.karaf.features.cfg
40 cat ${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > ${CFG}.1
41 cat ${CFG}.1 | sed "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%" > ${CFG}
44 echo "Configuring the log..."
45 LOG=org.ops4j.pax.logging.cfg
47 cat ${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > ${LOG}
50 echo "Configure the repos..."
51 REPO=org.ops4j.pax.url.mvn.cfg
52 cp ${REPO} ${REPO}.bak
53 cat ${REPO}.bak | sed '/http/d' | sed '$s/...$//'> ${REPO}
56 echo "Configure max memory..."
60 cat ${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > ${MEM}
63 echo "Starting controller..."
66 echo "sleeping for 20 seconds..."
69 echo "Check OSGi bundles..."
70 ./client "feature:install ${CONTROLLERFEATURES}" || echo $? > ${WORKSPACE}/error.txt
72 echo "Fetching Karaf log"
74 cp ${BUNDLEFOLDER}/data/log/karaf.log .
76 echo "Exit with error"
77 if [ `cat error.txt` -ne 0 ]; then
78 echo "Failed to deploy offline"
82 # vim: ts=4 sw=4 sts=4 et ft=sh :