Update VIRL images to 16.04.1
[csit.git] / resources / tools / disk-image-builder / ubuntu / build-listmaker.sh
1 #!/bin/sh
2
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:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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
15 # This builds the "listmaker" image. This is essentially a one-time
16 # action and most likely applicable to CSIT test lab only.
17
18 cd $(dirname $0)
19 BUILD_DIR="$(pwd)/build"
20 PACKER_DIR="${BUILD_DIR}/packer"
21 OUT_DIR="${BUILD_DIR}/output/listmaker"
22
23 if [ "$1" == "ubuntu-14.04.4" ]
24 then
25     RELEASE_NAME="csit-ubuntu-14.04.4-listmaker"
26     PACKER_TEMPLATE="listmaker/ubuntu-14.04.4.json"
27 elif [ "$1" == "ubuntu-16.04.1" ]
28 then
29     RELEASE_NAME="csit-ubuntu-16.04.1-listmaker"
30     PACKER_TEMPLATE="listmaker/ubuntu-16.04.1.json"
31 else
32     echo "Please provide OS as parameter:"
33     echo "Options: ${0} [ubuntu-14.04.4|ubuntu-16.04.1]"
34     exit 1
35 fi
36
37 VIRL_IMAGE_SUBTYPE=server
38 VIRL_IMAGE_NAME="${RELEASE_NAME}"
39 VIRL_IMAGE_FILE="${OUT_DIR}/packer-${RELEASE_NAME}"
40
41 # export PACKER_LOG="1"
42
43 # This script requires that the following two environment variables be defined-
44 #
45 # $VIRL_USER
46 # $VIRL_PASSWORD
47
48 if [ "$VIRL_USER" = "" ] || [ "$VIRL_PASSWORD" = "" ]
49 then
50   echo '$VIRL_USER and $VIRL_PASSWORD environment variables must be defined'
51   exit 1
52 fi
53
54 ###
55 ### Download and extract packer, if not already installed
56 ###
57 os=$(uname -s)
58 if [ "$os" = "Darwin" ]
59 then
60   packer_url="https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_darwin_amd64.zip"
61 elif [ "$os" = "Linux" ]
62 then
63   packer_url="https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip"
64 fi
65
66 mkdir -p $BUILD_DIR
67 wget -P ${PACKER_DIR} -N ${packer_url}
68
69 unzip -n ${PACKER_DIR}/packer*zip -d ${PACKER_DIR}
70
71 ###
72 ### Build the actual image as per packer script. Packer post-processor will
73 ### upload it to VIRL.
74 ###
75 ${BUILD_DIR}/packer/packer build -var "release=${RELEASE_NAME}" \
76   -var "outputdir=${OUT_DIR}" -force -machine-readable ${PACKER_TEMPLATE}

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.