| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file |
| # ----------------------------------------------------------------------------- |
| |
| set -e |
| |
| OUT=$1 |
| KARAF_TAR=$2 |
| ONOS_VERSION=$3 |
| BRANDING=$4 |
| #FIXME karaf version |
| KARAF_VERSION="3.0.8" |
| ONOS_SECURITY_MODE="false" |
| |
| PREFIX="onos-$ONOS_VERSION" |
| |
| # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
| tar xf $KARAF_TAR |
| |
| # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
| KARAF_DIR=$(ls -d apache*) |
| rm -rf $KARAF_DIR/demos |
| |
| # Patch the log-file size in place to increase it to 10 MB |
| perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \ |
| $KARAF_DIR/etc/org.ops4j.pax.logging.cfg |
| |
| # Patch-in proper Karaf version into the startup script |
| sed -i.bk "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-service |
| rm -f bin/*.bk |
| chmod a+x bin/onos-service bin/onos |
| |
| export BOOT_FEATURES="standard,ssh,scr,war,webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" |
| |
| # Patch the Apache Karaf distribution file to add ONOS features repository |
| 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|" \ |
| $KARAF_DIR/etc/org.apache.karaf.features.cfg |
| |
| # Patch the Apache Karaf distribution file to load default ONOS boot features |
| perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \ |
| $KARAF_DIR/etc/org.apache.karaf.features.cfg |
| |
| |
| # Patch the Apache Karaf distribution with ONOS branding bundle |
| cp $BRANDING $KARAF_DIR/lib |
| |
| # **** Moving karaf to subdirectory **** |
| mkdir $PREFIX |
| mv $KARAF_DIR $PREFIX |
| |
| # Stage the ONOS admin scripts and patch in Karaf service wrapper extras |
| cp -r bin $PREFIX |
| cp -r runtime/bin/* $PREFIX/bin/ |
| cp -r init $PREFIX |
| cp -r etc/* $PREFIX/$KARAF_DIR/etc/ |
| |
| if [ "$ONOS_SECURITY_MODE" = true ] |
| then |
| # ONOS Patching ---------------------------------------------------------------- |
| |
| echo "Enabling security mode ONOS..." |
| |
| # SM-ONOS step 1: downgrade felix config admin |
| FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar} |
| if [ ! -f $FELIX_CFG_ADMIN ]; then |
| echo "Downloading $FELIX_CFG_ADMIN..." |
| curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN |
| fi |
| [ ! -f $FELIX_CFG_ADMIN ] && \ |
| echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1 |
| |
| mkdir -p $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| cp $FELIX_CFG_ADMIN $PREFIX/$KARAF_DIR/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 |
| perl -pi.old -e "s|org.apache.felix.configadmin/1.8.4|org.apache.felix.configadmin/1.6.0|g" \ |
| $PREFIX/$KARAF_DIR/etc/startup.properties |
| |
| # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end |
| |
| # SM-ONOS step 3.1: configure karaf |
| perl -pi.old -e "s|#java.security.policy|java.security.policy|" \ |
| $PREFIX/$KARAF_DIR/etc/system.properties |
| perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \ |
| $PREFIX/$KARAF_DIR/etc/system.properties |
| |
| # SM-ONOS step 3.2: update featuresBoot |
| export BOOT_FEATURES="onos-security,$BOOT_FEATURES" |
| |
| # Patch the Apache Karaf distribution file to load onos security feature |
| perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \ |
| $PREFIX/$KARAF_DIR/etc/org.apache.karaf.features.cfg |
| fi |
| |
| zip -q -0 -r $OUT $PREFIX |