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