Refactor ONAP HEAT template config, part 2
[demo.git] / heat / ONAP / cloud-config / sdc_install.sh
1 #!/bin/bash
2
3 # Read configuration files
4 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
5 GERRIT_BRANCH=$(cat /opt/config/gerrit_branch.txt)
6 CODE_REPO=$(cat /opt/config/remote_repo.txt)
7 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
8 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
9
10 if [ $HTTP_PROXY != "no_proxy" ]
11 then
12     export http_proxy=$HTTP_PROXY
13     export https_proxy=$HTTPS_PROXY
14 fi
15
16
17 # Download scripts from Nexus
18 update-rc.d sdc_serv.sh defaults
19
20 # Create partition and mount the external volume
21 cp /opt/boot/sdc_ext_volume_partitions.txt /opt/sdc_ext_volume_partitions.txt
22
23 if [[ $CLOUD_ENV == "rackspace" ]]
24 then
25        DISK="xvdb"
26 else
27        DISK=$(ls /dev |grep -e '^.*db$')
28        sed -i "s/xvdb/$DISK/g" /opt/sdc_ext_volume_partitions.txt
29 fi
30
31 sfdisk /dev/$DISK < /opt/sdc_ext_volume_partitions.txt
32 mkfs -t ext4 /dev/$DISK"1"
33 mkdir -p /data
34 mount /dev/$DISK"1" /data
35 echo "/dev/"$DISK"1  /data           ext4    errors=remount-ro,noatime,barrier=0 0       1" >> /etc/fstab
36
37
38 # Clone Gerrit repository
39 cd /opt
40 mkdir -p /data/environments
41 mkdir -p /data/scripts
42 mkdir -p /data/logs/BE
43 mkdir -p /data/logs/FE
44 chmod 777 /data
45 chmod 777 /data/logs/BE
46 chmod 777 /data/logs/FE
47
48 git clone -b $GERRIT_BRANCH --single-branch $CODE_REPO
49
50 cat > /root/.bash_aliases << EOF
51 alias dcls='/data/scripts/docker_clean.sh \$1'
52 alias dlog='/data/scripts/docker_login.sh \$1'
53 alias rund='/data/scripts/docker_run.sh'
54 alias health='/data/scripts/docker_health.sh'
55 EOF
56
57 # Run docker containers. For openstack Ubuntu 16.04 images this will run as a service after the VM has restarted
58 ./sdc_vm_init.sh
59 ./sdc_wfd_vm_init.sh