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