Committed by
Gerrit Code Review
Updating onos-setup-karaf for security-mode ONOS
Change-Id: I8e9dd907e5a135262603694753fd8008289c0d35
Showing
1 changed file
with
46 additions
and
5 deletions
... | @@ -20,12 +20,23 @@ function validateIp { | ... | @@ -20,12 +20,23 @@ function validateIp { |
20 | ifconfig | awk '{ print $2}' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $1 | 20 | ifconfig | awk '{ print $2}' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $1 |
21 | } | 21 | } |
22 | 22 | ||
23 | -# Clean the previous Karaf directory if requested and if it exists. | 23 | +# Parse optional arguments |
24 | -if [ "$1" = "clean" ]; then | 24 | +while [[ $# > 0 ]]; do |
25 | - shift | 25 | +case $1 in |
26 | + clean) | ||
27 | + # Clean the previous Karaf directory if requested and if it exists. | ||
26 | CLEAN="true" | 28 | CLEAN="true" |
27 | [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config | 29 | [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $STAGE/apps $STAGE/config |
28 | -fi | 30 | + ;; |
31 | + secure) | ||
32 | + SECURE="true" | ||
33 | + ;; | ||
34 | + *) | ||
35 | + break | ||
36 | + ;; | ||
37 | +esac | ||
38 | +shift | ||
39 | +done | ||
29 | 40 | ||
30 | ONOS_IP=${ONOS_IP:-127.0.0.1} | 41 | ONOS_IP=${ONOS_IP:-127.0.0.1} |
31 | IP="${1:-$ONOS_IP}" | 42 | IP="${1:-$ONOS_IP}" |
... | @@ -43,7 +54,7 @@ fi | ... | @@ -43,7 +54,7 @@ fi |
43 | 54 | ||
44 | # If IP is still not surmised or if usage was requested, show usage and IPs. | 55 | # If IP is still not surmised or if usage was requested, show usage and IPs. |
45 | if [ -z "$IP" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then | 56 | if [ -z "$IP" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then |
46 | - echo "usage: $(basename $0) [clean] <ip-address>" | 57 | + echo "usage: $(basename $0) [clean] [secure] <ip-address>" |
47 | echo "Available IP addresses are:" | 58 | echo "Available IP addresses are:" |
48 | validateIp . | 59 | validateIp . |
49 | exit 1 | 60 | exit 1 |
... | @@ -71,6 +82,32 @@ if [ ! -d $KARAF_ROOT ]; then | ... | @@ -71,6 +82,32 @@ if [ ! -d $KARAF_ROOT ]; then |
71 | rm -rf $KARAF_ROOT/demos | 82 | rm -rf $KARAF_ROOT/demos |
72 | fi | 83 | fi |
73 | 84 | ||
85 | +if [ "$SECURE" = "true" ]; then | ||
86 | + echo "Enabling security mode ONOS..." | ||
87 | + | ||
88 | + # SM-ONOS step 1: downgrade felix config admin | ||
89 | + FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar} | ||
90 | + if [ ! -f $FELIX_CFG_ADMIN ]; then | ||
91 | + echo "Downloading $FELIX_CFG_ADMIN..." | ||
92 | + curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN | ||
93 | + fi | ||
94 | + [ ! -f $FELIX_CFG_ADMIN ] && \ | ||
95 | + echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1 | ||
96 | + | ||
97 | + mkdir -p $KARAF_ROOT/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 | ||
98 | + cp $FELIX_CFG_ADMIN $KARAF_ROOT/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 | ||
99 | + perl -pi.old -e "s|org.apache.felix.configadmin/1.8.0|org.apache.felix.configadmin/1.6.0|g" \ | ||
100 | + $KARAF_ROOT/etc/startup.properties | ||
101 | + | ||
102 | + # SM-ONOS step 2: stage ONOS Felix framework security (will get downloaded on demand); end | ||
103 | + | ||
104 | + # SM-ONOS step 3.1: configure karaf | ||
105 | + perl -pi.old -e "s|#java.security.policy|java.security.policy|" \ | ||
106 | + $KARAF_ROOT/etc/system.properties | ||
107 | + perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \ | ||
108 | + $KARAF_ROOT/etc/system.properties | ||
109 | +fi | ||
110 | + | ||
74 | if ! grep -q "/onos-features/" $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then | 111 | if ! grep -q "/onos-features/" $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then |
75 | # Patch the Apache Karaf distribution file to add ONOS features repository | 112 | # Patch the Apache Karaf distribution file to add ONOS features repository |
76 | echo "Adding ONOS feature repository..." | 113 | echo "Adding ONOS feature repository..." |
... | @@ -81,6 +118,10 @@ fi | ... | @@ -81,6 +118,10 @@ fi |
81 | if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then | 118 | if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then |
82 | # Patch the Apache Karaf distribution file to load default ONOS boot features | 119 | # Patch the Apache Karaf distribution file to load default ONOS boot features |
83 | export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" | 120 | export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" |
121 | + if [ "$SECURE" = "true" ]; then | ||
122 | + # SM-ONOS Step 3.2: add onos-security to featuresBoot | ||
123 | + export BOOT_FEATURES="onos-security,$BOOT_FEATURES" | ||
124 | + fi | ||
84 | echo "Adding ONOS boot features $BOOT_FEATURES..." | 125 | echo "Adding ONOS boot features $BOOT_FEATURES..." |
85 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ | 126 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ |
86 | $KARAF_ROOT/etc/org.apache.karaf.features.cfg | 127 | $KARAF_ROOT/etc/org.apache.karaf.features.cfg | ... | ... |
-
Please register or login to post a comment