Add PONSim installation scripts
[iec.git] / src / use_cases / seba_on_arm / test / ponsim / install.sh
1 #!/bin/bash
2 # shellcheck disable=SC2016
3
4 set -ex
5
6 basepath=$(cd "$(dirname "$0")"; pwd)
7
8 # Using opencord automation-tools from the cord-6.1 maintenance branch
9 AUTO_TOOLS_GIT="https://github.com/opencord/automation-tools.git"
10 AUTO_TOOLS_VER=${AUTO_TOOLS_VER:-cord-6.1}
11
12 export M=/tmp/milestones
13 export SEBAVALUE=
14 export WORKSPACE=${HOME}
15
16 mkdir -p ${M} "${WORKSPACE}/cord/test"
17
18 # Update helm-charts submdule needed later
19 # ignore subproject commit and use latest remote version
20 git submodule update --init --remote "${basepath}/../../src_repo/helm-charts"
21
22 cd "${WORKSPACE}"
23 test -d automation-tools || git clone "${AUTO_TOOLS_GIT}"
24 cd "${WORKSPACE}/automation-tools" && git checkout "${AUTO_TOOLS_VER}"
25
26 # Fake the setup phase so that portcheck.sh is not called
27 # also install some required packages
28 sudo apt install -y httpie jq software-properties-common bridge-utils make
29 # add iptbles rule needed to forward DHCP packets comming from the RG_POD
30 sudo iptables -P FORWARD ACCEPT
31 touch "${M}/setup"
32
33 # Skip helm installation if it already exists and fake /usr/local/bin/helm
34 if xhelm=$(command -v helm)
35 then
36   if [ "${xhelm}" != "/usr/local/bin/helm" ]
37   then
38      echo "helm is installed at ${xhelm}; symlinking to /usr/local/bin/helm"
39      mkdir -p /usr/local/bin/ || true
40      sudo ln -sf "${xhelm}" /usr/local/bin/helm
41   fi
42 else
43   echo "helm is not installed"
44 fi
45
46 # Faking helm-charts repo clone to our own git submodule if not already there
47 CHARTS="${WORKSPACE}/cord/helm-charts"
48 test -d "${CHARTS}" || test -h "${CHARTS}" || \
49     ln -s "${basepath}/../../src_repo/helm-charts" "${CHARTS}"
50
51 # Fake SiaB components setup since they are already installed
52 milestones="kubeadm helm-init kafka kafka-running etcd-operator-ready voltha \
53             voltha-running nem onos siab"
54
55 for m in ${milestones}
56 do
57   echo "Faking SiaB milestone ${M}/${m}"
58   test -f "${M}/${m}" || touch "${M}/${m}"
59 done
60
61 # Now calling make, to install PONSim
62 cd "${WORKSPACE}/automation-tools/seba-in-a-box"
63 make stable
64