Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 1 | # COPYRIGHT NOTICE STARTS HERE |
| 2 | # |
| 3 | # Copyright 2018 © Samsung Electronics Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # COPYRIGHT NOTICE ENDS HERE |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 18 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 19 | # |
| 20 | # this file contains shared variables and functions for the onap installer |
| 21 | # |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 22 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 23 | # any script which needs this file can check this variable |
| 24 | # and it will know immediately if the functions and variables |
| 25 | # are loaded and usable |
| 26 | IS_COMMON_FUNCTIONS_SOURCED=YES |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 27 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 28 | # setting of the path variables |
| 29 | if [ -z "$APROJECT_DIR" ] ; then |
| 30 | INCLUDE_PATH="${LOCAL_PATH}"/"${RELATIVE_PATH}" |
| 31 | APROJECT_DIR=$(readlink -f "$INCLUDE_PATH"/../..) |
| 32 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 33 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 34 | RESOURCES_DIR="$APROJECT_DIR/resources" |
| 35 | BASH_SCRIPTS_DIR="$APROJECT_DIR/bash" |
| 36 | NEXUS_DATA="$RESOURCES_DIR/nexus_data" |
| 37 | CERTS_TARGET_PATH="$APROJECT_DIR/live/certs" |
| 38 | NGINX_LOG_DIR="$APROJECT_DIR/live/nginx_logs" |
| 39 | GEN_CFG_PATH="$APROJECT_DIR/live/cfg" |
| 40 | GIT_REPOS="$RESOURCES_DIR/git-repo" |
| 41 | NGINX_HTTP_DIR="$RESOURCES_DIR/http" |
| 42 | RHEL_REPO="$RESOURCES_DIR/pkg/rhel" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 43 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 44 | PATH="${PATH}:/usr/local/bin:/usr/local/sbin" |
| 45 | export PATH |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 46 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 47 | # just self-defense against locale |
| 48 | LANG=C |
| 49 | export LANG |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 50 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 51 | # dns handling |
| 52 | SIMUL_HOSTS="gcr.io \ |
| 53 | git.rancher.io \ |
| 54 | gerrit.onap.org \ |
| 55 | registry-1.docker.io \ |
| 56 | docker.io \ |
| 57 | registry.npmjs.org \ |
| 58 | nexus3.onap.org \ |
| 59 | nexus.onap.org \ |
| 60 | docker.elastic.co \ |
| 61 | www.getcloudify.org \ |
| 62 | www.springframework.org \ |
| 63 | registry.hub.docker.com \ |
| 64 | git.onap.org \ |
| 65 | repo1.maven.org \ |
| 66 | repo.maven.apache.org" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 67 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 68 | # default credentials to the repository |
| 69 | NEXUS_USERNAME=admin |
| 70 | NEXUS_PASSWORD=admin123 |
| 71 | NEXUS_EMAIL=admin@onap.org |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 72 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 73 | # this function is intended to unify the installer output |
| 74 | message() { |
| 75 | case "$1" in |
| 76 | info) |
| 77 | echo 'INFO:' "$@" |
| 78 | ;; |
| 79 | debug) |
| 80 | echo 'DEBUG:' "$@" >&2 |
| 81 | ;; |
| 82 | warning) |
| 83 | echo 'WARNING [!]:' "$@" >&2 |
| 84 | ;; |
| 85 | error) |
| 86 | echo 'ERROR [!!]:' "$@" >&2 |
| 87 | return 1 |
| 88 | ;; |
| 89 | *) |
| 90 | echo 'UNKNOWN [?!]:' "$@" >&2 |
| 91 | return 2 |
| 92 | ;; |
| 93 | esac |
| 94 | return 0 |
| 95 | } |
| 96 | export message |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 97 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 98 | # if the environment variable DEBUG is set to DEBUG-ONAP -> |
| 99 | # -> this function will print its arguments |
| 100 | # otherwise nothing is done |
| 101 | debug() { |
| 102 | [ "$DEBUG" = DEBUG-ONAP ] && message debug "$@" |
| 103 | } |
| 104 | export debug |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 105 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 106 | fail() { |
| 107 | message error "$@" |
| 108 | exit 1 |
| 109 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 110 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 111 | retry() { |
| 112 | local n=1 |
| 113 | local max=5 |
| 114 | while ! "$@"; do |
| 115 | if [ $n -lt $max ]; then |
| 116 | n=$((n + 1)) |
| 117 | message warning "Command ${@} failed. Attempt: $n/$max" |
| 118 | message info "waiting 10s for another try..." |
| 119 | sleep 10s |
| 120 | else |
| 121 | fail "Command ${@} failed after $n attempts. Better to abort now." |
| 122 | fi |
| 123 | done |
| 124 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 125 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 126 | may_self_extract() { |
| 127 | # extract and untar to the current directory |
| 128 | sed '0,/^# PAYLOAD BELOW #$/d' "$0" | tar -xvpf - ; |
| 129 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 130 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 131 | update_hosts() { |
| 132 | if grep -q "^[^#]\+\s$SIMUL_HOSTS\s*\$" /etc/hosts ; then |
| 133 | message info "simulated domains already in /etc/hosts" |
| 134 | else |
| 135 | echo "$LOCAL_IP $SIMUL_HOSTS" >> /etc/hosts |
| 136 | message info "simulated domains added to /etc/hosts (please check it)" |
| 137 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 138 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 139 | if grep -q "^[^#]\+\s$NEXUS_FQDN\s*\$" /etc/hosts ; then |
| 140 | message info "nexus FQDN already in /etc/hosts" |
| 141 | else |
| 142 | echo "$LOCAL_IP $NEXUS_FQDN" >> /etc/hosts |
| 143 | message info "Nexus FQDN added to /etc/hosts (please check it)" |
| 144 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 145 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 146 | if grep -q "^[^#]\+\srepo.install-server\s*\$" /etc/hosts ; then |
| 147 | message info "custom repo FQDN already in /etc/hosts" |
| 148 | else |
| 149 | echo "$LOCAL_IP repo.install-server" >> /etc/hosts |
| 150 | message info "Nexus FQDN added to /etc/hosts (please check it)" |
| 151 | fi |
| 152 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 153 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 154 | get_cfg_val() { |
| 155 | name="$1" |
| 156 | shift |
| 157 | ask="$@" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 158 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 159 | value=$(eval "echo \$${name}") |
| 160 | if [ -z "$value" ]; then |
| 161 | while [ -z "$value" ] ; do |
| 162 | printf "${ask}" |
| 163 | read -r $name |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 164 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 165 | value=$(eval "echo \$${name}") |
| 166 | done |
| 167 | echo "${name}='${value}'" >> ./local_repo.conf |
| 168 | fi |
| 169 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 170 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 171 | get_configuration() { |
| 172 | if [ -f ./local_repo.conf ]; then |
| 173 | . ./local_repo.conf |
| 174 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 175 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 176 | if [ -z "${NEXUS_FQDN}" ]; then |
| 177 | NEXUS_FQDN="nexus.$HOSTNAME" |
| 178 | echo "NEXUS_FQDN='${NEXUS_FQDN}'" >> ./local_repo.conf |
| 179 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 180 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 181 | if [ -z "${ONAP_SCALE}" ]; then |
| 182 | ONAP_SCALE=full |
| 183 | echo "ONAP_SCALE='${ONAP_SCALE}'" >> ./local_repo.conf |
| 184 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 185 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 186 | # nexus should be configured using those default entries |
| 187 | # if it was not put the correct inputs instead |
| 188 | if [ -z "${NPM_USERNAME}" ]; then |
| 189 | NPM_USERNAME="${NEXUS_USERNAME}" |
| 190 | echo "NPM_USERNAME='${NPM_USERNAME}'" >> ./local_repo.conf |
| 191 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 192 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 193 | if [ -z "${NPM_PASSWORD}" ]; then |
| 194 | NPM_PASSWORD="${NEXUS_PASSWORD}" |
| 195 | echo "NPM_PASSWORD='${NPM_PASSWORD}'" >> ./local_repo.conf |
| 196 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 197 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 198 | if [ -z "${NPM_EMAIL}" ]; then |
| 199 | NPM_EMAIL="$NEXUS_EMAIL" |
| 200 | echo "NPM_EMAIL='${NPM_EMAIL}'" >> ./local_repo.conf |
| 201 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 202 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 203 | export NEXUS_FQDN |
| 204 | export ONAP_SCALE |
| 205 | export NPM_USERNAME |
| 206 | export NPM_PASSWORD |
| 207 | export NPM_EMAIL |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 208 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 209 | NODE_USERNAME="root" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 210 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 211 | if [ -z "$LOCAL_IP" ] ; then |
| 212 | echo |
| 213 | echo "======= Mandatory configuration =======" |
| 214 | echo |
| 215 | message info "fill in these mandatory configuration values" |
| 216 | get_cfg_val "LOCAL_IP" "Enter the public IPv4 used for this '$HOSTNAME' install machine," \ |
| 217 | "\nDO NOT USE LOOPBACK! (for example: 10.0.0.1): " |
| 218 | fi |
| 219 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 220 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 221 | enable_local_repo() { |
| 222 | sed -r "s%PATH%file://$APROJECT_DIR/resources/pkg/rhel%" "$APROJECT_DIR/resources/pkg/rhel/onap.repo" > /etc/yum.repos.d/onap.repo |
| 223 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 224 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 225 | install_packages() { |
| 226 | os_id="$1" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 227 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 228 | message info "Installing packages" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 229 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 230 | case "$os_id" in |
| 231 | centos) |
| 232 | yum -y install "$APROJECT_DIR/resources/pkg/centos/*.rpm" |
| 233 | ;; |
| 234 | rhel) |
| 235 | enable_local_repo |
| 236 | yum -y install docker-ce dnsmasq icewm firefox tigervnc-server |
| 237 | systemctl enable docker |
| 238 | systemctl start docker |
| 239 | ;; |
| 240 | ubuntu) |
| 241 | dpkg -i "$APROJECT_DIR/resources/pkg/ubuntu/*.deb" |
| 242 | ;; |
| 243 | *) |
| 244 | message error "OS release is not supported: $os_id" |
| 245 | message info "ABORTING INSTALLATION" |
| 246 | exit 1 |
| 247 | ;; |
| 248 | esac |
| 249 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 250 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 251 | install_files() { |
| 252 | message info "installation of external binaries" |
| 253 | for binary in kubectl helm rancher jq ; do |
| 254 | cp "$APROJECT_DIR/resources/downloads/${binary}" /usr/local/bin/ |
| 255 | chmod 755 "/usr/local/bin/${binary}" |
| 256 | done |
Petr Ospalý | cde2f33 | 2019-01-15 15:26:28 +0100 | [diff] [blame] | 257 | mkdir -p ~/.kube |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 258 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 259 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 260 | setup_vnc_server() { |
| 261 | mkdir -p ~/.vnc ~/.icewm |
| 262 | echo "onap" | vncpasswd -f > ~/.vnc/passwd |
| 263 | chmod 0600 ~/.vnc/passwd |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 264 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 265 | cat > ~/.vnc/xstartup <<EOF |
| 266 | #!/bin/sh |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 267 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 268 | unset SESSION_MANAGER |
| 269 | unset DBUS_SESSION_BUS_ADDRESS |
| 270 | exec icewm-session |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 271 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 272 | EOF |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 273 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 274 | chmod +x ~/.vnc/xstartup |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 275 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 276 | cat > ~/.icewm/menu <<EOF |
| 277 | prog Firefox firefox firefox |
| 278 | separator |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 279 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 280 | EOF |
| 281 | vncserver |
| 282 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 283 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 284 | update_docker_cfg() { |
| 285 | if [ -f "/etc/docker/daemon.json" ]; then |
| 286 | jq '.dns += ["172.17.0.1"]' /etc/docker/daemon.json > /tmp/daemon.json |
| 287 | mv /tmp/daemon.json /etc/docker/daemon.json |
| 288 | else |
| 289 | echo '{"dns": ["172.17.0.1"]}' > /etc/docker/daemon.json |
| 290 | fi |
| 291 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 292 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 293 | create_root_CA() { |
| 294 | echo "** Generate certificates **" |
| 295 | openssl genrsa -out $CERTS_TARGET_PATH/rootCA.key 4096 |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 296 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 297 | echo "** Generate self signed ***" |
| 298 | openssl req -config $GEN_CFG_PATH/cacert.cnf -key $CERTS_TARGET_PATH/rootCA.key -new -x509 -days 7300 -sha256 -extensions v3_ca \ |
| 299 | -out $CERTS_TARGET_PATH/rootCAcert.pem |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 300 | |
| 301 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 302 | # convert to crt |
| 303 | openssl x509 -in $CERTS_TARGET_PATH/rootCAcert.pem -inform PEM -out $CERTS_TARGET_PATH/rootCAcert.crt |
| 304 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 305 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 306 | install_root_CA() { |
| 307 | os=$1 |
| 308 | echo "** Publishing root CA **" |
| 309 | if [ "$os" == "redhat" ]; then |
| 310 | # for centos |
| 311 | update-ca-trust force-enable |
| 312 | cp $CERTS_TARGET_PATH/rootCAcert.crt /etc/pki/ca-trust/source/anchors/ |
| 313 | update-ca-trust extract |
| 314 | elif [ "$os" == "ubuntu" ]; then |
| 315 | mkdir -p /usr/local/share/ca-certificates/extra |
| 316 | cp $CERTS_TARGET_PATH/rootCAcert.crt /usr/local/share/ca-certificates/extra |
| 317 | update-ca-certificates |
| 318 | else |
| 319 | echo "OS \"$os\" is not supported" |
| 320 | exit -2 |
| 321 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 322 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 323 | echo "** Restart docker (because of reload new CA) **" |
| 324 | systemctl restart docker |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 325 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 326 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 327 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 328 | create_cert() { |
| 329 | server_name=$1 |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 330 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 331 | openssl genrsa -out $CERTS_TARGET_PATH/${server_name}_server.key 4096 |
| 332 | echo "** Generate sig request ***" |
| 333 | openssl req -new -config $GEN_CFG_PATH/${server_name}_cert.cnf -key $CERTS_TARGET_PATH/${server_name}_server.key -out $CERTS_TARGET_PATH/${server_name}_server.csr |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 334 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 335 | # v3.ext must be in separate file , because of bug in openssl 1.0 |
| 336 | echo "** sign **" |
| 337 | openssl x509 -req -in $CERTS_TARGET_PATH/${server_name}_server.csr\ |
| 338 | -extfile $GEN_CFG_PATH/v3.ext\ |
| 339 | -CA $CERTS_TARGET_PATH/rootCAcert.crt\ |
| 340 | -CAkey $CERTS_TARGET_PATH/rootCA.key\ |
| 341 | -CAcreateserial -out $CERTS_TARGET_PATH/${server_name}_server.crt -days 3650 -sha256 |
| 342 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 343 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 344 | create_all_certs() { |
| 345 | create_cert "nexus" |
| 346 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 347 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 348 | update_firewall() { |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 349 | # TODO |
| 350 | #firewall-cmd --permanent --add-port=53/udp |
| 351 | #firewall-cmd --permanent --add-port=53/tcp |
| 352 | #firewall-cmd --permanent --add-port=10001/tcp |
| 353 | #firewall-cmd --permanent --add-port=80/tcp |
| 354 | #firewall-cmd --permanent --add-port=443/tcp |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 355 | return 0 |
| 356 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 357 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 358 | distribute_root_CA() { |
| 359 | targetip=$1 |
| 360 | scp $APROJECT_DIR/install_cacert.sh $targetip:. |
| 361 | ssh $targetip ./install_cacert.sh |
| 362 | echo "** Add DNS record to remote host **" |
| 363 | ssh $targetip "echo nameserver $LOCAL_IP > /etc/resolv.conf" |
| 364 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 365 | |
| 366 | upload_ansible_pkgs() { |
| 367 | os=$1 |
| 368 | targetip=$2 |
| 369 | #if [[ $os == "ubuntu" ]]; then |
| 370 | # those deb & whl packages are needed for sdnc-ansible-server pod |
| 371 | # independently on host OS distros |
| 372 | echo "** Copy required packages for sdnc-ansible-pod to kubernetes node $targetip **" |
| 373 | scp -r $APROJECT_DIR/resources/pkg/ubuntu/ansible_pkg $targetip:. |
| 374 | #fi |
| 375 | } |
| 376 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 377 | remote_setup_nfs_server() { |
| 378 | os=$1 |
| 379 | targetip=$2 |
| 380 | shift 2 |
| 381 | scp $APROJECT_DIR/bash/tools/setup_nfs_server_${os}.sh $targetip:setup_nfs_server.sh |
| 382 | if [[ $os == "ubuntu" ]]; then |
| 383 | scp -r $APROJECT_DIR/resources/pkg/ubuntu/nfs-common-pkg/* $targetip:. |
| 384 | ssh $targetip dpkg -i *.deb |
| 385 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 386 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 387 | ssh $targetip /bin/bash ./setup_nfs_server.sh "$@" |
| 388 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 389 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 390 | remote_setup_nfs_mount() { |
| 391 | os=$1 |
| 392 | targetip=$2 |
| 393 | nfsip=$3 |
| 394 | scp $APROJECT_DIR/bash/tools/setup_nfs_mount.sh $targetip:. |
| 395 | if [[ $os == "ubuntu" ]]; then |
| 396 | scp -r $APROJECT_DIR/resources/pkg/ubuntu/nfs-common-pkg/* $targetip:. |
| 397 | ssh $targetip dpkg -i *.deb |
| 398 | fi |
| 399 | ssh $targetip /bin/bash ./setup_nfs_mount.sh $nfsip |
| 400 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 401 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 402 | enable_remote_repo() { |
| 403 | targetip=$1 |
| 404 | sed -r "s%PATH%http://repo.install-server%" $APROJECT_DIR/resources/pkg/rhel/onap.repo | ssh $targetip 'cat > /etc/yum.repos.d/onap.repo' |
| 405 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 406 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 407 | install_remote_docker() { |
| 408 | targetip=$1 |
| 409 | os=$2 |
| 410 | if [[ $os == "ubuntu" ]]; then |
| 411 | scp -r $APROJECT_DIR/resources/pkg/ubuntu/{docker-ce_17.03.2~ce-0~ubuntu-xenial_amd64.deb,libltdl7_2.4.6-0.1_amd64.deb} $targetip:. |
| 412 | ssh $targetip dpkg -i *.deb |
| 413 | elif [[ $os == "rhel" ]]; then |
| 414 | ssh $targetip yum -y install docker-ce |
| 415 | fi |
| 416 | ssh $targetip "mkdir -p /etc/docker" |
| 417 | scp "$APROJECT_DIR/resources/downloads/jq" $targetip:/usr/local/bin/ |
| 418 | ssh $targetip "if [[ -f /etc/docker/daemon.json ]]; then |
| 419 | jq '.dns += [\"$LOCAL_IP\"]' /etc/docker/daemon.json > /tmp/daemon.json |
| 420 | mv /tmp/daemon.json /etc/docker/daemon.json |
| 421 | else |
| 422 | echo {'\"'dns'\"': ['\"'$LOCAL_IP'\"']} > /etc/docker/daemon.json |
| 423 | fi" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 424 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 425 | ssh $targetip 'systemctl enable docker; systemctl restart docker' |
| 426 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 427 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 428 | deploy_rancher() { |
| 429 | docker run -d --entrypoint "/bin/bash" --restart=unless-stopped -p 8080:8080 \ |
| 430 | -v $CERTS_TARGET_PATH:/usr/local/share/ca-certificates/extra:ro \ |
| 431 | --name rancher_server rancher/server:v1.6.14 \ |
| 432 | -c "/usr/sbin/update-ca-certificates;/usr/bin/entry /usr/bin/s6-svscan /service" |
| 433 | echo "** wait until rancher is ready **" |
| 434 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 435 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 436 | deploy_kubernetes() { |
| 437 | os=$1 |
| 438 | set +e |
| 439 | for i in `seq 5 -1 1`; do |
| 440 | API_RESPONSE=`curl -s 'http://127.0.0.1:8080/v2-beta/apikey' \ |
| 441 | -d '{"type":"apikey","accountId":"1a1","name":"autoinstall"\ |
| 442 | ,"description":"autoinstall","created":null,"kind":null,\ |
| 443 | "removeTime":null,"removed":null,"uuid":null}'` |
| 444 | if [[ "$?" -eq 0 ]]; then |
| 445 | KEY_PUBLIC=`echo $API_RESPONSE | jq -r .publicValue` |
| 446 | KEY_SECRET=`echo $API_RESPONSE | jq -r .secretValue` |
| 447 | break |
| 448 | fi |
| 449 | echo "Waiting for rancher server to start" |
| 450 | sleep 60 |
| 451 | done |
| 452 | set -e |
| 453 | export RANCHER_URL=http://${LOCAL_IP}:8080 |
| 454 | export RANCHER_ACCESS_KEY=$KEY_PUBLIC |
| 455 | export RANCHER_SECRET_KEY=$KEY_SECRET |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 456 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 457 | rancher env ls |
| 458 | echo "wait 60 sec for rancher environments can settle before we create the onap kubernetes one" |
| 459 | sleep 60 |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 460 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 461 | rancher env create -t kubernetes onap > kube_env_id.json |
| 462 | PROJECT_ID=$(<kube_env_id.json) |
| 463 | echo "env id: $PROJECT_ID" |
| 464 | export RANCHER_HOST_URL=http://${LOCAL_IP}:8080/v1/projects/$PROJECT_ID |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 465 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 466 | for i in `seq 5`; do |
| 467 | status=$(rancher env ls | grep $PROJECT_ID | awk '{print $4}') |
| 468 | if [[ "$status" == "active" ]]; then |
| 469 | echo "Check on environments again before registering the URL response" |
| 470 | rancher env ls |
| 471 | break |
| 472 | fi |
| 473 | echo "Wait for environment to become active" |
| 474 | sleep 30 |
| 475 | done |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 476 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 477 | REG_URL_RESPONSE=`curl -X POST -u $KEY_PUBLIC:$KEY_SECRET -H 'Accept: application/json' -H 'ContentType: application/json' -d '{"name":"$LOCAL_IP"}' "http://$LOCAL_IP:8080/v1/projects/$PROJECT_ID/registrationtokens"` |
| 478 | echo "wait for server to finish url configuration - 3 min" |
| 479 | sleep 180 |
| 480 | # see registrationUrl in |
| 481 | REGISTRATION_TOKENS=`curl http://127.0.0.1:8080/v2-beta/registrationtokens` |
| 482 | REGISTRATION_DOCKER=`echo $REGISTRATION_TOKENS | jq -r .data[0].image` |
| 483 | REGISTRATION_TOKEN=`echo $REGISTRATION_TOKENS | jq -r .data[0].token` |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 484 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 485 | # base64 encode the kubectl token from the auth pair |
| 486 | # generate this after the host is registered |
| 487 | KUBECTL_TOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0) |
| 488 | echo "KUBECTL_TOKEN base64 encoded: ${KUBECTL_TOKEN}" |
| 489 | cat > ~/.kube/config <<EOF |
| 490 | apiVersion: v1 |
| 491 | kind: Config |
| 492 | clusters: |
| 493 | - cluster: |
| 494 | api-version: v1 |
| 495 | insecure-skip-tls-verify: true |
| 496 | server: "https://$LOCAL_IP:8080/r/projects/$PROJECT_ID/kubernetes:6443" |
| 497 | name: "onap" |
| 498 | contexts: |
| 499 | - context: |
| 500 | cluster: "onap" |
| 501 | user: "onap" |
| 502 | name: "onap" |
| 503 | current-context: "onap" |
| 504 | users: |
| 505 | - name: "onap" |
| 506 | user: |
| 507 | token: "$KUBECTL_TOKEN" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 508 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 509 | EOF |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 510 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 511 | if [[ $os == "rhel" ]]; then |
| 512 | echo "Upgrade datavolume for RHEL" |
| 513 | KUBELET_ID=`curl http://${LOCAL_IP}:8080/v2-beta/projects/${PROJECT_ID}/services/ | jq -r '.data[] | select(.name=="kubelet")'.id` |
| 514 | OLD_LAUNCH_CONFIG=`curl http://${LOCAL_IP}:8080/v2-beta/projects/${PROJECT_ID}/services/${KUBELET_ID} | jq '.launchConfig'` |
| 515 | NEW_LAUNCH_CONFIG=`echo $OLD_LAUNCH_CONFIG | jq '.dataVolumes[2]="/sys/fs/cgroup:/sys/fs/cgroup:ro,rprivate"'` |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 516 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 517 | DATA="{ |
| 518 | \"inServiceStrategy\": { |
| 519 | \"batchSize\": 1, |
| 520 | \"intervalMillis\": 2000, |
| 521 | \"startFirst\": false, |
| 522 | \"launchConfig\": ${NEW_LAUNCH_CONFIG}, |
| 523 | \"secondaryLaunchConfigs\": [] |
| 524 | } |
| 525 | }" |
| 526 | curl -s -u $KEY_PUBLIC:$KEY_SECRET -X POST -H 'Content-Type: application/json' -d "${DATA}" "http://${LOCAL_IP}:8080/v2-beta/projects/${PROJECT_ID}/services/${KUBELET_ID}?action=upgrade" > /dev/null |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 527 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 528 | echo "Give environment time to update (30 sec)" |
| 529 | sleep 30 |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 530 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 531 | curl -s -u $KEY_PUBLIC:$KEY_SECRET -X POST "http://${LOCAL_IP}:8080/v2-beta/projects/${PROJECT_ID}/services/${KUBELET_ID}?action=finishupgrade" > /dev/null |
| 532 | fi |
| 533 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 534 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 535 | deploy_rancher_agent() { |
| 536 | nodeip=$1 |
| 537 | if [ -z "$REGISTRATION_DOCKER" ]; then |
| 538 | echo "ASSERT: Missing REGISTRATION_DOCKER" |
| 539 | exit 1 |
| 540 | fi |
| 541 | if [ -z "$RANCHER_URL" ]; then |
| 542 | echo "ASSERT: Missing RANCHER_URL" |
| 543 | exit 1 |
| 544 | fi |
| 545 | if [ -z "$REGISTRATION_TOKEN" ]; then |
| 546 | echo "ASSERT: Missing REGISTRATION_TOKEN" |
| 547 | exit 1 |
| 548 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 549 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 550 | ssh $nodeip "docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/racher:/var/lib/rancher $REGISTRATION_DOCKER $RANCHER_URL/v1/scripts/$REGISTRATION_TOKEN" |
| 551 | echo "waiting 2 min for creating kubernetes environment" |
| 552 | sleep 120 |
| 553 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 554 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 555 | deploy_node() { |
| 556 | nodeip=$1 |
| 557 | os=$2 |
| 558 | echo "Deploying node $nodeip" |
| 559 | distribute_root_CA $nodeip |
| 560 | install_remote_docker $nodeip $os |
| 561 | deploy_rancher_agent $nodeip |
| 562 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 563 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 564 | deploy_onap() { |
| 565 | pushd $APROJECT_DIR/resources/oom/kubernetes |
| 566 | helm init --upgrade --skip-refresh |
| 567 | # this might fail |
| 568 | set +e |
| 569 | helm repo remove stable |
| 570 | set -e |
| 571 | helm serve & |
| 572 | echo "wait a moment before helm will come up ..." |
| 573 | sleep 5 |
| 574 | helm repo add local http://127.0.0.1:8879 |
| 575 | make all |
| 576 | #Pass the CA certificate contents directly during installation. |
| 577 | helm install local/onap -n dev --namespace onap \ |
| 578 | --set "global.cacert=$(cat ${CERTS_TARGET_PATH}/rootCAcert.crt)" |
| 579 | popd |
| 580 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 581 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 582 | expand_file() { |
| 583 | file=$1 |
| 584 | # print warning if patched file does not exist as some charts |
| 585 | # might not be available for some deployments |
| 586 | if [ ! -f "$file" ]; then |
| 587 | echo "WARNING: Can't patch file $file because this file does not exists." |
| 588 | return 0 |
| 589 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 590 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 591 | shift |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 592 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 593 | for ivar in "$@" ; do |
| 594 | ivalue=$(eval 'echo "$'${ivar}'"') |
| 595 | sed -i "s#${ivar}#${ivalue}#g" "$file" |
| 596 | done |
| 597 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 598 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 599 | patch_npm_oom() { |
| 600 | if [ -z "$LOCAL_IP" ] ; then |
| 601 | echo "ERROR: LOCAL_IP unset" |
| 602 | return 1 |
| 603 | fi |
| 604 | if [ -z "$NEXUS_FQDN" ] ; then |
| 605 | echo "ERROR: NEXUS_FQDN unset" |
| 606 | return 1 |
| 607 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 608 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 609 | UPDATE_HOSTS_FILE="$LOCAL_IP $NEXUS_FQDN" |
| 610 | UPDATE_NPM_REGISTRY="npm set registry \"http://${NEXUS_FQDN}/repository/npm-private/\"" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 611 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 612 | expand_file $APROJECT_DIR/resources/oom/kubernetes/common/dgbuilder/templates/deployment.yaml \ |
| 613 | UPDATE_HOSTS_FILE \ |
| 614 | UPDATE_NPM_REGISTRY |
| 615 | expand_file $APROJECT_DIR/resources/oom/kubernetes/sdnc/charts/sdnc-portal/templates/deployment.yaml \ |
| 616 | UPDATE_HOSTS_FILE \ |
| 617 | UPDATE_NPM_REGISTRY |
| 618 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 619 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 620 | patch_spring_oom() { |
| 621 | if [ -z "$LOCAL_IP" ] ; then |
| 622 | echo "ERROR: LOCAL_IP unset" |
| 623 | return 1 |
| 624 | fi |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 625 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 626 | UPDATE_HOSTS_FILE="$LOCAL_IP www.springframework.org" |
| 627 | expand_file $APROJECT_DIR/resources/oom/kubernetes/dmaap/charts/message-router/templates/deployment.yaml \ |
| 628 | UPDATE_HOSTS_FILE |
| 629 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 630 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 631 | patch_cfy_manager_depl() { |
| 632 | os="$1" |
| 633 | file="${APROJECT_DIR}/resources/oom/kubernetes/dcaegen2/charts/dcae-cloudify-manager/templates/deployment.yaml" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 634 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 635 | case "$os" in |
| 636 | centos|rhel) |
| 637 | CERT_PATH="/etc/pki/ca-trust/source/anchors" |
| 638 | ;; |
| 639 | ubuntu) |
| 640 | CERT_PATH="/usr/local/share/ca-certificates/extra" |
| 641 | ;; |
| 642 | '') |
| 643 | echo "ERROR: missing argument" |
| 644 | return 1 |
| 645 | ;; |
| 646 | *) |
| 647 | echo "ERROR: unknown OS: ${os}" |
| 648 | return 1 |
| 649 | ;; |
| 650 | esac |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 651 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 652 | expand_file "$file" CERT_PATH |
| 653 | } |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 654 | |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 655 | copy_onap_values_file() { |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 656 | cp "${APROJECT_DIR}/${CUSTOM_CFG_RELPATH:-cfg}/${ONAP_SCALE}_depl_values.yaml" \ |
Piotr Perzanowski | a69b4f6 | 2018-12-18 12:12:51 +0100 | [diff] [blame] | 657 | "${APROJECT_DIR}/resources/oom/kubernetes/onap/values.yaml" |
Petr Ospalý | 8100123 | 2019-01-02 15:52:24 +0100 | [diff] [blame] | 658 | } |