Update of Packer builder for Vagrant and various clouds
[osm/devops.git] / packer / packer_templates / _common / vmware.sh
1 #!/bin/sh -eux
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # set a default HOME_DIR environment variable if not set
16 HOME_DIR="${HOME_DIR:-/home/vagrant}";
17
18 case "$PACKER_BUILDER_TYPE" in
19 vmware-iso|vmware-vmx)
20
21 # make sure we have /sbin in our path. RHEL systems lack this
22 PATH=/sbin:$PATH
23 export PATH
24
25 mkdir -p /tmp/vmware;
26 mkdir -p /tmp/vmware-archive;
27 mount -o loop $HOME_DIR/linux.iso /tmp/vmware;
28
29 TOOLS_PATH="`ls /tmp/vmware/VMwareTools-*.tar.gz`";
30 VER="`echo "${TOOLS_PATH}" | cut -f2 -d'-'`";
31 MAJ_VER="`echo ${VER} | cut -d '.' -f 1`";
32
33 echo "VMware Tools Version: $VER";
34
35 tar xzf ${TOOLS_PATH} -C /tmp/vmware-archive;
36 if [ "${MAJ_VER}" -lt "10" ]; then
37 /tmp/vmware-archive/vmware-tools-distrib/vmware-install.pl --default;
38 else
39 /tmp/vmware-archive/vmware-tools-distrib/vmware-install.pl --force-install;
40 fi
41 umount /tmp/vmware;
42 rm -rf /tmp/vmware;
43 rm -rf /tmp/vmware-archive;
44 rm -f $HOME_DIR/*.iso;
45 ;;
46 esac