Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2017-present Open Networking Foundation |
| 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 | set -xe |
| 18 | |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 19 | # This script assumes the following repos exist and will create them if not |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 20 | # ~/cord/automation-tools |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 21 | # ~/cord/helm-charts |
| 22 | |
| 23 | # Sanity tests |
| 24 | if [[ $UID == 0 ]]; then |
| 25 | echo "Please run this script as non-root user" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | if ! sudo -n true; then |
| 30 | echo "Please configure passwordless sudo on this account" |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 35 | |
| 36 | # Location of 'cord' directory for checkouts on the local system |
| 37 | CORDDIR="${CORDDIR:-${HOME}/cord}" |
| 38 | |
| 39 | [ ! -d "$CORDDIR" ] && mkdir -p "$CORDDIR" |
| 40 | [ ! -d "$CORDDIR"/automation-tools ] && cd "$CORDDIR" && git clone https://gerrit.opencord.org/automation-tools |
| 41 | [ ! -d "$CORDDIR"/helm-charts ] && cd "$CORDDIR" && git clone https://gerrit.opencord.org/helm-charts |
| 42 | |
| 43 | |
| 44 | # Install K8S, Helm, Openstack |
| 45 | "$CORDDIR"/automation-tools/openstack-helm/openstack-helm-dev-setup.sh |
| 46 | |
| 47 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 48 | # Add keys for VTN |
| 49 | [ ! -e ~/.ssh/id_rsa ] && ssh-keygen -f ~/.ssh/id_rsa -t rsa -N "" |
| 50 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
| 51 | cp ~/.ssh/id_rsa "$CORDDIR"/helm-charts/xos-profiles/base-openstack/files/node_key |
| 52 | |
| 53 | # Add dummy fabric interface |
Andy Bavier | 9958885 | 2018-06-05 12:59:51 -0700 | [diff] [blame] | 54 | if ! ifconfig fabric &>> /dev/null |
| 55 | then |
| 56 | sudo modprobe dummy |
| 57 | sudo ip link set name fabric dev dummy0 |
| 58 | sudo ifconfig fabric up |
| 59 | fi |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 60 | |
| 61 | # Install charts for M-CORD |
| 62 | cd "$CORDDIR"/helm-charts |
Andy Bavier | 306279b | 2018-06-26 10:09:31 -0700 | [diff] [blame] | 63 | sudo mkdir -p /var/local/vol1 |
| 64 | helm upgrade --install local-persistent-volume ./local-persistent-volume \ |
| 65 | --set volumeHostName="$( hostname -f )" |
| 66 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 67 | helm dep update ./xos-core |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 68 | helm upgrade --install xos-core ./xos-core \ |
Andy Bavier | 306279b | 2018-06-26 10:09:31 -0700 | [diff] [blame] | 69 | --set xos-gui.xos_projectName="M-CORD" \ |
| 70 | --set needDBPersistence=true |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 71 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 72 | |
| 73 | helm dep update ./xos-profiles/base-openstack |
| 74 | helm upgrade --install base-openstack ./xos-profiles/base-openstack \ |
| 75 | --set computeNodes.master.name="$( hostname )" \ |
| 76 | --set vtn-service.sshUser="$( whoami )" |
| 77 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 78 | |
| 79 | helm upgrade --install onos-cord ./onos |
| 80 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 81 | |
| 82 | helm dep update ./xos-profiles/mcord |
| 83 | helm upgrade --install mcord ./xos-profiles/mcord \ |
| 84 | --set global.proxySshUser="$( whoami )" |
| 85 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 86 | |
| 87 | |
Andy Bavier | 9958885 | 2018-06-05 12:59:51 -0700 | [diff] [blame] | 88 | # Firewall VNC ports for security (CloudLab) |
| 89 | if [ -d /mnt/extra ] |
| 90 | then |
| 91 | sudo ufw default allow incoming |
| 92 | sudo ufw default allow outgoing |
| 93 | sudo ufw default allow routed |
| 94 | sudo ufw deny proto tcp from any to any port 5900:5950 comment 'vnc' |
| 95 | sudo ufw --force enable |
| 96 | fi |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 97 | |
| 98 | echo "M-CORD has been successfully installed" |