blob: fc3a6eb6a420f2c05986131924d0449981a39948 [file] [log] [blame]
akutz9efe9a22019-05-22 13:46:51 -05001#!/bin/sh
2
3# Cloud-Init Datasource for VMware Guestinfo
4#
5# Copyright (c) 2019 VMware, Inc. All Rights Reserved.
6#
7# This product is licensed to you under the Apache 2.0 license (the "License").
8# You may not use this product except in compliance with the Apache 2.0 License.
9#
10# This product may include a number of subcomponents with separate copyright
11# notices and license terms. Your use of these subcomponents is subject to the
12# terms and conditions of the subcomponent's license, as noted in the LICENSE
13# file.
14
15#
akutzd1f67642019-05-30 12:33:50 -050016# This file should be installed to /usr/bin/dscheck_VMwareGuestInfo
akutz9efe9a22019-05-22 13:46:51 -050017# without the ".sh" extension. The extension only exists to make it easier
18# to identify the file during development.
19#
20# This file provides cloud-init's ds-identify program a shell type that
21# can be resolved with "type dscheck_VMwareGuestInfo" and used to validate
22# where a datasource is installed and useable.
23#
24# Cloud-init's ds-identify program in /usr/lib/cloud-init includes functions
25# to determine whether or not datasources can be used. Because the program
26# is a shell script and uses "type dscheck_DATASOURCE_NAME" to determine
27# if there is a matching bash type that can answer for the datasource,
28# it's possible to respond with an external script. While other datasources
29# have functions in ds-identify, the "type" command looks up types both
30# in Bash's function table as well as script in the PATH. Therefore the
31# ds-identify program, when looking up whether or not the datasource
32# VMwareGuestInfo can be used, will defer to this file when it is in the
33# PATH and named dscheck_VMwareGuestInfo.
34#
35
36if ! command -v vmtoolsd >/dev/null 2>&1; then
37 exit 1
38fi
39
40if { vmtoolsd --cmd "info-get guestinfo.metadata" || \
41 vmtoolsd --cmd "info-get guestinfo.userdata" || \
42 vmtoolsd --cmd "info-get guestinfo.vendordata"; } >/dev/null 2>&1; then
43 exit 0
44fi
45
46exit 1