Support for ds-identify

This patch adds support for using the datasource with cloud-init
installations that leverage ds-identify
(https://github.com/number5/cloud-init/blob/master/tools/ds-identify).

The ds-identify program uses bash types (functions, scripts, etc.) to
determine whether or not a configured datasource is valid on the
installed system. The script in this patch allows the ds-identify
program to query whether or not the VMwareGuestInfo datasource is valid.
Otherwise, depending on how ds-identify is configured, a system
configured to use the VMwareGuestInfo datasource might actually have it
disabled after ds-identify fails to query the datasource's availability.
diff --git a/dscheck_VMwareGuestInfo.sh b/dscheck_VMwareGuestInfo.sh
new file mode 100644
index 0000000..2e55e0b
--- /dev/null
+++ b/dscheck_VMwareGuestInfo.sh
@@ -0,0 +1,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/local/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
diff --git a/install.sh b/install.sh
index 06e04e7..6226690 100755
--- a/install.sh
+++ b/install.sh
@@ -36,4 +36,10 @@
 curl -sSL -o /etc/cloud/cloud.cfg.d/99-DataSourceVMwareGuestInfo.cfg \
   "${REPO_SLUG}/${GIT_REF}/99-DataSourceVMwareGuestInfo.cfg"
 
+# Download program used by ds-identify to determine wheether or not the
+# VMwareGuestInfo datasource is useable.
+curl -sSL -o "/usr/local/bin/dscheck_VMwareGuestInfo" \
+  "${REPO_SLUG}/${GIT_REF}/dscheck_VMwareGuestInfo.sh"
+chmod 0755 "/usr/local/bin/dscheck_VMwareGuestInfo"
+
 echo "So long, and thanks for all the fish."