diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/21-cloudinit.conf | 6 | ||||
-rwxr-xr-x | tools/Z99-cloud-locale-test.sh | 98 | ||||
-rwxr-xr-x | tools/build-on-freebsd | 66 | ||||
-rwxr-xr-x | tools/ccfg-merge-debug | 90 | ||||
-rwxr-xr-x | tools/cloud-init-per | 60 | ||||
-rwxr-xr-x | tools/hacking.py | 170 | ||||
-rwxr-xr-x | tools/make-dist-tarball | 21 | ||||
-rwxr-xr-x | tools/make-mime.py | 60 | ||||
-rwxr-xr-x | tools/make-tarball | 39 | ||||
-rwxr-xr-x | tools/mock-meta.py | 454 | ||||
-rwxr-xr-x | tools/motd-hook | 35 | ||||
-rwxr-xr-x | tools/read-dependencies | 29 | ||||
-rwxr-xr-x | tools/read-version | 26 | ||||
-rwxr-xr-x | tools/run-pep8 | 21 | ||||
-rwxr-xr-x | tools/run-pyflakes | 18 | ||||
-rwxr-xr-x | tools/run-pyflakes3 | 2 | ||||
-rwxr-xr-x | tools/tox-venv | 42 | ||||
-rwxr-xr-x | tools/uncloud-init | 141 | ||||
-rwxr-xr-x | tools/validate-yaml.py | 25 | ||||
-rwxr-xr-x | tools/write-ssh-key-fingerprints | 38 |
20 files changed, 0 insertions, 1441 deletions
diff --git a/tools/21-cloudinit.conf b/tools/21-cloudinit.conf deleted file mode 100644 index c65325c1..00000000 --- a/tools/21-cloudinit.conf +++ /dev/null @@ -1,6 +0,0 @@ -# Log cloudinit generated log messages to file -:syslogtag, isequal, "[CLOUDINIT]" /var/log/cloud-init.log - -# comment out the following line to allow CLOUDINIT messages through. -# Doing so means you'll also get CLOUDINIT messages in /var/log/syslog -& ~ diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh deleted file mode 100755 index 8e0469ed..00000000 --- a/tools/Z99-cloud-locale-test.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -# vi: ts=4 noexpandtab -# -# Author: Ben Howard <ben.howard@canonical.com> -# Author: Scott Moser <scott.moser@ubuntu.com> -# (c) 2012, Canonical Group, Ltd. -# -# Purpose: Detect invalid locale settings and inform the user -# of how to fix them. -# - -locale_warn() { - local bad_names="" bad_lcs="" key="" val="" var="" vars="" bad_kv="" - local w1 w2 w3 w4 remain - - # if shell is zsh, act like sh only for this function (-L). - # The behavior change will not permenently affect user's shell. - [ "${ZSH_NAME+zsh}" = "zsh" ] && emulate -L sh - - # locale is expected to output either: - # VARIABLE= - # VARIABLE="value" - # locale: Cannot set LC_SOMETHING to default locale - while read -r w1 w2 w3 w4 remain; do - case "$w1" in - locale:) bad_names="${bad_names} ${w4}";; - *) - key=${w1%%=*} - val=${w1#*=} - val=${val#\"} - val=${val%\"} - vars="${vars} $key=$val";; - esac - done - for bad in $bad_names; do - for var in ${vars}; do - [ "${bad}" = "${var%=*}" ] || continue - val=${var#*=} - [ "${bad_lcs#* ${val}}" = "${bad_lcs}" ] && - bad_lcs="${bad_lcs} ${val}" - bad_kv="${bad_kv} $bad=$val" - break - done - done - bad_lcs=${bad_lcs# } - bad_kv=${bad_kv# } - [ -n "$bad_lcs" ] || return 0 - - printf "_____________________________________________________________________\n" - printf "WARNING! Your environment specifies an invalid locale.\n" - printf " The unknown environment variables are:\n %s\n" "$bad_kv" - printf " This can affect your user experience significantly, including the\n" - printf " ability to manage packages. You may install the locales by running:\n\n" - - local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED" - local pkgs="" - if [ -e "$sfile" ]; then - for bad in ${bad_lcs}; do - grep -q -i "${bad}" "$sfile" && - to_gen="${to_gen} ${bad}" || - invalid="${invalid} ${bad}" - done - else - printf " sudo apt-get install locales\n" - to_gen=$bad_lcs - fi - to_gen=${to_gen# } - - local pkgs="" - for bad in ${to_gen}; do - pkgs="${pkgs} language-pack-${bad%%_*}" - done - pkgs=${pkgs# } - - if [ -n "${pkgs}" ]; then - printf " sudo apt-get install ${pkgs# }\n" - printf " or\n" - printf " sudo locale-gen ${to_gen# }\n" - printf "\n" - fi - for bad in ${invalid}; do - printf "WARNING: '${bad}' is an invalid locale\n" - done - - printf "To see all available language packs, run:\n" - printf " apt-cache search \"^language-pack-[a-z][a-z]$\"\n" - printf "To disable this message for all users, run:\n" - printf " sudo touch /var/lib/cloud/instance/locale-check.skip\n" - printf "_____________________________________________________________________\n\n" - - # only show the message once - : > ~/.cloud-locale-test.skip 2>/dev/null || : -} - -[ -f ~/.cloud-locale-test.skip -o -f /var/lib/cloud/instance/locale-check.skip ] || - locale 2>&1 | locale_warn - -unset locale_warn diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd deleted file mode 100755 index 8436498e..00000000 --- a/tools/build-on-freebsd +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Since there is no official FreeBSD port yet, we need some way of building and -# installing cloud-init. This script takes care of building and installing. It -# will optionally make a first run at the end. - -fail() { echo "FAILED:" "$@" 1>&2; exit 1; } - -# Check dependencies: -depschecked=/tmp/c-i.dependencieschecked -pkgs=" - dmidecode - e2fsprogs - gpart - py27-Jinja2 - py27-argparse - py27-boto - py27-cheetah - py27-configobj - py27-jsonpatch - py27-jsonpointer - py27-oauth - py27-prettytable - py27-requests - py27-serial - py27-six - py27-yaml - python - sudo -" -[ -f "$depschecked" ] || pkg install ${pkgs} || fail "install packages" -touch $depschecked - -# Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer -# Luckily, the install step will take care of this by installing it from pypi... - -# Build the code and install in /usr/local/: -python setup.py build -python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd - -# Install the correct config file: -cp config/cloud.cfg-freebsd /usr/local/etc/cloud/cloud.cfg - -# Enable cloud-init in /etc/rc.conf: -sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf -echo 'cloudinit_enable="YES"' >> /etc/rc.conf - -echo "Installation completed." - -if [ "$1" = "run" ]; then - echo "Ok, now let's see if it works." - - # Backup SSH keys - mv /etc/ssh/ssh_host_* /tmp/ - - # Remove old metadata - rm -rf /var/lib/cloud - - # Just log everything, quick&dirty - rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg - - # Start: - /usr/local/etc/rc.d/cloudinit start - - # Restore SSH keys - mv /tmp/ssh_host_* /etc/ssh/ -fi diff --git a/tools/ccfg-merge-debug b/tools/ccfg-merge-debug deleted file mode 100755 index 1f08e0cb..00000000 --- a/tools/ccfg-merge-debug +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python - -from cloudinit import handlers -from cloudinit.handlers import cloud_config as cc_part -from cloudinit import helpers -from cloudinit import log as logging -from cloudinit.settings import PER_INSTANCE -from cloudinit import user_data as ud - -import argparse -import os -import shutil -import tempfile - - -def main(): - parser = argparse.ArgumentParser( - description='test cloud-config merging') - parser.add_argument("--output", "-o", metavar="file", - help="specify output file", default="-") - parser.add_argument('--verbose', '-v', action='count', default=0) - parser.add_argument('files', nargs='+') - - args = parser.parse_args() - - if args.verbose: - level = (logging.WARN, logging.INFO, - logging.DEBUG)[min(args.verbose, 2)] - logging.setupBasicLogging(level) - - outfile = args.output - if args.output == "-": - outfile = "/dev/stdout" - - tempd = tempfile.mkdtemp() - handler_dir = os.path.join(tempd, "hdir") - data = None # the 'init' object - frequency = PER_INSTANCE - - paths = helpers.Paths({}) - - # make a '#include <f1>' style - udproc = ud.UserDataProcessor(paths=paths) - user_data_msg = udproc.process("#include\n" + - '\n'.join([os.path.abspath(f) for f in args.files])) - - ccph = cc_part.CloudConfigPartHandler(paths=paths) - ccph.cloud_fn = outfile - - c_handlers = helpers.ContentHandlers() - c_handlers.register(ccph) - - called = [] - for (_ctype, mod) in c_handlers.items(): - if mod in called: - continue - handlers.call_begin(mod, data, frequency) - called.append(mod) - - # Walk the user data - part_data = { - 'handlers': c_handlers, - # Any new handlers that are encountered get writen here - 'handlerdir': handler_dir, - 'data': data, - # The default frequency if handlers don't have one - 'frequency': frequency, - # This will be used when new handlers are found - # to help write there contents to files with numbered - # names... - 'handlercount': 0, - 'excluded': [], - } - - handlers.walk(user_data_msg, handlers.walker_callback, data=part_data) - - # Give callbacks opportunity to finalize - called = [] - for (_ctype, mod) in c_handlers.items(): - if mod in called: - continue - handlers.call_end(mod, data, frequency) - called.append(mod) - - shutil.rmtree(tempd) - -if __name__ == "__main__": - main() - -# vi: ts=4 expandtab diff --git a/tools/cloud-init-per b/tools/cloud-init-per deleted file mode 100755 index 5d9a2864..00000000 --- a/tools/cloud-init-per +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -DATA_PRE="/var/lib/cloud/sem/bootper" -INST_PRE="/var/lib/cloud/instance/sem/bootper" - -Usage() { - cat <<EOF -Usage: ${0##*/} frequency name cmd [ arg1 [ arg2 [ ... ] ] - run cmd with arguments provided. - - This utility can make it easier to use boothooks or bootcmd - on a per "once" or "always" basis. - - If frequency is: - * once: run only once (do not re-run for new instance-id) - * instance: run only the first boot for a given instance-id - * always: run every boot - -EOF -} -error() { echo "$@" 1>&2; } -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } - -# support the old 'cloud-init-run-module freq name "execute" cmd arg1' -# if < 3 arguments, it will fail below on usage. -if [ "${0##*/}" = "cloud-init-run-module" ]; then - if [ $# -le 2 -o "$3" = "execute" ]; then - error "Warning: ${0##*/} is deprecated. Please use cloud-init-per." - freq=$1; name=$2; - [ $# -le 2 ] || shift 3; - set -- "$freq" "$name" "$@" - else - fail "legacy cloud-init-run-module only supported with module 'execute'" - fi -fi - -[ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; } -[ $# -ge 3 ] || { Usage 1>&2; exit 1; } -freq=$1 -name=$2 -shift 2; - -[ "${name#*/}" = "${name}" ] || fail "name cannot contain a /" -[ "$(id -u)" = "0" ] || fail "must be root" - -case "$freq" in - once|always) sem="${DATA_PRE}.$name.$freq";; - instance) sem="${INST_PRE}.$name.$freq";; - *) Usage 1>&2; fail "invalid frequency: $freq";; -esac - -[ -d "${sem%/*}" ] || mkdir -p "${sem%/*}" || - fail "failed to make directory for ${sem}" - -[ "$freq" != "always" -a -e "$sem" ] && exit 0 -"$@" -ret=$? -printf "%s\t%s\n" "$ret" "$(date +%s)" > "$sem" || - fail "failed to write to $sem" -exit $ret diff --git a/tools/hacking.py b/tools/hacking.py deleted file mode 100755 index 716c1154..00000000 --- a/tools/hacking.py +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright (c) 2012, Cloudscaling -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -"""cloudinit HACKING file compliance testing (based off of nova hacking.py) - -built on top of pep8.py -""" - -import inspect -import logging -import re -import sys - -import pep8 - -# Don't need this for testing -logging.disable('LOG') - -# N1xx comments -# N2xx except -# N3xx imports -# N4xx docstrings -# N[5-9]XX (future use) - -DOCSTRING_TRIPLE = ['"""', "'''"] -VERBOSE_MISSING_IMPORT = False -_missingImport = set([]) - - -def import_normalize(line): - # convert "from x import y" to "import x.y" - # handle "from x import y as z" to "import x.y as z" - split_line = line.split() - if (line.startswith("from ") and "," not in line and - split_line[2] == "import" and split_line[3] != "*" and - split_line[1] != "__future__" and - (len(split_line) == 4 or (len(split_line) == 6 and - split_line[4] == "as"))): - return "import %s.%s" % (split_line[1], split_line[3]) - else: - return line - - -def cloud_import_alphabetical(physical_line, line_number, lines): - """Check for imports in alphabetical order. - - HACKING guide recommendation for imports: - imports in human alphabetical order - N306 - """ - # handle import x - # use .lower since capitalization shouldn't dictate order - split_line = import_normalize(physical_line.strip()).lower().split() - split_previous = import_normalize(lines[line_number - 2]) - split_previous = split_previous.strip().lower().split() - # with or without "as y" - length = [2, 4] - if (len(split_line) in length and len(split_previous) in length and - split_line[0] == "import" and split_previous[0] == "import"): - if split_line[1] < split_previous[1]: - return (0, "N306: imports not in alphabetical order (%s, %s)" - % (split_previous[1], split_line[1])) - - -def cloud_docstring_start_space(physical_line): - """Check for docstring not start with space. - - HACKING guide recommendation for docstring: - Docstring should not start with space - N401 - """ - pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start - if (pos != -1 and len(physical_line) > pos + 1): - if (physical_line[pos + 3] == ' '): - return (pos, - "N401: one line docstring should not start with a space") - - -def cloud_todo_format(physical_line): - """Check for 'TODO()'. - - HACKING guide recommendation for TODO: - Include your name with TODOs as in "#TODO(termie)" - N101 - """ - pos = physical_line.find('TODO') - pos1 = physical_line.find('TODO(') - pos2 = physical_line.find('#') # make sure it's a comment - if (pos != pos1 and pos2 >= 0 and pos2 < pos): - return pos, "N101: Use TODO(NAME)" - - -def cloud_docstring_one_line(physical_line): - """Check one line docstring end. - - HACKING guide recommendation for one line docstring: - A one line docstring looks like this and ends in a period. - N402 - """ - pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start - end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end - if (pos != -1 and end and len(physical_line) > pos + 4): - if (physical_line[-5] != '.'): - return pos, "N402: one line docstring needs a period" - - -def cloud_docstring_multiline_end(physical_line): - """Check multi line docstring end. - - HACKING guide recommendation for docstring: - Docstring should end on a new line - N403 - """ - pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start - if (pos != -1 and len(physical_line) == pos): - print(physical_line) - if (physical_line[pos + 3] == ' '): - return (pos, "N403: multi line docstring end on new line") - - -current_file = "" - - -def readlines(filename): - """Record the current file being tested.""" - pep8.current_file = filename - return open(filename).readlines() - - -def add_cloud(): - """Monkey patch pep8 for cloud-init guidelines. - - Look for functions that start with cloud_ - and add them to pep8 module. - - Assumes you know how to write pep8.py checks - """ - for name, function in globals().items(): - if not inspect.isfunction(function): - continue - if name.startswith("cloud_"): - exec("pep8.%s = %s" % (name, name)) - -if __name__ == "__main__": - # NOVA based 'hacking.py' error codes start with an N - pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}') - add_cloud() - pep8.current_file = current_file - pep8.readlines = readlines - try: - pep8._main() - finally: - if len(_missingImport) > 0: - print >> sys.stderr, ("%i imports missing in this test environment" - % len(_missingImport)) diff --git a/tools/make-dist-tarball b/tools/make-dist-tarball deleted file mode 100755 index 5b078515..00000000 --- a/tools/make-dist-tarball +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -Usage() { - cat <<EOF -Usage: ${0##*/} version - make a tarball of 'version' - must be in a bzr directory, and 'version' must be a tag - -EOF -} - -topdir="$PWD" -tag="$1" - -[ -n "$tag" ] || { Usage 1>&2 ; exit 1; } - -out="${topdir}/cloud-init-${tag}.tar.gz" - -bzr export --format=tgz --root="cloud-init-$tag" \ - "--revision=tag:${tag}" "$out" "$topdir" && - echo "Wrote ${out}" diff --git a/tools/make-mime.py b/tools/make-mime.py deleted file mode 100755 index 72b29fb9..00000000 --- a/tools/make-mime.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python - -import argparse -import sys - -from email.mime.multipart import MIMEMultipart -from email.mime.text import MIMEText - -KNOWN_CONTENT_TYPES = [ - 'text/x-include-once-url', - 'text/x-include-url', - 'text/cloud-config-archive', - 'text/upstart-job', - 'text/cloud-config', - 'text/part-handler', - 'text/x-shellscript', - 'text/cloud-boothook', -] - - -def file_content_type(text): - try: - filename, content_type = text.split(":", 1) - return (open(filename, 'r'), filename, content_type.strip()) - except: - raise argparse.ArgumentError("Invalid value for %r" % (text)) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-a", "--attach", - dest="files", - type=file_content_type, - action='append', - default=[], - required=True, - metavar="<file>:<content-type>", - help="attach the given file in the specified " - "content type") - args = parser.parse_args() - sub_messages = [] - for i, (fh, filename, format_type) in enumerate(args.files): - contents = fh.read() - sub_message = MIMEText(contents, format_type, sys.getdefaultencoding()) - sub_message.add_header('Content-Disposition', - 'attachment; filename="%s"' % (filename)) - content_type = sub_message.get_content_type().lower() - if content_type not in KNOWN_CONTENT_TYPES: - sys.stderr.write(("WARNING: content type %r for attachment %s " - "may be incorrect!\n") % (content_type, i + 1)) - sub_messages.append(sub_message) - combined_message = MIMEMultipart() - for msg in sub_messages: - combined_message.attach(msg) - print(combined_message) - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools/make-tarball b/tools/make-tarball deleted file mode 100755 index b7039150..00000000 --- a/tools/make-tarball +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -set -e - -find_root() { - local topd - if [ -z "${CLOUD_INIT_TOP_D}" ]; then - topd=$(cd "$(dirname "${0}")" && cd .. && pwd) - else - topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd) - fi - [ $? -eq 0 -a -f "${topd}/setup.py" ] || return - ROOT_DIR="$topd" -} - -if ! find_root; then - echo "Unable to locate 'setup.py' file that should" \ - "exist in the cloud-init root directory." 1>&2 - exit 1; -fi - -REVNO=$(bzr revno "$ROOT_DIR") - -if [ ! -z "$1" ]; then - ARCHIVE_FN="$1" -else - VERSION=$("$ROOT_DIR/tools/read-version") - ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz" -fi - -export_uncommitted="" -if [ "${UNCOMMITTED:-0}" != "0" ]; then - export_uncommitted="--uncommitted" -fi - -bzr export ${export_uncommitted} \ - --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \ - "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR" - -echo "$ARCHIVE_FN" diff --git a/tools/mock-meta.py b/tools/mock-meta.py deleted file mode 100755 index 1c746f17..00000000 --- a/tools/mock-meta.py +++ /dev/null @@ -1,454 +0,0 @@ -#!/usr/bin/python - -# Provides a somewhat random, somewhat compat, somewhat useful mock version of -# http://docs.amazonwebservices.com -# /AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.htm - -""" -To use this to mimic the EC2 metadata service entirely, run it like: - # Where 'eth0' is *some* interface. - sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255 - - sudo ./mock-meta.py -a 169.254.169.254 -p 80 - -Then: - wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo - curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo - ec2metadata --instance-id -""" - -import functools -import httplib -import json -import logging -import os -import random -import string -import sys -import yaml - -from optparse import OptionParser - -from BaseHTTPServer import (HTTPServer, BaseHTTPRequestHandler) - -log = logging.getLogger('meta-server') - -EC2_VERSIONS = [ - '1.0', - '2007-01-19', - '2007-03-01', - '2007-08-29', - '2007-10-10', - '2007-12-15', - '2008-02-01', - '2008-09-01', - '2009-04-04', -] - -BLOCK_DEVS = [ - 'ami', - 'ephemeral0', - 'root', -] - -DEV_PREFIX = 'v' # This seems to vary alot depending on images... -DEV_MAPPINGS = { - 'ephemeral0': '%sda2' % (DEV_PREFIX), - 'root': '/dev/%sda1' % (DEV_PREFIX), - 'ami': '%sda1' % (DEV_PREFIX), - 'swap': '%sda3' % (DEV_PREFIX), -} - -META_CAPABILITIES = [ - 'aki-id', - 'ami-id', - 'ami-launch-index', - 'ami-manifest-path', - 'ari-id', - 'block-device-mapping/', - 'hostname', - 'instance-action', - 'instance-id', - 'instance-type', - 'local-hostname', - 'local-ipv4', - 'placement/', - 'product-codes', - 'public-hostname', - 'public-ipv4', - 'public-keys/', - 'reservation-id', - 'security-groups' -] - -PUB_KEYS = { - 'brickies': [ - ('ssh-rsa ' - 'AAAAB3NzaC1yc2EAAAABIwAAAQEA3I7VUf2l5gSn5uavROsc5HRDpZdQueUq5ozemN' - 'Sj8T7enqKHOEaFoU2VoPgGEWC9RyzSQVeyD6s7APMcE82EtmW4skVEgEGSbDc1pvxz' - 'xtchBj78hJP6Cf5TCMFSXw+Fz5rF1dR23QDbN1mkHs7adr8GW4kSWqU7Q7NDwfIrJJ' - 'tO7Hi42GyXtvEONHbiRPOe8stqUly7MvUoN+5kfjBM8Qqpfl2+FNhTYWpMfYdPUnE7' - 'u536WqzFmsaqJctz3gBxH9Ex7dFtrxR4qiqEr9Qtlu3xGn7Bw07/+i1D+ey3ONkZLN' - '+LQ714cgj8fRS4Hj29SCmXp5Kt5/82cD/VN3NtHw== brickies'), - '', - ], -} - -INSTANCE_TYPES = [ - 'm1.large', - 'm1.medium', - 'm1.small', - 'm1.xlarge', -] - -AVAILABILITY_ZONES = [ - "us-east-1a", - "us-east-1b", - "us-east-1c", - "us-east-1d", - 'eu-west-1a', - 'eu-west-1b', - 'us-west-1', -] - -PLACEMENT_CAPABILITIES = { - 'availability-zone': AVAILABILITY_ZONES, -} - -NOT_IMPL_RESPONSE = json.dumps({}) - - -class WebException(Exception): - def __init__(self, code, msg): - Exception.__init__(self, msg) - self.code = code - - -def yamlify(data): - formatted = yaml.dump(data, - line_break="\n", - indent=4, - explicit_start=True, - explicit_end=True, - default_flow_style=False) - return formatted - - -def format_text(text): - if not len(text): - return "<<" - lines = text.splitlines() - nlines = [] - for line in lines: - nlines.append("<< %s" % line) - return "\n".join(nlines) - - -def traverse(keys, mp): - result = dict(mp) - for k in keys: - try: - result = result.get(k) - except (AttributeError, TypeError): - result = None - break - return result - - -ID_CHARS = [c for c in (string.ascii_uppercase + string.digits)] - - -def id_generator(size=6, lower=False): - txt = ''.join(random.choice(ID_CHARS) for x in range(size)) - if lower: - return txt.lower() - else: - return txt - - -def get_ssh_keys(): - keys = {} - keys.update(PUB_KEYS) - - # Nice helper to add in the 'running' users key (if they have one) - key_pth = os.path.expanduser('~/.ssh/id_rsa.pub') - if not os.path.isfile(key_pth): - key_pth = os.path.expanduser('~/.ssh/id_dsa.pub') - - if os.path.isfile(key_pth): - with open(key_pth, 'rb') as fh: - contents = fh.read() - keys[os.getlogin()] = [contents, ''] - - return keys - - -class MetaDataHandler(object): - - def __init__(self, opts): - self.opts = opts - self.instances = {} - - def get_data(self, params, who, **kwargs): - if not params: - # Show the root level capabilities when - # no params are passed... - caps = sorted(META_CAPABILITIES) - return "\n".join(caps) - action = params[0] - action = action.lower() - if action == 'instance-id': - return 'i-%s' % (id_generator(lower=True)) - elif action == 'ami-launch-index': - return "%s" % random.choice([0, 1, 2, 3]) - elif action == 'aki-id': - return 'aki-%s' % (id_generator(lower=True)) - elif action == 'ami-id': - return 'ami-%s' % (id_generator(lower=True)) - elif action == 'ari-id': - return 'ari-%s' % (id_generator(lower=True)) - elif action == 'block-device-mapping': - nparams = params[1:] - if not nparams: - return "\n".join(BLOCK_DEVS) - else: - subvalue = traverse(nparams, DEV_MAPPINGS) - if not subvalue: - return "\n".join(sorted(list(DEV_MAPPINGS.keys()))) - else: - return str(subvalue) - elif action in ['hostname', 'local-hostname', 'public-hostname']: - # Just echo back there own hostname that they called in on.. - return "%s" % (who) - elif action == 'instance-type': - return random.choice(INSTANCE_TYPES) - elif action == 'ami-manifest-path': - return 'my-amis/spamd-image.manifest.xml' - elif action == 'security-groups': - return 'default' - elif action in ['local-ipv4', 'public-ipv4']: - # Just echo back there own ip that they called in on... - return "%s" % (kwargs.get('client_ip', '10.0.0.1')) - elif action == 'reservation-id': - return "r-%s" % (id_generator(lower=True)) - elif action == 'product-codes': - return "%s" % (id_generator(size=8)) - elif action == 'public-keys': - nparams = params[1:] - # This is a weird kludge, why amazon why!!! - # public-keys is messed up, list of /latest/meta-data/public-keys/ - # shows something like: '0=brickies' - # but a GET to /latest/meta-data/public-keys/0=brickies will fail - # you have to know to get '/latest/meta-data/public-keys/0', then - # from there you get a 'openssh-key', which you can get. - # this hunk of code just re-works the object for that. - avail_keys = get_ssh_keys() - key_ids = sorted(list(avail_keys.keys())) - if nparams: - mybe_key = nparams[0] - try: - key_id = int(mybe_key) - key_name = key_ids[key_id] - except: - raise WebException(httplib.BAD_REQUEST, - "Unknown key id %r" % mybe_key) - # Extract the possible sub-params - result = traverse(nparams[1:], { - "openssh-key": "\n".join(avail_keys[key_name]), - }) - if isinstance(result, (dict)): - # TODO(harlowja): This might not be right?? - result = "\n".join(sorted(result.keys())) - if not result: - result = '' - return result - else: - contents = [] - for (i, key_id) in enumerate(key_ids): - contents.append("%s=%s" % (i, key_id)) - return "\n".join(contents) - elif action == 'placement': - nparams = params[1:] - if not nparams: - pcaps = sorted(PLACEMENT_CAPABILITIES.keys()) - return "\n".join(pcaps) - else: - pentry = nparams[0].strip().lower() - if pentry == 'availability-zone': - zones = PLACEMENT_CAPABILITIES[pentry] - return "%s" % random.choice(zones) - else: - return "%s" % (PLACEMENT_CAPABILITIES.get(pentry, '')) - else: - log.warn(("Did not implement action %s, " - "returning empty response: %r"), - action, NOT_IMPL_RESPONSE) - return NOT_IMPL_RESPONSE - - -class UserDataHandler(object): - - def __init__(self, opts): - self.opts = opts - - def _get_user_blob(self, **kwargs): - blob = None - if self.opts['user_data_file'] is not None: - blob = self.opts['user_data_file'] - if not blob: - blob_mp = { - 'hostname': kwargs.get('who', 'localhost'), - } - lines = [ - "#cloud-config", - yamlify(blob_mp), - ] - blob = "\n".join(lines) - return blob.strip() - - def get_data(self, params, who, **kwargs): - if not params: - return self._get_user_blob(who=who) - return NOT_IMPL_RESPONSE - - -# Seem to need to use globals since can't pass -# data into the request handlers instances... -# Puke! -meta_fetcher = None -user_fetcher = None - - -class Ec2Handler(BaseHTTPRequestHandler): - - def _get_versions(self): - versions = ['latest'] + EC2_VERSIONS - versions = sorted(versions) - return "\n".join(versions) - - def log_message(self, fmt, *args): - msg = "%s - %s" % (self.address_string(), fmt % (args)) - log.info(msg) - - def _find_method(self, path): - # Puke! (globals) - func_mapping = { - 'user-data': user_fetcher.get_data, - 'meta-data': meta_fetcher.get_data, - } - segments = [piece for piece in path.split('/') if len(piece)] - log.info("Received segments %s", segments) - if not segments: - return self._get_versions - date = segments[0].strip().lower() - if date not in self._get_versions(): - raise WebException(httplib.BAD_REQUEST, - "Unknown version format %r" % date) - if len(segments) < 2: - raise WebException(httplib.BAD_REQUEST, "No action provided") - look_name = segments[1].lower() - if look_name not in func_mapping: - raise WebException(httplib.BAD_REQUEST, - "Unknown requested data %r" % look_name) - base_func = func_mapping[look_name] - who = self.address_string() - ip_from = self.client_address[0] - if who == ip_from: - # Nothing resolved, so just use 'localhost' - who = 'localhost' - kwargs = { - 'params': list(segments[2:]), - 'who': who, - 'client_ip': ip_from, - } - return functools.partial(base_func, **kwargs) - - def _do_response(self): - who = self.client_address - log.info("Got a call from %s for path %s", who, self.path) - try: - func = self._find_method(self.path) - data = func() - if not data: - data = '' - self.send_response(httplib.OK) - self.send_header("Content-Type", "binary/octet-stream") - self.send_header("Content-Length", len(data)) - log.info("Sending data (len=%s):\n%s", len(data), - format_text(data)) - self.end_headers() - self.wfile.write(data) - except RuntimeError as e: - log.exception("Error somewhere in the server.") - self.send_error(httplib.INTERNAL_SERVER_ERROR, message=str(e)) - except WebException as e: - code = e.code - log.exception(str(e)) - self.send_error(code, message=str(e)) - - def do_GET(self): - self._do_response() - - def do_POST(self): - self._do_response() - - -def setup_logging(log_level, fmt='%(levelname)s: @%(name)s : %(message)s'): - root_logger = logging.getLogger() - console_logger = logging.StreamHandler(sys.stdout) - console_logger.setFormatter(logging.Formatter(fmt)) - root_logger.addHandler(console_logger) - root_logger.setLevel(log_level) - - -def extract_opts(): - parser = OptionParser() - parser.add_option("-p", "--port", dest="port", action="store", type=int, - default=80, metavar="PORT", - help=("port from which to serve traffic" - " (default: %default)")) - parser.add_option("-a", "--addr", dest="address", action="store", type=str, - default='0.0.0.0', metavar="ADDRESS", - help=("address from which to serve traffic" - " (default: %default)")) - parser.add_option("-f", '--user-data-file', dest='user_data_file', - action='store', metavar='FILE', - help=("user data filename to serve back to" - "incoming requests")) - (options, args) = parser.parse_args() - out = dict() - out['extra'] = args - out['port'] = options.port - out['user_data_file'] = None - out['address'] = options.address - if options.user_data_file: - if not os.path.isfile(options.user_data_file): - parser.error("Option -f specified a non-existent file") - with open(options.user_data_file, 'rb') as fh: - out['user_data_file'] = fh.read() - return out - - -def setup_fetchers(opts): - global meta_fetcher - global user_fetcher - meta_fetcher = MetaDataHandler(opts) - user_fetcher = UserDataHandler(opts) - - -def run_server(): - # Using global here since it doesn't seem like we - # can pass opts into a request handler constructor... - opts = extract_opts() - setup_logging(logging.DEBUG) - setup_fetchers(opts) - log.info("CLI opts: %s", opts) - server_address = (opts['address'], opts['port']) - server = HTTPServer(server_address, Ec2Handler) - sa = server.socket.getsockname() - log.info("Serving ec2 metadata on %s using port %s ...", sa[0], sa[1]) - server.serve_forever() - - -if __name__ == '__main__': - run_server() diff --git a/tools/motd-hook b/tools/motd-hook deleted file mode 100755 index 8c482e8c..00000000 --- a/tools/motd-hook +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# -# 92-ec2-upgrade-available - update-motd script -# -# Copyright (C) 2010 Canonical Ltd. -# -# Authors: Scott Moser <smoser@ubuntu.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# 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/>. - - -# Determining if updates are available is possibly slow. -# a cronjob runs occasioinally and updates a file with information -# on the latest available release (if newer than current) - -BUILD_FILE=/var/lib/cloud/data/available.build - -[ -s "${BUILD_FILE}" ] || exit 0 - -read suite build_name name serial other < "${BUILD_FILE}" - -cat <<EOF -A newer build of the Ubuntu ${suite} ${build_name} image is available. -It is named '${name}' and has build serial '${serial}'. -EOF diff --git a/tools/read-dependencies b/tools/read-dependencies deleted file mode 100755 index 6a6f3e12..00000000 --- a/tools/read-dependencies +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import os -import re -import sys - -if 'CLOUD_INIT_TOP_D' in os.environ: - topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D')) -else: - topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - -for fname in ("setup.py", "requirements.txt"): - if not os.path.isfile(os.path.join(topd, fname)): - sys.stderr.write("Unable to locate '%s' file that should " - "exist in cloud-init root directory." % fname) - sys.exit(1) - -if len(sys.argv) > 1: - reqfile = sys.argv[1] -else: - reqfile = "requirements.txt" - -with open(os.path.join(topd, reqfile), "r") as fp: - for line in fp: - if not line.strip() or line.startswith("#"): - continue - sys.stdout.write(re.split("[>=.<]*", line)[0].strip() + "\n") - -sys.exit(0) diff --git a/tools/read-version b/tools/read-version deleted file mode 100755 index d02651e9..00000000 --- a/tools/read-version +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -import os -import re -import sys - -if 'CLOUD_INIT_TOP_D' in os.environ: - topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D')) -else: - topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - -for fname in ("setup.py", "ChangeLog"): - if not os.path.isfile(os.path.join(topd, fname)): - sys.stderr.write("Unable to locate '%s' file that should " - "exist in cloud-init root directory." % fname) - sys.exit(1) - -vermatch = re.compile(r"^[0-9]+[.][0-9]+[.][0-9]+:$") - -with open(os.path.join(topd, "ChangeLog"), "r") as fp: - for line in fp: - if vermatch.match(line): - sys.stdout.write(line.strip()[:-1] + "\n") - break - -sys.exit(0) diff --git a/tools/run-pep8 b/tools/run-pep8 deleted file mode 100755 index 4bd0bbfb..00000000 --- a/tools/run-pep8 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -pycheck_dirs=( "cloudinit/" "tests/" "tools/" ) - -CR=" -" -[ "$1" = "-v" ] && { verbose="$1"; shift; } || verbose="" - -set -f -if [ $# -eq 0 ]; then unset IFS - IFS="$CR" - files=( "${bin_files[@]}" "${pycheck_dirs[@]}" ) - unset IFS -else - files=( "$@" ) -fi - -myname=${0##*/} -cmd=( "${myname#run-}" $verbose "${files[@]}" ) -echo "Running: " "${cmd[@]}" 1>&2 -exec "${cmd[@]}" diff --git a/tools/run-pyflakes b/tools/run-pyflakes deleted file mode 100755 index b3759a94..00000000 --- a/tools/run-pyflakes +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -PYTHON_VERSION=${PYTHON_VERSION:-2} -CR=" -" -pycheck_dirs=( "cloudinit/" "tests/" "tools/" ) - -set -f -if [ $# -eq 0 ]; then - files=( "${pycheck_dirs[@]}" ) -else - files=( "$@" ) -fi - -cmd=( "python${PYTHON_VERSION}" -m "pyflakes" "${files[@]}" ) - -echo "Running: " "${cmd[@]}" 1>&2 -exec "${cmd[@]}" diff --git a/tools/run-pyflakes3 b/tools/run-pyflakes3 deleted file mode 100755 index e9f0863d..00000000 --- a/tools/run-pyflakes3 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -PYTHON_VERSION=3 exec "${0%/*}/run-pyflakes" "$@" diff --git a/tools/tox-venv b/tools/tox-venv deleted file mode 100755 index 76ed5076..00000000 --- a/tools/tox-venv +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -error() { echo "$@" 1>&2; } -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } -Usage() { - cat <<EOF -Usage: ${0##*/} tox-environment [command [args]] - run command with provided arguments in the provided tox environment - command defaults to \${SHELL:-/bin/sh}. - - invoke with '--list' to show available environments -EOF -} -list_toxes() { - local td="$1" pre="$2" d="" - ( cd "$tox_d" && - for d in *; do [ -f "$d/bin/activate" ] && echo "${pre}$d"; done) -} - -[ $# -eq 0 ] && { Usage 1>&2; exit 1; } -[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; } - -env="$1" -shift -tox_d="${0%/*}/../.tox" -activate="$tox_d/$env/bin/activate" - - -[ -d "$tox_d" ] || fail "$tox_d: not a dir. maybe run 'tox'?" - -[ "$env" = "-l" -o "$env" = "--list" ] && { list_toxes ; exit ; } - -if [ ! -f "$activate" ]; then - error "$env: not a valid tox environment?" - error "try one of:" - list_toxes "$tox_d" " " - fail -fi -. "$activate" - -[ "$#" -gt 0 ] || set -- ${SHELL:-/bin/bash} -debian_chroot="tox:$env" exec "$@" diff --git a/tools/uncloud-init b/tools/uncloud-init deleted file mode 100755 index 2574d482..00000000 --- a/tools/uncloud-init +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# vi: ts=4 noexpandtab - -# This script is meant to "kvmify" an image. Its not meant to be -# terribly robust, or a good idea to ever run in a "real image". -# its' only intended method of invocation is from the kernel as 'init' -# in which case it will then invoke /sbin/init after it is done -# init=/path/to/kvmify-init - -KEY="xupdate" -UMOUNT="" -RMDIR="" -MARK=/var/lib/cloud/sem/uncloud-init.once -ROOT_RW="" - -doexec() { - if [ -n "$ROOT_RW" ]; then - mkdir -p "${MARK%/*}"; - date > "${MARK}"; - fi - cleanup; - log "invoking /sbin/init $*" - exec /sbin/init "$@"; -} -log() { echo "::${0##*/}:" "$@"; } -cleanup() { - [ -z "${UMOUNT}" ] || { umount "${UMOUNT}" && unset UMOUNT; } - [ -z "${RMDIR}" ] || { rm -Rf "${RMDIR}" && unset RMDIR; } - [ -z "${ROOT_RW}" ] || { mount -o remount,ro / ; unset ROOT_RW; } -} - -updateFrom() { - local dev=$1 fmt=$2 - local mp=""; - - [ "${fmt}" = "tar" -o "${fmt}" = "mnt" ] || - { log FAIL "unknown format ${fmt}"; return 1; } - - log INFO "updating from ${dev} format ${fmt}" - [ ! -e "${dev}" -a -e "/dev/${dev}" ] && dev="/dev/${dev}" - [ -e "${dev}" ] || { echo "no file $dev"; return 2; } - - mp=$(mktemp -d "${TEMPDIR:-/tmp}/update.XXXXXX") && - RMDIR="${mp}" || - { log FAIL "failed to mktemp"; return 1; } - - if [ "$fmt" = "tar" ]; then - dd "if=${dev}" | ( tar -C "${mp}" -xf - ) || - { log FAIL "failed to extract ${dev}"; return 1; } - elif [ "$fmt" = "mnt" ]; then - mount -o ro "${dev}" "${mp}" && UMOUNT=${mp} || - { log FAIL "failed mount ${mp}"; return 1; } - else - log FAIL "unknown format ${fmt}"; return 1; - fi - - if [ -d "${mp}/updates" ]; then - rsync -av "${mp}/updates/" "/" || - { log FAIL "failed rsync updates/ /"; return 1; } - fi - if [ -f "${mp}/updates.tar" ]; then - tar -C / -xvf "${mp}/updates.tar" || - { log FAIL "failed tar -C / -xvf ${mp}/updates.tar"; return 1; } - fi - script="${mp}/updates.script" - if [ -f "${script}" -a -x "${script}" ]; then - MP_DIR=${mp} "${mp}/updates.script" || - { log FAIL "failed to run updates.script"; return 1; } - fi -} - -fail() { { [ $# -eq 0 ] && log "FAILING" ; } || log "$@"; exit 1; } - -[ -s "$MARK" ] && { log "already updated" ; doexec "$@"; } - -mount -o remount,rw / || fail "failed to mount rw" -ROOT_RW=1 - -if [ ! -e /proc/cmdline ]; then - mount -t proc /proc /proc - read cmdline < /proc/cmdline - umount /proc -else - read cmdline < /proc/cmdline -fi - -ubuntu_pass="" - -for x in ${cmdline}; do - case "$x" in - ${KEY}=*) - val=${x#${KEY}=} - dev=${val%:*} - [ "${dev}" = "${val}" ] && fmt="" || fmt=${val#${dev}:} - log "update from ${dev},${fmt}" - updateFrom "${dev}" "${fmt}" || fail "update failed" - log "end update ${dev},${fmt}" - ;; - ubuntu-pass=*|ubuntu_pass=*) ubuntu_pass=${x#*=};; - helpmount) helpmount=1;; - root=*) rootspec=${x#root=};; - esac -done - -if [ "${ubuntu_pass}" = "R" -o "${ubuntu_pass}" = "random" ]; then - ubuntu_pass=$(python -c 'import string, random; -random.seed(); print "".join(random.sample(string.letters+string.digits, 8))') - log "settting ubuntu pass = ${ubuntu_pass}" - printf "\n===\nubuntu_pass = %s\n===\n" "${ubuntu_pass}" >/dev/ttyS0 -fi - -[ -z "${ubuntu_pass}" ] || - printf "ubuntu:%s\n" "${ubuntu_pass}" > /root/ubuntu-user-pass - -if [ -e /root/ubuntu-user-pass ]; then - log "changing ubuntu user's password!" - chpasswd < /root/ubuntu-user-pass || - log "FAIL: failed changing pass" -fi - -cp /etc/init/tty2.conf /etc/init/ttyS0.conf && - sed -i s,tty2,ttyS0,g /etc/init/ttyS0.conf 2>/dev/null && - log "enabled console on ttyS0" - -pa=PasswordAuthentication -sed -i "s,${pa} no,${pa} yes," /etc/ssh/sshd_config 2>/dev/null && - log "enabled passwd auth in ssh" || - log "failed to enable passwd ssh" - -grep -q vga16fb /etc/modprobe.d/blacklist.conf || { - echo "blacklist vga16fb" >> /etc/modprobe.d/blacklist.conf && - log "blacklisted vga16fb" -} - -#lstr="${rootspec}" -#if ! grep -q "^${lstr}[[:space:]]" /etc/fstab; then -# log "changing / in /etc/ftab to agree with cmdline (${lstr}) (bug 509841)" -# sed -i "s,^\([^[[:space:]#]\+\)\([[:space:]]\+\)/\([[:space:]]\+\),${lstr}\2/\3," /etc/fstab -#fi - -doexec "$@" diff --git a/tools/validate-yaml.py b/tools/validate-yaml.py deleted file mode 100755 index ed9037d9..00000000 --- a/tools/validate-yaml.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 - -"""Try to read a YAML file and report any errors. -""" - -import sys -import yaml - - -if __name__ == "__main__": - bads = 0 - for fn in sys.argv[1:]: - sys.stdout.write("%s" % (fn)) - try: - fh = open(fn, 'r') - yaml.safe_load(fh.read()) - fh.close() - sys.stdout.write(" - ok\n") - except Exception as e: - sys.stdout.write(" - bad (%s)\n" % (e)) - bads += 1 - if bads > 0: - sys.exit(1) - else: - sys.exit(0) diff --git a/tools/write-ssh-key-fingerprints b/tools/write-ssh-key-fingerprints deleted file mode 100755 index 6c3451fd..00000000 --- a/tools/write-ssh-key-fingerprints +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -logger_opts="-p user.info -t ec2" - -# rhels' version of logger_opts does not support long -# for of -s (--stderr), so use short form. -logger_opts="$logger_opts -s" - -# Redirect stderr to stdout -exec 2>&1 - -fp_blist=",${1}," -key_blist=",${2}," -{ -echo -echo "#############################################################" -echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----" -for f in /etc/ssh/ssh_host_*key.pub; do - [ -f "$f" ] || continue - read ktype line < "$f" - # skip the key if its type is in the blacklist - [ "${fp_blist#*,$ktype,}" = "${fp_blist}" ] || continue - ssh-keygen -l -f "$f" -done -echo "-----END SSH HOST KEY FINGERPRINTS-----" -echo "#############################################################" - -} | logger $logger_opts - -echo "-----BEGIN SSH HOST KEY KEYS-----" -for f in /etc/ssh/ssh_host_*key.pub; do - [ -f "$f" ] || continue - read ktype line < "$f" - # skip the key if its type is in the blacklist - [ "${key_blist#*,$ktype,}" = "${key_blist}" ] || continue - cat $f -done -echo "-----END SSH HOST KEY KEYS-----" |