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 |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 13 | LOG4J2_EXTRA=$6 |
| 14 | SANDBOX=${7:-.} |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 15 | |
Ray Milkey | da74633 | 2020-07-06 11:30:36 -0700 | [diff] [blame] | 16 | KARAF_VERSION="4.2.9" |
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 |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 25 | # mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true |
Yuta HIGUCHI | 6771ef6 | 2017-12-19 11:37:48 -0800 | [diff] [blame] | 26 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 27 | #tar xf $KARAF_PATCHES |
Thomas Vachuska | 9e6432c | 2018-04-20 22:26:19 -0700 | [diff] [blame] | 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. |
Charles Chan | 209edb1 | 2020-09-04 19:50:57 -0700 | [diff] [blame] | 30 | export KARAF_DIR=$(ls -d apache*) |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 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 | |
Andrea Campanella | dd54d56 | 2020-10-07 16:44:21 +0200 | [diff] [blame^] | 37 | # Patch the fileinstall to avoid NPE when filter is null |
| 38 | echo "felix.fileinstall.filter=*.jar" >> \ |
| 39 | $KARAF_DIR/etc/org.apache.felix.fileinstall-deploy.cfg |
| 40 | |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 41 | # Patch-in proper Karaf version into the startup script |
Charles Chan | 209edb1 | 2020-09-04 19:50:57 -0700 | [diff] [blame] | 42 | perl -pi.bk -e 's/apache-karaf-\$KARAF_VERSION/$ENV{KARAF_DIR}/g' $SANDBOX/bin/onos-service |
Ray Milkey | f83e422 | 2018-08-08 07:46:51 -0700 | [diff] [blame] | 43 | |
| 44 | # hack - need to break the link to the script in the source tree for bazel |
Charles Chan | 209edb1 | 2020-09-04 19:50:57 -0700 | [diff] [blame] | 45 | perl -pi.bk -e 's/apache-karaf-\$KARAF_VERSION/$ENV{KARAF_DIR}/g' $SANDBOX/bin/onos |
Ray Milkey | f83e422 | 2018-08-08 07:46:51 -0700 | [diff] [blame] | 46 | |
Charles Chan | 209edb1 | 2020-09-04 19:50:57 -0700 | [diff] [blame] | 47 | rm -f $SANDBOX/bin/*.bk |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 48 | chmod a+x $SANDBOX/bin/onos-service $SANDBOX/bin/onos |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 49 | |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 50 | # Patch the Apache Karaf distribution with ONOS branding bundle |
Thomas Vachuska | 8fcd204 | 2018-06-12 12:00:16 -0700 | [diff] [blame] | 51 | cp $BRANDING $KARAF_DIR/lib/onos-tools-package-branding.jar |
Brian O'Connor | 9e1352f | 2016-04-29 17:13:33 -0700 | [diff] [blame] | 52 | |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 53 | # **** Moving karaf to subdirectory **** |
| 54 | mkdir $PREFIX |
| 55 | mv $KARAF_DIR $PREFIX |
| 56 | |
| 57 | # Stage the ONOS admin scripts and patch in Karaf service wrapper extras |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 58 | cp -r $SANDBOX/bin $PREFIX |
| 59 | cp -r $SANDBOX/runtime/bin/* $PREFIX/bin/ |
| 60 | cp -r $SANDBOX/init $PREFIX |
| 61 | cp -r $SANDBOX/etc/* $PREFIX/$KARAF_DIR/etc/ |
Brian O'Connor | 92ec213 | 2016-05-03 17:30:25 -0700 | [diff] [blame] | 62 | |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 63 | ONOS_VERSION_POINT=$(echo ${ONOS_VERSION} | sed -E 's/-/./') |
| 64 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 65 | # Fix the onos version string in the features config |
| 66 | sed -i".VERBACK" -E "s/.ONOS_VERSION/${ONOS_VERSION}/" $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 67 | # Fix onos version in startup properties |
| 68 | sed -i".VERBACK" "s/.ONOS_VERSION/${ONOS_VERSION_POINT}/" $PREFIX/$KARAF_DIR/etc/startup.properties |
| 69 | |
| 70 | # Add log4j2-extra Bundle |
| 71 | mkdir -p $PREFIX/$KARAF_DIR/system/org/onosproject/onos-log4j2-extra/$ONOS_VERSION_POINT/ |
| 72 | cp $LOG4J2_EXTRA $PREFIX/$KARAF_DIR/system/org/onosproject/onos-log4j2-extra/$ONOS_VERSION_POINT/onos-log4j2-extra-$ONOS_VERSION_POINT.jar |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 73 | |
Heedo Kang | 611a065 | 2017-09-05 12:26:30 +0900 | [diff] [blame] | 74 | if [ "$ONOS_SECURITY_MODE" = true ] |
| 75 | then |
| 76 | # ONOS Patching ---------------------------------------------------------------- |
| 77 | |
| 78 | echo "Enabling security mode ONOS..." |
| 79 | |
| 80 | # SM-ONOS step 1: downgrade felix config admin |
| 81 | FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar} |
| 82 | if [ ! -f $FELIX_CFG_ADMIN ]; then |
| 83 | echo "Downloading $FELIX_CFG_ADMIN..." |
| 84 | curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN |
| 85 | fi |
| 86 | [ ! -f $FELIX_CFG_ADMIN ] && \ |
| 87 | echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1 |
| 88 | |
| 89 | mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| 90 | cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| 91 | perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \ |
| 92 | $PREFIX/$KARAF_DIR/etc/startup.properties |
| 93 | |
| 94 | # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end |
| 95 | |
| 96 | # SM-ONOS step 3.1: configure karaf |
| 97 | perl -pi.old -e "s|#java.security.policy|java.security.policy|" \ |
| 98 | $PREFIX/$KARAF_DIR/etc/system.properties |
| 99 | perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \ |
| 100 | $PREFIX/$KARAF_DIR/etc/system.properties |
| 101 | |
| 102 | # SM-ONOS step 3.2: update featuresBoot |
| 103 | export BOOT_FEATURES="onos-security,$BOOT_FEATURES" |
| 104 | |
| 105 | # Patch the Apache Karaf distribution file to load onos security feature |
| 106 | perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \ |
| 107 | $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg |
| 108 | fi |
| 109 | |
Brian O'Connor | 65c0bdf | 2016-05-03 18:40:17 -0700 | [diff] [blame] | 110 | zip -q -0 -r $OUT $PREFIX |