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