Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created January 6, 2011 17:23
Show Gist options
  • Save seungjin/768212 to your computer and use it in GitHub Desktop.
Save seungjin/768212 to your computer and use it in GitHub Desktop.
atmo rc.local file
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
# load pci hotplug for dynamic disk attach in KVM (for EBS)
depmod -a
modprobe acpiphp
# simple attempt to get the user ssh key using the meta-data service
mkdir -p /root/.ssh
touch /root/.ssh/authorized_keys
cp /dev/null /root/.ssh/authorized_keys
echo >> /root/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /root/.ssh/authorized_keys
echo "AUTHORIZED_KEYS:"
echo "************************"
cat /root/.ssh/authorized_keys
echo "************************"
# AtmoInit
mkdir -p /tmp/atmoInit
wget http://169.254.169.254/latest/user-data -O /tmp/atmoInit/atmoInit.rb
if [ "$?" -eq "0" ]; then
# unzip /tmp/atmo-init/atmo-init.zip -d /tmp/atmo-init/ -o
# if unzip error code is 0, there was no error
#if [ "$?" -eq "0" ]; then
# if the atmo-init.rb script exists, run it
if [ -f /tmp/atmoInit/atmoInit.rb ]; then
/usr/bin/ruby /tmp/atmoInit/atmoInit.rb
else
echo rc.local : No atmo-init.rb script to run
fi
#else
# echo rc.local : atmo-init.zip is corrupted
#fi
else
echo rc.local : error retrieving user data
fi
touch /var/lock/subsys/local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment