blob: 1cc21e24838750d61ab68aa18b3a073de0482970 [file] [log] [blame]
Brian O'Connor9e1352f2016-04-29 17:13:33 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file
4# -----------------------------------------------------------------------------
5
6set -e
7
8OUT=$1
9KARAF_TAR=$2
10ONOS_VERSION=$3
11BRANDING=$4
Thomas Vachuska9e6432c2018-04-20 22:26:19 -070012KARAF_PATCHES=$5
Thomas Vachuska0f956032018-06-12 10:41:12 -070013SANDBOX=${6:-.}
14
Brian O'Connor92ec2132016-05-03 17:30:25 -070015#FIXME karaf version
Jon Hallb84df5d2017-01-31 11:19:48 -080016KARAF_VERSION="3.0.8"
Heedo Kang611a0652017-09-05 12:26:30 +090017ONOS_SECURITY_MODE="false"
Brian O'Connor92ec2132016-05-03 17:30:25 -070018
Brian O'Connor35007342016-09-13 17:41:16 -070019PREFIX="onos-$ONOS_VERSION"
Brian O'Connor9e1352f2016-04-29 17:13:33 -070020
21# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
22tar xf $KARAF_TAR
23
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080024# rename path name to match what was distributed with vicci
25mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true
26
Thomas Vachuska9e6432c2018-04-20 22:26:19 -070027tar xf $KARAF_PATCHES
28
Brian O'Connor9e1352f2016-04-29 17:13:33 -070029# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
30KARAF_DIR=$(ls -d apache*)
31rm -rf $KARAF_DIR/demos
32
33# Patch the log-file size in place to increase it to 10 MB
34perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \
35 $KARAF_DIR/etc/org.ops4j.pax.logging.cfg
36
37# Patch-in proper Karaf version into the startup script
Thomas Vachuska0f956032018-06-12 10:41:12 -070038sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" $SANDBOX/bin/onos-service
Ray Milkeyf83e4222018-08-08 07:46:51 -070039
40# hack - need to break the link to the script in the source tree for bazel
41sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" $SANDBOX/bin/onos
42
Brian O'Connora5704f32016-05-05 17:00:44 -070043rm -f bin/*.bk
Thomas Vachuska0f956032018-06-12 10:41:12 -070044chmod a+x $SANDBOX/bin/onos-service $SANDBOX/bin/onos
Brian O'Connor9e1352f2016-04-29 17:13:33 -070045
Brian O'Connor92ec2132016-05-03 17:30:25 -070046export BOOT_FEATURES="standard,ssh,scr,war,webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
Brian O'Connor9e1352f2016-04-29 17:13:33 -070047
48# Patch the Apache Karaf distribution file to add ONOS features repository
Brian O'Connor92ec2132016-05-03 17:30:25 -070049perl -pi.old -e "s|^(featuresRepositories=).*|\1mvn:org.apache.karaf.features/standard/$KARAF_VERSION/xml/features,mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features|" \
Brian O'Connor9e1352f2016-04-29 17:13:33 -070050 $KARAF_DIR/etc/org.apache.karaf.features.cfg
51
52# Patch the Apache Karaf distribution file to load default ONOS boot features
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080053perl -pi.old -e "s|^(featuresBoot ?= ?).*|\1$BOOT_FEATURES|" \
Brian O'Connor9e1352f2016-04-29 17:13:33 -070054 $KARAF_DIR/etc/org.apache.karaf.features.cfg
55
Brian O'Connor92ec2132016-05-03 17:30:25 -070056
Brian O'Connor9e1352f2016-04-29 17:13:33 -070057# Patch the Apache Karaf distribution with ONOS branding bundle
Thomas Vachuska8fcd2042018-06-12 12:00:16 -070058cp $BRANDING $KARAF_DIR/lib/onos-tools-package-branding.jar
Brian O'Connor9e1352f2016-04-29 17:13:33 -070059
Brian O'Connor92ec2132016-05-03 17:30:25 -070060# **** Moving karaf to subdirectory ****
61mkdir $PREFIX
62mv $KARAF_DIR $PREFIX
63
64# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
Thomas Vachuska0f956032018-06-12 10:41:12 -070065cp -r $SANDBOX/bin $PREFIX
66cp -r $SANDBOX/runtime/bin/* $PREFIX/bin/
67cp -r $SANDBOX/init $PREFIX
68cp -r $SANDBOX/etc/* $PREFIX/$KARAF_DIR/etc/
Brian O'Connor92ec2132016-05-03 17:30:25 -070069
Heedo Kang611a0652017-09-05 12:26:30 +090070if [ "$ONOS_SECURITY_MODE" = true ]
71then
72 # ONOS Patching ----------------------------------------------------------------
73
74 echo "Enabling security mode ONOS..."
75
76 # SM-ONOS step 1: downgrade felix config admin
77 FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar}
78 if [ ! -f $FELIX_CFG_ADMIN ]; then
79 echo "Downloading $FELIX_CFG_ADMIN..."
80 curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN
81 fi
82 [ ! -f $FELIX_CFG_ADMIN ] && \
83 echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1
84
85 mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
86 cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
87 perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \
88 $PREFIX/$KARAF_DIR/etc/startup.properties
89
90 # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end
91
92 # SM-ONOS step 3.1: configure karaf
93 perl -pi.old -e "s|#java.security.policy|java.security.policy|" \
94 $PREFIX/$KARAF_DIR/etc/system.properties
95 perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
96 $PREFIX/$KARAF_DIR/etc/system.properties
97
98 # SM-ONOS step 3.2: update featuresBoot
99 export BOOT_FEATURES="onos-security,$BOOT_FEATURES"
100
101 # Patch the Apache Karaf distribution file to load onos security feature
102 perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \
103 $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg
104fi
105
Brian O'Connor65c0bdf2016-05-03 18:40:17 -0700106zip -q -0 -r $OUT $PREFIX