4
BURL="http://169.254.169.254/2009-04-04"
5
MDURL="${BURL}/meta-data"
6
UDURL="${BURL}/user-data"
8
CLOUD_CONFIG=${STATE_D}/config.sh
13
[ -d "${STATE_D}" ] || mkdir -p "${STATE_D}"
15
[ -f "${CLOUD_CONFIG}" ] && . "${CLOUD_CONFIG}"
16
# CLOUD_CONFIG may set
20
TMPF=/tmp/${0##*/}.tmp
21
trap "rm -f ${TMPF}" EXIT
22
msg() { echo "${XN}: $1"; }
24
if [ "${2}" = "-" ]; then
25
wget -q -O - "${MDURL}/${1}"
27
local out=${2:-${TMPF}}
28
wget -q -O - "${MDURL}/${1}" > "${out}" &&
29
{ read _RET < "${TMPF}" ; :; }
33
local name=${2:-${XN}} iid=${1}
34
[ -f "${STATE_D}/${name}.${iid}" ]
37
local name=${2:-${XN}} iid=${1}
38
{ [ -d "${STATE_D}" ] || mkdir "${STATE_D}"; } ||
39
msg "failed to make ${STATE_D}"
40
date > "${STATE_D}/${name}.${iid}"
44
local dbf="${STATE_D}/mddebug"
45
if [ -f "${dbf}" ]; then
47
msg "running ${dbf} (${MD_DEBUG_COUNT} tries reached)"
48
echo "############ debug start ##############"
50
echo "############ debug end ##############"
53
msg "running debug (${MD_DEBUG_COUNT} tries reached)"
54
echo "############ debug start ##############"
55
echo "### /etc/rc.d/init.d/sshd start"
56
/etc/rc.d/init.d/sshd start
58
gw=$(route -n | awk '$1 == "0.0.0.0" && $2 != "0.0.0.0" { print $2 }')
59
echo "### ifconfig -a"
63
echo "### cat /etc/resolv.conf"
65
if [ -n "${gw}" ]; then
66
echo "### ping -c 5 ${gw}"
69
echo "### gateway not found"
71
local t1 t2 t3 nslist="" ns=""
72
while read t1 t2 t3; do
74
nameserver) nslist="${nslist} ${t2}";;
76
done < /etc/resolv.conf
77
echo "### pinging nameservers"
78
for ns in ${nslist}; do
79
echo "#### ping -c 5 ${ns}"
84
lxc-is-container || { echo "### lsmod"; lsmod; }
85
echo "### dmesg | tail"
87
echo "### tail -n 25 /var/log/messages"
88
tail -n 25 /var/log/messages
89
echo "############ debug end ##############"
93
[ "${IS_NOCLOUD:-0}" != "0" ] && return 0
95
{ grep -q "ds=nocloud" /proc/cmdline && return 0; }
96
[ -f /root/nocloud ] && return 0