Operation

Query

Insatnces

Volumes

Addresses

Groups

Keypairs

Eucalyptus

Amazon

Tools

EC2 data fetcher

(
set -e -E -C -u -o pipefail || exit 1

exec {_lock}>|/tmp/ec2-data.lock
flock -xn "${_lock}"

test ! -e /tmp/ec2-data
test ! -e /tmp/ec2-data.tar.gz

mkdir /tmp/ec2-data
echo -n >/tmp/ec2-data/.index
echo -n >/tmp/ec2-data/.index.enqueue

mkdir /tmp/ec2-data/2009-04-04
echo '2009-04-04/user-data' >>/tmp/ec2-data/.index.enqueue
echo '2009-04-04/meta-data/' >>/tmp/ec2-data/.index.enqueue

while test -s /tmp/ec2-data/.index.enqueue
do
    mv -T /tmp/ec2-data/.index.enqueue /tmp/ec2-data/.index.dequeue
    echo -n >/tmp/ec2-data/.index.enqueue
    while read _target
    do
        echo "[ii] fetching \`${_target}\`..." >&2
        curl -s "http://169.254.169.254/${_target}" >"/tmp/ec2-data/${_target%%/}.tmp"
        case "${_target}" in
            ( */ )
                test ! -e "/tmp/ec2-data/${_target%%/}"
                mkdir "/tmp/ec2-data/${_target%%/}"
                { cat "/tmp/ec2-data/${_target%%/}.tmp" ; echo ; } \
                | while read _entry
                do
                    test -n "${_entry}" || break
                    echo "${_target}${_entry}" >>/tmp/ec2-data/.index.enqueue
                done
                mv "/tmp/ec2-data/${_target%%/}.tmp" "/tmp/ec2-data/${_target%%/}/.data"
            ;;
            ( * )
                test ! -e "/tmp/ec2-data/${_target}"
                mv -T "/tmp/ec2-data/${_target}.tmp" "/tmp/ec2-data/${_target}"
            ;;
        esac
        echo "${_target}" >>/tmp/ec2-data/.index
    done </tmp/ec2-data/.index.dequeue
done

rm /tmp/ec2-data/.index.enqueue
rm /tmp/ec2-data/.index.dequeue

tar -czf /tmp/ec2-data.tar.gz -C /tmp ./ec2-data

echo "[ii] succeeded" >&2
)

EC2 data service

(
set -e -E -C -u -o pipefail || exit 1
exec sudo webfsd -F -i 169.254.169.254 -p 80 -R /tmp/ec2-data -f .data
)

Setup

Eucalyptus tools