Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | OUT=$1 |
| 9 | KARAF_TAR=$2 |
| 10 | ONOS_VERSION=$3 |
| 11 | BRANDING=$4 |
Thomas Vachuska | 9e6432c | 2018-04-20 22:26:19 -0700 | [diff] [blame] | 12 | KARAF_PATCHES=$5 |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 13 | SANDBOX=${6:-.} |
| 14 | |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 15 | #FIXME karaf version |
Jon Hall | b84df5d | 2017-01-31 11:19:48 -0800 | [diff] [blame] | 16 | KARAF_VERSION="3.0.8" |
Heedo Kang | 611a065 | 2017-09-05 12:26:30 +0900 | [diff] [blame] | 17 | ONOS_SECURITY_MODE="false" |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 18 | |
Brian O'Connor | 3500734 | 2016-09-13 17:41:16 -0700 | [diff] [blame] | 19 | PREFIX="onos-$ONOS_VERSION" |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 20 | |
| 21 | # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
| 22 | tar xf $KARAF_TAR |
| 23 | |
Yuta HIGUCHI | 6771ef6 | 2017-12-19 11:37:48 -0800 | [diff] [blame] | 24 | # rename path name to match what was distributed with vicci |
| 25 | mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true |
| 26 | |
Thomas Vachuska | 9e6432c | 2018-04-20 22:26:19 -0700 | [diff] [blame] | 27 | tar xf $KARAF_PATCHES |
| 28 | |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 29 | # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
| 30 | KARAF_DIR=$(ls -d apache*) |
| 31 | rm -rf $KARAF_DIR/demos |
| 32 | |
| 33 | # Patch the log-file size in place to increase it to 10 MB |
| 34 | perl -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 Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 38 | sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" $SANDBOX/bin/onos-service |
Brian O'Connor | a5704f3 | 2016-05-05 17:00:44 -0700 | [diff] [blame] | 39 | rm -f bin/*.bk |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 40 | chmod a+x $SANDBOX/bin/onos-service $SANDBOX/bin/onos |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 41 | |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 42 | export BOOT_FEATURES="standard,ssh,scr,war,webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 43 | |
| 44 | # Patch the Apache Karaf distribution file to add ONOS features repository |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 45 | perl -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'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 46 | $KARAF_DIR/etc/org.apache.karaf.features.cfg |
| 47 | |
| 48 | # Patch the Apache Karaf distribution file to load default ONOS boot features |
Yuta HIGUCHI | 6771ef6 | 2017-12-19 11:37:48 -0800 | [diff] [blame] | 49 | perl -pi.old -e "s|^(featuresBoot ?= ?).*|\1$BOOT_FEATURES|" \ |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 50 | $KARAF_DIR/etc/org.apache.karaf.features.cfg |
| 51 | |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 52 | |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 53 | # Patch the Apache Karaf distribution with ONOS branding bundle |
Thomas Vachuska | 8fcd204 | 2018-06-12 12:00:16 -0700 | [diff] [blame] | 54 | cp $BRANDING $KARAF_DIR/lib/onos-tools-package-branding.jar |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 55 | |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 56 | # **** Moving karaf to subdirectory **** |
| 57 | mkdir $PREFIX |
| 58 | mv $KARAF_DIR $PREFIX |
| 59 | |
| 60 | # Stage the ONOS admin scripts and patch in Karaf service wrapper extras |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 61 | cp -r $SANDBOX/bin $PREFIX |
| 62 | cp -r $SANDBOX/runtime/bin/* $PREFIX/bin/ |
| 63 | cp -r $SANDBOX/init $PREFIX |
| 64 | cp -r $SANDBOX/etc/* $PREFIX/$KARAF_DIR/etc/ |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 65 | |
Heedo Kang | 611a065 | 2017-09-05 12:26:30 +0900 | [diff] [blame] | 66 | if [ "$ONOS_SECURITY_MODE" = true ] |
| 67 | then |
| 68 | # ONOS Patching ---------------------------------------------------------------- |
| 69 | |
| 70 | echo "Enabling security mode ONOS..." |
| 71 | |
| 72 | # SM-ONOS step 1: downgrade felix config admin |
| 73 | FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar} |
| 74 | if [ ! -f $FELIX_CFG_ADMIN ]; then |
| 75 | echo "Downloading $FELIX_CFG_ADMIN..." |
| 76 | curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN |
| 77 | fi |
| 78 | [ ! -f $FELIX_CFG_ADMIN ] && \ |
| 79 | echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1 |
| 80 | |
| 81 | mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| 82 | cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| 83 | perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \ |
| 84 | $PREFIX/$KARAF_DIR/etc/startup.properties |
| 85 | |
| 86 | # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end |
| 87 | |
| 88 | # SM-ONOS step 3.1: configure karaf |
| 89 | perl -pi.old -e "s|#java.security.policy|java.security.policy|" \ |
| 90 | $PREFIX/$KARAF_DIR/etc/system.properties |
| 91 | perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \ |
| 92 | $PREFIX/$KARAF_DIR/etc/system.properties |
| 93 | |
| 94 | # SM-ONOS step 3.2: update featuresBoot |
| 95 | export BOOT_FEATURES="onos-security,$BOOT_FEATURES" |
| 96 | |
| 97 | # Patch the Apache Karaf distribution file to load onos security feature |
| 98 | perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \ |
| 99 | $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg |
| 100 | fi |
| 101 | |
Brian O'Connor | 65c0bdf | 2016-05-03 18:40:17 -0700 | [diff] [blame] | 102 | zip -q -0 -r $OUT $PREFIX |