blob: a4668584d20a7d1ce032c927af31ac85757bae9e [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
Brian O'Connor92ec2132016-05-03 17:30:25 -070013#FIXME karaf version
Jon Hallb84df5d2017-01-31 11:19:48 -080014KARAF_VERSION="3.0.8"
Heedo Kang611a0652017-09-05 12:26:30 +090015ONOS_SECURITY_MODE="false"
Brian O'Connor92ec2132016-05-03 17:30:25 -070016
Brian O'Connor35007342016-09-13 17:41:16 -070017PREFIX="onos-$ONOS_VERSION"
Brian O'Connor9e1352f2016-04-29 17:13:33 -070018
19# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
20tar xf $KARAF_TAR
21
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080022# rename path name to match what was distributed with vicci
23mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true
24
Thomas Vachuska9e6432c2018-04-20 22:26:19 -070025tar xf $KARAF_PATCHES
26
Brian O'Connor9e1352f2016-04-29 17:13:33 -070027# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
28KARAF_DIR=$(ls -d apache*)
29rm -rf $KARAF_DIR/demos
30
31# Patch the log-file size in place to increase it to 10 MB
32perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \
33 $KARAF_DIR/etc/org.ops4j.pax.logging.cfg
34
35# Patch-in proper Karaf version into the startup script
Brian O'Connor9a17c1a2016-05-05 16:37:21 -070036sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-service
Brian O'Connora5704f32016-05-05 17:00:44 -070037rm -f bin/*.bk
Brian O'Connor9e1352f2016-04-29 17:13:33 -070038chmod a+x bin/onos-service bin/onos
39
Brian O'Connor92ec2132016-05-03 17:30:25 -070040export 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 -070041
42# Patch the Apache Karaf distribution file to add ONOS features repository
Brian O'Connor92ec2132016-05-03 17:30:25 -070043perl -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 -070044 $KARAF_DIR/etc/org.apache.karaf.features.cfg
45
46# Patch the Apache Karaf distribution file to load default ONOS boot features
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080047perl -pi.old -e "s|^(featuresBoot ?= ?).*|\1$BOOT_FEATURES|" \
Brian O'Connor9e1352f2016-04-29 17:13:33 -070048 $KARAF_DIR/etc/org.apache.karaf.features.cfg
49
Brian O'Connor92ec2132016-05-03 17:30:25 -070050
Brian O'Connor9e1352f2016-04-29 17:13:33 -070051# Patch the Apache Karaf distribution with ONOS branding bundle
52cp $BRANDING $KARAF_DIR/lib
53
Brian O'Connor92ec2132016-05-03 17:30:25 -070054# **** Moving karaf to subdirectory ****
55mkdir $PREFIX
56mv $KARAF_DIR $PREFIX
57
58# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
59cp -r bin $PREFIX
Ray Milkey5c0d8f92017-06-09 12:26:31 -070060cp -r runtime/bin/* $PREFIX/bin/
Brian O'Connor92ec2132016-05-03 17:30:25 -070061cp -r init $PREFIX
Thomas Vachuska5f54c6f2016-05-04 19:19:51 -070062cp -r etc/* $PREFIX/$KARAF_DIR/etc/
Brian O'Connor92ec2132016-05-03 17:30:25 -070063
Heedo Kang611a0652017-09-05 12:26:30 +090064if [ "$ONOS_SECURITY_MODE" = true ]
65then
66 # ONOS Patching ----------------------------------------------------------------
67
68 echo "Enabling security mode ONOS..."
69
70 # SM-ONOS step 1: downgrade felix config admin
71 FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar}
72 if [ ! -f $FELIX_CFG_ADMIN ]; then
73 echo "Downloading $FELIX_CFG_ADMIN..."
74 curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN
75 fi
76 [ ! -f $FELIX_CFG_ADMIN ] && \
77 echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1
78
79 mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
80 cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
81 perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \
82 $PREFIX/$KARAF_DIR/etc/startup.properties
83
84 # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end
85
86 # SM-ONOS step 3.1: configure karaf
87 perl -pi.old -e "s|#java.security.policy|java.security.policy|" \
88 $PREFIX/$KARAF_DIR/etc/system.properties
89 perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
90 $PREFIX/$KARAF_DIR/etc/system.properties
91
92 # SM-ONOS step 3.2: update featuresBoot
93 export BOOT_FEATURES="onos-security,$BOOT_FEATURES"
94
95 # Patch the Apache Karaf distribution file to load onos security feature
96 perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \
97 $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg
98fi
99
Brian O'Connor65c0bdf2016-05-03 18:40:17 -0700100zip -q -0 -r $OUT $PREFIX