blob: c5926488d48a3774bd4acc77aeba5f9ee45de32f [file] [log] [blame]
Brian O'Connor9e1352f2016-04-29 17:13:33 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file
4# -----------------------------------------------------------------------------
5
6set -e
7
8OUT=$1
9KARAF_TAR=$2
10ONOS_VERSION=$3
11BRANDING=$4
12
13# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
14tar xf $KARAF_TAR
15
16# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
17KARAF_DIR=$(ls -d apache*)
18rm -rf $KARAF_DIR/demos
19
20# Patch the log-file size in place to increase it to 10 MB
21perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \
22 $KARAF_DIR/etc/org.ops4j.pax.logging.cfg
23
24# Patch-in proper Karaf version into the startup script
25sed -i '' "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-service
26sed -i '' "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-client
27mv bin/onos-client bin/onos
28chmod a+x bin/onos-service bin/onos
29
30# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
31cp -r bin $KARAF_DIR
32cp -r init $KARAF_DIR
33cp -r etc $KARAF_DIR
34
35export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
36#FIXME
37#[ "$ONOS_SECURITY_MODE" = true ] && enable_security_mode
38
39# Patch the Apache Karaf distribution file to add ONOS features repository
40perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features|" \
41 $KARAF_DIR/etc/org.apache.karaf.features.cfg
42
43# Patch the Apache Karaf distribution file to load default ONOS boot features
44perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \
45 $KARAF_DIR/etc/org.apache.karaf.features.cfg
46
47# Patch the Apache Karaf distribution with ONOS branding bundle
48cp $BRANDING $KARAF_DIR/lib
49
50zip -q -0 -r $OUT $KARAF_DIR
51
52#FIXME
53# Stage all builtin ONOS apps for factory install
54#onos-stage-apps $ONOS_STAGE/apps $ONOS_STAGE/$KARAF_DIST/system
55# Mark the org.onosproject.drivers app active by default
56#touch $ONOS_STAGE/apps/org.onosproject.drivers/active
57
58# copy in features and repos
59# Patch in the ONOS version file
60#echo $ONOS_VERSION > $ONOS_STAGE/VERSION
61
62
63#function enable_security_mode() {
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 $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
76# cp $FELIX_CFG_ADMIN $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
77# perl -pi.old -e "s|org.apache.felix.configadmin/1.8.0|org.apache.felix.configadmin/1.6.0|g" \
78# $ONOS_STAGE/$KARAF_DIST/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# $ONOS_STAGE/$KARAF_DIST/etc/system.properties
85# perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
86# $ONOS_STAGE/$KARAF_DIST/etc/system.properties
87#
88# # SM-ONOS step 3.2: update featuresBoot
89# export BOOT_FEATURES="onos-security,$BOOT_FEATURES"
90#}
91