blob: 44a05f78933b1450d9791856f532bf656692366a [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
Ray Milkeyd84f89b2018-08-17 14:54:17 -07006set -eu -o pipefail
Brian O'Connor9e1352f2016-04-29 17:13:33 -07007
8OUT=$1
Ray Milkey3f274d92018-09-28 14:23:34 -07009KARAF_TAR=$2
Brian O'Connor9e1352f2016-04-29 17:13:33 -070010ONOS_VERSION=$3
11BRANDING=$4
Thomas Vachuska9e6432c2018-04-20 22:26:19 -070012KARAF_PATCHES=$5
Thomas Vachuska0f956032018-06-12 10:41:12 -070013SANDBOX=${6:-.}
14
Ray Milkey5f11a072019-06-28 14:10:19 -070015KARAF_VERSION="4.2.6"
Heedo Kang611a0652017-09-05 12:26:30 +090016ONOS_SECURITY_MODE="false"
Brian O'Connor92ec2132016-05-03 17:30:25 -070017
Brian O'Connor35007342016-09-13 17:41:16 -070018PREFIX="onos-$ONOS_VERSION"
Brian O'Connor9e1352f2016-04-29 17:13:33 -070019
20# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
21tar xf $KARAF_TAR
22
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080023# rename path name to match what was distributed with vicci
Ray Milkeyd84f89b2018-08-17 14:54:17 -070024# mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true
Yuta HIGUCHI6771ef62017-12-19 11:37:48 -080025
Ray Milkeyd84f89b2018-08-17 14:54:17 -070026#tar xf $KARAF_PATCHES
Thomas Vachuska9e6432c2018-04-20 22:26:19 -070027
Brian O'Connor9e1352f2016-04-29 17:13:33 -070028# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
29KARAF_DIR=$(ls -d apache*)
30rm -rf $KARAF_DIR/demos
31
32# Patch the log-file size in place to increase it to 10 MB
33perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \
34 $KARAF_DIR/etc/org.ops4j.pax.logging.cfg
35
Andrea Campanella198ed902020-10-07 16:44:21 +020036# Patch the fileinstall to avoid NPE when filter is null
Andrea Campanella0e1f5ea2020-10-19 10:44:15 +020037echo "felix.fileinstall.filter='\\*.jar'" >> \
Andrea Campanella198ed902020-10-07 16:44:21 +020038 $KARAF_DIR/etc/org.apache.felix.fileinstall-deploy.cfg
39
Brian O'Connor9e1352f2016-04-29 17:13:33 -070040# Patch-in proper Karaf version into the startup script
Thomas Vachuska0f956032018-06-12 10:41:12 -070041sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" $SANDBOX/bin/onos-service
Ray Milkeyf83e4222018-08-08 07:46:51 -070042
43# hack - need to break the link to the script in the source tree for bazel
44sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" $SANDBOX/bin/onos
45
Brian O'Connora5704f32016-05-05 17:00:44 -070046rm -f bin/*.bk
Thomas Vachuska0f956032018-06-12 10:41:12 -070047chmod a+x $SANDBOX/bin/onos-service $SANDBOX/bin/onos
Brian O'Connor9e1352f2016-04-29 17:13:33 -070048
Brian O'Connor9e1352f2016-04-29 17:13:33 -070049# Patch the Apache Karaf distribution with ONOS branding bundle
Thomas Vachuska8fcd2042018-06-12 12:00:16 -070050cp $BRANDING $KARAF_DIR/lib/onos-tools-package-branding.jar
Brian O'Connor9e1352f2016-04-29 17:13:33 -070051
Brian O'Connor92ec2132016-05-03 17:30:25 -070052# **** Moving karaf to subdirectory ****
53mkdir $PREFIX
54mv $KARAF_DIR $PREFIX
55
56# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
Thomas Vachuska0f956032018-06-12 10:41:12 -070057cp -r $SANDBOX/bin $PREFIX
58cp -r $SANDBOX/runtime/bin/* $PREFIX/bin/
59cp -r $SANDBOX/init $PREFIX
60cp -r $SANDBOX/etc/* $PREFIX/$KARAF_DIR/etc/
Brian O'Connor92ec2132016-05-03 17:30:25 -070061
Ray Milkeyd84f89b2018-08-17 14:54:17 -070062# Fix the onos version string in the features config
63sed -i".VERBACK" -E "s/.ONOS_VERSION/${ONOS_VERSION}/" $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg
64
Heedo Kang611a0652017-09-05 12:26:30 +090065if [ "$ONOS_SECURITY_MODE" = true ]
66then
67 # ONOS Patching ----------------------------------------------------------------
68
69 echo "Enabling security mode ONOS..."
70
71 # SM-ONOS step 1: downgrade felix config admin
72 FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar}
73 if [ ! -f $FELIX_CFG_ADMIN ]; then
74 echo "Downloading $FELIX_CFG_ADMIN..."
75 curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN
76 fi
77 [ ! -f $FELIX_CFG_ADMIN ] && \
78 echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1
79
80 mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
81 cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
82 perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \
83 $PREFIX/$KARAF_DIR/etc/startup.properties
84
85 # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end
86
87 # SM-ONOS step 3.1: configure karaf
88 perl -pi.old -e "s|#java.security.policy|java.security.policy|" \
89 $PREFIX/$KARAF_DIR/etc/system.properties
90 perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
91 $PREFIX/$KARAF_DIR/etc/system.properties
92
93 # SM-ONOS step 3.2: update featuresBoot
94 export BOOT_FEATURES="onos-security,$BOOT_FEATURES"
95
96 # Patch the Apache Karaf distribution file to load onos security feature
97 perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \
98 $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg
99fi
100
Brian O'Connor65c0bdf2016-05-03 18:40:17 -0700101zip -q -0 -r $OUT $PREFIX