3 # Copyright (c) 2016 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 TEMP_PATH="/root/temp"
21 echo "********** INSTALLING APT PACKAGES **********"
22 echo -n > /etc/apt/sources.list
24 export DEBIAN_FRONTEND=noninteractive
26 # We're doing this the hard way as we're dealing with a bunch of
27 # .deb packages rather than any sources organized through APT.
29 # Attempt up to five cycles of unpack/configure. There may be dependency
30 # problems during the first one(s).
36 while [ $attempt -le $MAX_ATTEMPTS ] && [ $try_again -eq 1 ]
39 echo "Attempting .deb package installation, attempt #${attempt}/${MAX_ATTEMPTS}"
40 dpkg --unpack --recursive --skip-same-version ${TEMP_PATH}/deb || try_again=1
41 dpkg --configure --pending || try_again=1
42 if [ $try_again -eq 1 ]
44 echo Encountered errors.
46 attempt=$(( $attempt + 1 ))
49 if [ $try_again -eq 1 ]
51 echo "Still encountered errors after ${MAX_ATTEMPTS} attempts. Aborting".
58 echo "********** INSTALLING PIP PACKAGES **********"
59 pip install --no-index --find-links ${TEMP_PATH}/pip/ -r ${TEMP_PATH}/requirements.txt
62 echo "********** CREATING HISTORIC LINK FOR QEMU, COPY NESTED VM IMAGE **********"
63 mkdir -p /opt/qemu/bin
64 ln -s /usr/bin/qemu-system-x86_64 /opt/qemu/bin/qemu-system-x86_64
68 echo "Embedding nested VM image on this image"
69 mkdir /var/lib/vm/images
70 cp ${TEMP_PATH}/nested-vm/* /var/lib/vm/images/
71 # There should only be one file at this time
72 ln -s /var/lib/vm/images/* /var/lib/vm/vhost-nested.img
76 # Mount hugepages directory for nested VM
78 echo 'hugetlbfs /mnt/huge hugetlbfs mode=1770,gid=111 0 0' >> /etc/fstab
83 echo "********** CREATING JAVA SHELL PROFILE **********"
84 mkdir -p /etc/profile.d
85 echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64' > /etc/profile.d/java.sh
86 echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/java.sh
92 echo "********** MOVING CHANGELOG AND VERSION FILES **********"
94 mv ${TEMP_PATH}/VERSION /
95 mv ${TEMP_PATH}/CHANGELOG /
97 echo "********** CLEANING UP **********"