jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | ### |
| 4 | # ============LICENSE_START======================================================= |
| 5 | # SDNC |
| 6 | # ================================================================================ |
Konrad Bańka | ade13cb | 2020-04-06 14:19:18 +0200 | [diff] [blame^] | 7 | # Copyright © 2020 Samsung Electronics |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 8 | # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 9 | # ================================================================================ |
| 10 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | # you may not use this file except in compliance with the License. |
| 12 | # You may obtain a copy of the License at |
| 13 | # |
| 14 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | # |
| 16 | # Unless required by applicable law or agreed to in writing, software |
| 17 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | # See the License for the specific language governing permissions and |
| 20 | # limitations under the License. |
| 21 | # ============LICENSE_END========================================================= |
| 22 | ### |
| 23 | |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 24 | # Append features to karaf boot feature configuration |
| 25 | # $1 additional feature to be added |
| 26 | # $2 repositories to be added (optional) |
| 27 | function addToFeatureBoot() { |
| 28 | CFG=$ODL_HOME/etc/org.apache.karaf.features.cfg |
| 29 | ORIG=$CFG.orig |
| 30 | if [ -n "$2" ] ; then |
| 31 | echo "Add repository: $2" |
| 32 | mv $CFG $ORIG |
| 33 | cat $ORIG | sed -e "\|featuresRepositories|s|$|,$2|" > $CFG |
| 34 | fi |
| 35 | echo "Add boot feature: $1" |
| 36 | mv $CFG $ORIG |
| 37 | cat $ORIG | sed -e "\|featuresBoot *=|s|$|,$1|" > $CFG |
| 38 | } |
| 39 | |
| 40 | # Append features to karaf boot feature configuration |
| 41 | # $1 search pattern |
| 42 | # $2 replacement |
| 43 | function replaceFeatureBoot() { |
| 44 | CFG=$ODL_HOME/etc/org.apache.karaf.features.cfg |
| 45 | ORIG=$CFG.orig |
| 46 | echo "Replace boot feature $1 with: $2" |
| 47 | sed -i "/featuresBoot/ s/$1/$2/g" $CFG |
| 48 | } |
| 49 | |
| 50 | function install_sdnrwt_features() { |
| 51 | addToFeatureBoot "$SDNRWT_BOOTFEATURES" $SDNRWT_REPOSITORY |
| 52 | } |
| 53 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 54 | function enable_odl_cluster(){ |
| 55 | if [ -z $SDNC_REPLICAS ]; then |
| 56 | echo "SDNC_REPLICAS is not configured in Env field" |
| 57 | exit |
| 58 | fi |
| 59 | |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 60 | #Be sure to remove feature odl-netconf-connector-all from list |
| 61 | replaceFeatureBoot "odl-netconf-connector-all," |
| 62 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 63 | echo "Installing Opendaylight cluster features" |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 64 | replaceFeatureBoot odl-netconf-topology odl-netconf-clustered-topology |
| 65 | replaceFeatureBoot odl-mdsal-all odl-mdsal-all,odl-mdsal-clustering |
| 66 | addToFeatureBoot odl-jolokia |
Timoney, Dan (dt5972) | 1bb05c8 | 2018-07-24 10:10:08 -0400 | [diff] [blame] | 67 | #${ODL_HOME}/bin/client feature:install odl-mdsal-clustering |
| 68 | #${ODL_HOME}/bin/client feature:install odl-jolokia |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 69 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 70 | |
| 71 | echo "Update cluster information statically" |
| 72 | hm=$(hostname) |
| 73 | echo "Get current Hostname ${hm}" |
| 74 | |
Trevor Tait | 702d105 | 2018-04-20 11:21:09 -0400 | [diff] [blame] | 75 | node=($(echo ${hm} | sed 's/-[0-9]*$//g')) |
| 76 | node_index=($(echo ${hm} | awk -F"-" '{print $NF}')) |
| 77 | member_offset=1 |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 78 | |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 79 | if $GEO_ENABLED; then |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 80 | echo "This is a Geo cluster" |
| 81 | |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 82 | if [ -z $IS_PRIMARY_CLUSTER ] || [ -z $MY_ODL_CLUSTER ] || [ -z $PEER_ODL_CLUSTER ]; then |
| 83 | echo "IS_PRIMARY_CLUSTER, MY_ODL_CLUSTER and PEER_ODL_CLUSTER must all be configured in Env field" |
| 84 | return |
| 85 | fi |
| 86 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 87 | if $IS_PRIMARY_CLUSTER; then |
| 88 | PRIMARY_NODE=${MY_ODL_CLUSTER} |
| 89 | SECONDARY_NODE=${PEER_ODL_CLUSTER} |
| 90 | else |
| 91 | PRIMARY_NODE=${PEER_ODL_CLUSTER} |
| 92 | SECONDARY_NODE=${MY_ODL_CLUSTER} |
| 93 | member_offset=4 |
| 94 | fi |
| 95 | |
| 96 | node_list="${PRIMARY_NODE} ${SECONDARY_NODE}" |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 97 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 98 | /opt/onap/sdnc/bin/configure_geo_cluster.sh $((node_index+member_offset)) ${node_list} |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 99 | else |
| 100 | echo "This is a local cluster" |
| 101 | |
| 102 | node_list="${node}-0.{{.Values.service.name}}-cluster.{{.Release.Namespace}}"; |
| 103 | |
| 104 | for ((i=1;i<${SDNC_REPLICAS};i++)); |
| 105 | do |
| 106 | node_list="${node_list} ${node}-$i.{{.Values.service.name}}-cluster.{{.Release.Namespace}}" |
| 107 | done |
| 108 | |
| 109 | /opt/opendaylight/current/bin/configure_cluster.sh $((node_index+1)) ${node_list} |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 110 | fi |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 111 | } |
| 112 | |
jmac | c21cb7d | 2018-04-16 19:54:54 +0000 | [diff] [blame] | 113 | |
| 114 | # Install SDN-C platform components if not already installed and start container |
| 115 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 116 | ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 117 | ODL_ADMIN_USERNAME=${ODL_ADMIN_USERNAME} |
| 118 | ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 119 | SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc} |
DarraghEgan | dbb5b68 | 2019-03-25 18:04:31 +0000 | [diff] [blame] | 120 | SDNC_BIN=${SDNC_BIN:-/opt/onap/sdnc/bin} |
Trevor Tait | 702d105 | 2018-04-20 11:21:09 -0400 | [diff] [blame] | 121 | CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk} |
Trevor Tait | 567ff1e | 2018-05-01 16:20:54 -0400 | [diff] [blame] | 122 | ENABLE_ODL_CLUSTER=${ENABLE_ODL_CLUSTER:-false} |
| 123 | GEO_ENABLED=${GEO_ENABLED:-false} |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 124 | SDNC_AAF_ENABLED=${SDNC_AAF_ENABLED:-false} |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 125 | SDNRWT=${SDNRWT:-false} |
| 126 | SDNRWT_BOOTFEATURES=${SDNRWT_BOOTFEATURES:-sdnr-wt-feature-aggregator} |
DarraghEgan | 78531bf | 2019-05-20 13:24:29 +0000 | [diff] [blame] | 127 | export ODL_ADMIN_PASSWORD ODL_ADMIN_USERNAME |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 128 | |
| 129 | echo "Settings:" |
| 130 | echo " ENABLE_ODL_CLUSTER=$ENABLE_ODL_CLUSTER" |
| 131 | echo " SDNC_REPLICAS=$SDNC_REPLICAS" |
| 132 | echo " SDNRWT=$SDNRWT" |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 133 | echo " AAF_ENABLED=$SDNC_AAF_ENABLED" |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 134 | |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 135 | |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 136 | if $SDNC_AAF_ENABLED; then |
Konrad Bańka | ade13cb | 2020-04-06 14:19:18 +0200 | [diff] [blame^] | 137 | export SDNC_AAF_STORE_DIR=/opt/app/osaaf/local |
| 138 | export SDNC_AAF_CONFIG_DIR=/opt/app/osaaf/local |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 139 | export SDNC_KEYPASS=`cat /opt/app/osaaf/local/.pass` |
| 140 | export SDNC_KEYSTORE=org.onap.sdnc.p12 |
| 141 | sed -i '/cadi_prop_files/d' $ODL_HOME/etc/system.properties |
Konrad Bańka | ade13cb | 2020-04-06 14:19:18 +0200 | [diff] [blame^] | 142 | echo "cadi_prop_files=$SDNC_AAF_CONFIG_DIR/org.onap.sdnc.props" >> $ODL_HOME/etc/system.properties |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 143 | |
| 144 | sed -i '/org.ops4j.pax.web.ssl.keystore/d' $ODL_HOME/etc/custom.properties |
| 145 | sed -i '/org.ops4j.pax.web.ssl.password/d' $ODL_HOME/etc/custom.properties |
| 146 | sed -i '/org.ops4j.pax.web.ssl.keypassword/d' $ODL_HOME/etc/custom.properties |
Konrad Bańka | ade13cb | 2020-04-06 14:19:18 +0200 | [diff] [blame^] | 147 | echo org.ops4j.pax.web.ssl.keystore=$SDNC_AAF_STORE_DIR/$SDNC_KEYSTORE >> $ODL_HOME/etc/custom.properties |
Agarwal, Ruchira (ra1926) | ec7c75e | 2019-10-01 17:36:24 +0000 | [diff] [blame] | 148 | echo org.ops4j.pax.web.ssl.password=$SDNC_KEYPASS >> $ODL_HOME/etc/custom.properties |
| 149 | echo org.ops4j.pax.web.ssl.keypassword=$SDNC_KEYPASS >> $ODL_HOME/etc/custom.properties |
| 150 | fi |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 151 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 152 | if [ ! -f ${SDNC_HOME}/.installed ] |
| 153 | then |
| 154 | echo "Installing SDN-C keyStore" |
| 155 | ${SDNC_HOME}/bin/addSdncKeyStore.sh |
| 156 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 157 | if $ENABLE_ODL_CLUSTER ; then enable_odl_cluster ; fi |
| 158 | |
Herbert Eiselt | 746fa02 | 2019-04-05 20:01:01 +0200 | [diff] [blame] | 159 | if $SDNRWT ; then install_sdnrwt_features ; fi |
| 160 | |
Timoney, Dan (dt5972) | eaa6a24 | 2018-11-16 17:08:12 -0500 | [diff] [blame] | 161 | echo "Installed at `date`" > ${SDNC_HOME}/.installed |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 162 | fi |
| 163 | |
DarraghEgan | dbb5b68 | 2019-03-25 18:04:31 +0000 | [diff] [blame] | 164 | cp /opt/opendaylight/current/certs/* /tmp |
| 165 | |
| 166 | nohup python ${SDNC_BIN}/installCerts.py & |
| 167 | |
| 168 | |
jmac | dbbe937 | 2018-07-30 20:18:44 +0000 | [diff] [blame] | 169 | exec ${ODL_HOME}/bin/karaf server |