AlkantarClanX12
| Current Path : /var/lib/dpkg/info/ |
| Current File : /var/lib/dpkg/info/cloud-init.config |
#!/bin/sh -e
. /usr/share/debconf/confmodule
hasEc2Md() {
local d=/var/lib/cloud i=/var/lib/cloud/instance/ f=""
local flist="${i}/datasource ${i}/obj.pkl ${d}/cache/obj.pkl"
# search current instance data source information
for f in ${flist}; do
[ -f "${f}" ] || continue
grep -q DataSourceEc2 "${f}" 2>/dev/null && return 0
done
# there was no data above found that would have been indicated
# by a upgrade. lets just see if we can't find the metadata
# service. if wget is not present (it is not 'essential')
# then we will quietly return 1
local url="http://169.254.169.254/2009-04-04/meta-data/instance-id"
i=""
if command -v wget >/dev/null 2>&1; then
local tout="--connect-timeout 5 --read-timeout 5 --tries 1"
i=$(wget "${url}" ${tout} -O - 2>/dev/null) || :
elif command -v curl >/dev/null 2>&1; then
i=$(curl "${url}" --max-time 1) || :
fi
# if instance-id starts with 'i-' then in all likelyhood its good
[ "${i#i-}" != "${i}" ] && return 0
return 1
}
if [ -f /etc/cloud/cloud.cfg.d/90_dpkg.cfg ] && [ -f /etc/cloud/distro.cfg ] ; then
DATASRC_LIST=`cat /etc/cloud/cloud.cfg.d/90_dpkg.cfg | grep "datasource_list:" | sed 's/datasource_list: \[ //' | sed 's/ \]//'`
if [ -n "${DATASRC_LIST}" ] ; then
db_set cloud-init/datasources ${DATASRC_LIST}
fi
else
if { db_fget cloud-init/datasources seen || : ; } &&
[ "${RET}" = "false" ]; then
db_get cloud-init/datasources
def="${RET}"
# if this is the first time this we've run, then try
# to detect if we would have access to DataSourceEc2
case " ${def}," in
*\ Ec2,*) :;;
*) hasEc2Md &&
db_set cloud-init/datasources "${def:+${def}, }Ec2";;
esac
fi
fi
db_input low cloud-init/datasources || true
db_go
exit 0