diff options
-rw-r--r-- | debian/changelog | 16 | ||||
-rw-r--r-- | debian/init | 25 | ||||
-rwxr-xr-x | debian/rules | 2 | ||||
-rwxr-xr-x | ec2-set-apt-sources.py | 6 | ||||
-rwxr-xr-x | ec2-set-defaults.py | 21 | ||||
-rwxr-xr-x | ec2-set-hostname.py | 6 |
6 files changed, 60 insertions, 16 deletions
diff --git a/debian/changelog b/debian/changelog index a705faaf..ea7c4b79 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,22 @@ +ec2-init (0.3.4ubuntu3) karmic; urgency=low + + * debian/init: Move init script to run before ssh and regenerate the ssh + host kes in the init script rather than /etc/rc.local (LP: #370628) + * ec2-set-apt-sources.py: + - Move sources.list to /var/ec2 so it doesnt get removed after user + reboots. + * ec2-set-defaults.py: + - Move locale to /var/ec2/ so it doesnt get remove after user reboots. + * ec2-set-hostname.py + - Create an /etc/hostname as well. + + -- Chuck Short <zulcss@ubuntu.com> Thu, 14 May 2009 11:11:49 -0400 + ec2-init (0.3.4ubuntu2) karmic; urgency=low * Really change the locale when setting up an instance. (LP: #341066) * Run ec2-run-user-data script last. (LP: #373055) - * Minor comment tweaks. (LP:373057) + * Minor comment tweaks. (LP: #373057) -- Chuck Short <zulcss@ubuntu.com> Wed, 13 May 2009 13:41:35 -0400 diff --git a/debian/init b/debian/init index 15345b6a..3f982be5 100644 --- a/debian/init +++ b/debian/init @@ -17,11 +17,34 @@ NAME=ec2-init . /lib/lsb/init-functions if [ ! -d /var/run/ec2 ]; then - mkdir /var/run/ec2 + mkdir /var/ec2 fi +first_boot() { + # check to see if we are booting for the first time + if [ ! -f /var/ec2/.first-boot ]; then + log_daemon_msg "Running EC2 first boot" + rm -f /etc/ssh/ssh_host_*_key* + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N '' | logger -s -t "ec2" + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N '' | logger -s -t "ec2" + + # This allows user to get host keys securely through console log + echo | logger -s -t "ec2" + echo | logger -s -t "ec2" + echo "#############################################################" | logger -s -t "ec2" + echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----" | logger -s -t "ec2" + ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub | logger -s -t "ec2" + ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub | logger -s -t "ec2" + echo "-----END SSH HOST KEY FINGERPRINTS-----" | logger -s -t "ec2" + echo "#############################################################" | logger -s -t "ec2" + update-motd + touch /var/ec2/.first-boot + fi +} + case "$1" in start) + first_boot log_daemon_msg "Setting EC2 defaults" if ec2-set-defaults 2> /dev/null then diff --git a/debian/rules b/debian/rules index 641694d9..488b93d9 100755 --- a/debian/rules +++ b/debian/rules @@ -2,7 +2,7 @@ include /usr/share/cdbs/1/rules/debhelper.mk -DEB_UPDATE_RCD_PARAMS:= start 90 2 3 4 5 . stop 20 1 . +DEB_UPDATE_RCD_PARAMS:= start 15 2 3 4 5 . stop 20 1 . build/ec2-init:: install -d debian/tmp/usr/sbin diff --git a/ec2-set-apt-sources.py b/ec2-set-apt-sources.py index 8efb5896..6327a78b 100755 --- a/ec2-set-apt-sources.py +++ b/ec2-set-apt-sources.py @@ -50,20 +50,20 @@ def detectZone(): def updateList(filename): mirror = detectZone() - if not os.path.exists("/var/run/ec2/sources.lists"): + if not os.path.exists("/var/ec2/sources.lists"): t = os.popen("lsb_release -c").read() codename = t.split() distro = codename[1] mp = {'mirror' : mirror, 'codename' : distro} t = Template(file="/etc/ec2-init/templates/sources.list.tmpl", searchList=[mp]) - f = open("/var/run/ec2/sources.list", "w") + f = open("/var/ec2/sources.list", "w") f.write('%s' %(t)) f.close() if not os.path.exists("/etc/apt/sources.list-ec2-init"): os.system("mv /etc/apt/sources.list /etc/apt/sources.list-ec2-init") - os.symlink("/var/run/ec2/sources.list", "/etc/apt/sources.list") + os.symlink("/var/ec2/sources.list", "/etc/apt/sources.list") cache = apt.Cache(apt.progress.OpProgress()) prog = apt.progress.FetchProgress() cache.update(prog) diff --git a/ec2-set-defaults.py b/ec2-set-defaults.py index 75a2f5c8..c99e3f9e 100755 --- a/ec2-set-defaults.py +++ b/ec2-set-defaults.py @@ -21,6 +21,7 @@ import urllib import os +from Cheetah.Template import Template api_ver = '2008-02-01' metadata = None @@ -34,26 +35,26 @@ elif zone.startswith("eu"): archive = "http://eu.ec2.archive.ubuntu.com/ubuntu" def set_language(location,filename): - if location.startswith("us"): - lang='en_US.UTF-8' - elif location.startswith("eu"): - lang='en_GB.UTF-8' + if location.startswith("us"): + lang='en_US.UTF-8' + elif location.startswith("eu"): + lang='en_GB.UTF-8' - os.system('locale-gen %s' %(lang) - os.system('update-locale %s' %(lang) + os.system('locale-gen %s' %(lang)) + os.system('update-locale %s' %(lang)) mp = {'lang' : lang } T = Template(file="/etc/ec2-init/templates/locale.tmpl", searchList=[mp]) - f = open("/var/run/ec2/locale", "w") - f.write('%s' $(t)) + f = open("/var/ec2/locale", "w") + f.write('%s' %(T)) f.close() if not os.path.exists("/etc/default/locale-ec2-init"): os.system("mv /etc/default/locale /etc/default/locale-ec2-init") os.symlink("/var/run/ec2/locale", "/etc/default/locale") - os.system("source /etc/default/locale") + os.system(". /etc/default/locale") - os.system('touch %s' %(filename)) + os.system('touch %s' %(filename)) def get_amid(): url = 'http://169.254.169.254/%s/meta-data' % api_ver diff --git a/ec2-set-hostname.py b/ec2-set-hostname.py index 818d0e02..c4e56fc9 100755 --- a/ec2-set-hostname.py +++ b/ec2-set-hostname.py @@ -49,6 +49,12 @@ def set_hostname(filename): f = open("/etc/hosts", "w") f.write('%s' %(t)) f.close() + + os.system("rm /etc/hostname") + f = open("/etc/hostname", "w") + f.write('%s' %(t)) + f.close() + os.system('touch %s' %(filename)) id = get_ami_id() |