Skip to content

Commit

Permalink
moving away from cloud-init for the moment because it seems slow and …
Browse files Browse the repository at this point in the history
…isn't doing

what I want...
  • Loading branch information
marklee77 committed Oct 29, 2014
1 parent 70d7f72 commit c29324c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM phusion/baseimage:latest
MAINTAINER Mark Stillwell <[email protected]>

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install cloud-init && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
#ENV DEBIAN_FRONTEND noninteractive
#RUN apt-get update && \
# apt-get -y install cloud-init && \
# rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN mkdir -p /etc/my_init.d && \
touch /etc/growroot-disabled && \
echo '#!/bin/sh\n/usr/bin/cloud-init init' > \
/etc/my_init.d/10-cloud-init && \
chmod 755 /etc/my_init.d/10-cloud-init
#RUN mkdir -p /etc/my_init.d && \
# touch /etc/growroot-disabled && \
# echo '#!/bin/sh\n/usr/bin/cloud-init init' > \
# /etc/my_init.d/10-cloud-init && \
# chmod 755 /etc/my_init.d/10-cloud-init

RUN mkdir -p /etc/my_init.d
COPY setkey.sh /etc/my_init.d/10-setkey
RUN chmod 755 /etc/my_init.d/10-setkey
23 changes: 23 additions & 0 deletions setkey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
ATTEMPTS=30

mkdir -p /root/.ssh
chmod 700 /root/.ssh

TMPFILE=$(mktemp)
while [ ! -f /root/.ssh/authorized_keys ] && [ ${ATTEMPTS} -gt 0 ]; do
ATTEMPTS=$((${ATTEMPTS}-1))
curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key \
> ${TMPFILE} 2>/dev/null
if [ \$? -eq 1 ]; then
cat ${TMPFILE} >> /root/.ssh/authorized_keys
chmod 0600 /root/.ssh/authorized_keys
rm -f ${TMPFILE}
echo "Successfully retrieved public key from instance metadata"
echo "********************************************************"
echo "AUTHORIZED KEYS"
echo "********************************************************"
cat /root/.ssh/authorized_keys
echo "********************************************************"
fi
done

0 comments on commit c29324c

Please sign in to comment.