diff options
-rw-r--r-- | debian/init | 10 | ||||
-rwxr-xr-x | ec2-wait-for-meta-data-service.py | 33 | ||||
-rwxr-xr-x | setup.py | 3 |
3 files changed, 45 insertions, 1 deletions
diff --git a/debian/init b/debian/init index 2fc4b822..608db7a2 100644 --- a/debian/init +++ b/debian/init @@ -70,10 +70,20 @@ regenerate_ssh_host_keys() { case "$1" in start) + log_daemon_msg "Waiting for EC2 meta-data service" + if ec2-wait-for-meta-data-service + then + log_end_msg 0 + else + log_end_msg 1 + exit 1 + fi + if run_once_per_ami ssh_host_key_regeneration then regenerate_ssh_host_keys fi + update-motd if run_once_ever ec2-defaults diff --git a/ec2-wait-for-meta-data-service.py b/ec2-wait-for-meta-data-service.py new file mode 100755 index 00000000..a2759f37 --- /dev/null +++ b/ec2-wait-for-meta-data-service.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# +# Wait for the meta-data service to turn up. If it never does, execute +# the configured bailout +# Copyright (C) 2009 Canonical Ltd. +# +# Author: Soren Hansen <soren@canonical.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +import sys + +import ec2init + +def main(): + ec2 = ec2init.EC2Init() + if ec2.wait_or_bail(): + sys.exit(0) + else: + sys.exit(1) + +if __name__ == '__main__': + main() @@ -34,7 +34,8 @@ setup(name='EC2-init', 'ec2-run-user-data.py', 'ec2-set-apt-sources.py', 'ec2-set-defaults.py', - 'ec2-set-hostname.py'], + 'ec2-set-hostname.py', + 'ec2-wait-for-meta-data-service.py'], data_files=[('/etc/ec2-init', ['debian/ec2-config.cfg']), ('/etc/ec2-init/templates', glob('templates/*'))], ) |