From 86d7dfa8dae0b53866462ce8e737309a40436402 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 25 Jun 2012 23:56:15 -0700 Subject: 1. Change these to be templates where possible. 2. Rename to be a debian subdir, matching the redhat subdir. --- packages/debian/rules | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 packages/debian/rules (limited to 'packages/debian/rules') diff --git a/packages/debian/rules b/packages/debian/rules new file mode 100755 index 00000000..a907b594 --- /dev/null +++ b/packages/debian/rules @@ -0,0 +1,27 @@ +#!/usr/bin/make -f + +DEB_PYTHON2_MODULE_PACKAGES = cloud-init + +binary-install/cloud-init::cloud-init-fixups + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/python-distutils.mk + +DEB_DH_INSTALL_SOURCEDIR := debian/tmp + +cloud-init-fixups: + install -d $(DEB_DESTDIR)/etc/rsyslog.d + cp tools/21-cloudinit.conf $(DEB_DESTDIR)/etc/rsyslog.d/21-cloudinit.conf + +# You only need to run this immediately after checking out the package from +# revision control. +# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572204 +quilt-setup: + @[ ! -d .pc ] || { echo ".pc exists. remove it and re-run to start fresh"; exit 1; } + set -e; for patch in $$(quilt series | tac); do \ + patch -p1 -R --no-backup-if-mismatch <"debian/patches/$$patch"; \ + done + quilt push -a + +.PHONY: quilt-setup + -- cgit v1.2.3 From 1c2c043b970a62f82b5e19e368b348d48ebbb638 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 28 Jun 2012 16:48:18 -0400 Subject: packages/debian/rules: remove unused quilt section --- packages/debian/rules | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'packages/debian/rules') diff --git a/packages/debian/rules b/packages/debian/rules index a907b594..1739f4cf 100755 --- a/packages/debian/rules +++ b/packages/debian/rules @@ -12,16 +12,3 @@ DEB_DH_INSTALL_SOURCEDIR := debian/tmp cloud-init-fixups: install -d $(DEB_DESTDIR)/etc/rsyslog.d cp tools/21-cloudinit.conf $(DEB_DESTDIR)/etc/rsyslog.d/21-cloudinit.conf - -# You only need to run this immediately after checking out the package from -# revision control. -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572204 -quilt-setup: - @[ ! -d .pc ] || { echo ".pc exists. remove it and re-run to start fresh"; exit 1; } - set -e; for patch in $$(quilt series | tac); do \ - patch -p1 -R --no-backup-if-mismatch <"debian/patches/$$patch"; \ - done - quilt push -a - -.PHONY: quilt-setup - -- cgit v1.2.3 From 51a8e6ee88e9ee83450215208e2aaad4ad2a2843 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 4 Jul 2012 13:52:34 -0700 Subject: 1. Make the debian rules file a template (and pass in the daemon-type) 2. Adjust the bddeb to pass this in (as well as other output statement being added) 3. Adjust make-tarball to only archive the bzr versioned files (using --recursive) --- packages/bddeb | 37 ++++++++++++++++++------ packages/debian/rules | 3 ++ packages/make-tarball | 78 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 81 insertions(+), 37 deletions(-) (limited to 'packages/debian/rules') diff --git a/packages/bddeb b/packages/bddeb index eeb64434..b5a70dd8 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -29,7 +29,7 @@ PKG_MP = { } -def write_debian_folder(root, version, revno): +def write_debian_folder(root, version, revno, daemon_type): deb_dir = util.abs_join(root, 'debian') os.makedirs(deb_dir) @@ -65,8 +65,12 @@ def write_debian_folder(root, version, revno): util.abs_join(deb_dir, 'control'), params={'requires': requires}) + templater.render_to_file(util.abs_join('debian', 'rules'), + util.abs_join(deb_dir, 'rules'), + params={'daemon_type': daemon_type}) + # Just copy the following directly - for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']: + for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']: shutil.copy(util.abs_join('debian', base_fn), util.abs_join(deb_dir, base_fn)) @@ -84,6 +88,10 @@ def main(): " (default: %(default)s)"), default=False, action='store_true') + parser.add_argument("-b", "--boot", dest="boot", + help="select boot type (default: %(default)s)", + metavar="TYPE", default='upstart', + choices=('upstart', 'upstart-local')) args = parser.parse_args() capture = True @@ -101,25 +109,33 @@ def main(): (sysout, _stderr) = util.subp(cmd) revno = sysout.strip() + # This is really only a temporary archive + # since we will extract it then add in the debian + # folder, then re-archive it for debian happiness + print("Creating a temporary tarball using the 'make-tarball' helper") cmd = [sys.executable, util.abs_join(os.getcwd(), 'make-tarball')] (sysout, _stderr) = util.subp(cmd) arch_fn = sysout.strip() - tmp_arch_fn = util.abs_join(tdir, os.path.basename(arch_fn)) shutil.move(arch_fn, tmp_arch_fn) + print("Extracting temporary tarball %r" % (tmp_arch_fn)) cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', tdir] - util.subp(cmd) - + util.subp(cmd, capture=capture) base_name = os.path.basename(arch_fn)[:-len(".tar.gz")] shutil.move(util.abs_join(tdir, base_name), util.abs_join(tdir, 'cloud-init')) + print("Creating a debian/ folder in %r" % + (util.abs_join(tdir, 'cloud-init'))) write_debian_folder(util.abs_join(tdir, 'cloud-init'), - version, revno) + version, revno, args.boot) + # The naming here seems to follow some debian standard + # so it will whine if it is changed... tar_fn = "cloud-init_%s~%s.orig.tar.gz" % (version, revno) + print("Archiving that new folder into %r" % (tar_fn)) cmd = ['tar', '-czvf', util.abs_join(tdir, tar_fn), '-C', util.abs_join(tdir, 'cloud-init')] @@ -127,7 +143,8 @@ def main(): util.subp(cmd, capture=capture) shutil.copy(util.abs_join(tdir, tar_fn), tar_fn) print("Wrote out archive %r" % (util.abs_join(tar_fn))) - + + print("Running 'debuild' in %r" % (util.abs_join(tdir, 'cloud-init'))) with util.chdir(util.abs_join(tdir, 'cloud-init')): cmd = ['debuild'] if not args.sign: @@ -137,14 +154,16 @@ def main(): globs = [] globs.extend(glob.glob("%s/*.deb" % (os.path.join(tdir)))) + link_fn = os.path.join(os.getcwd(), 'cloud-init_all.deb') for fn in globs: base_fn = os.path.basename(fn) shutil.move(fn, base_fn) print("Wrote out debian package %r" % (base_fn)) if fn.endswith('_all.deb'): # Add in the local link - util.del_file('cloud-init_all.deb') - os.symlink(base_fn, 'cloud-init_all.deb') + util.del_file(link_fn) + os.symlink(base_fn, link_fn) + print("Linked %r to %r" % (base_fn, link_fn)) return 0 diff --git a/packages/debian/rules b/packages/debian/rules index 1739f4cf..6814974f 100755 --- a/packages/debian/rules +++ b/packages/debian/rules @@ -7,8 +7,11 @@ binary-install/cloud-init::cloud-init-fixups include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk +DEB_PYTHON_INSTALL_ARGS_ALL += --daemon-type={{daemon_type}} + DEB_DH_INSTALL_SOURCEDIR := debian/tmp cloud-init-fixups: install -d $(DEB_DESTDIR)/etc/rsyslog.d cp tools/21-cloudinit.conf $(DEB_DESTDIR)/etc/rsyslog.d/21-cloudinit.conf + diff --git a/packages/make-tarball b/packages/make-tarball index 479e11af..43a6fc33 100755 --- a/packages/make-tarball +++ b/packages/make-tarball @@ -7,6 +7,8 @@ import subprocess import sys import tempfile +import optparse + # Use the util functions from cloudinit possible_topdir = os.path.normpath(os.path.join(os.path.abspath( @@ -17,51 +19,71 @@ if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")): from cloudinit import util -def main(args): +def find_versioned_files(): + (stdout, _stderr) = util.subp(['bzr', 'ls', '--versioned', '--recursive']) + fns = [fn for fn in stdout.splitlines() + if fn and not fn.startswith('.')] + fns.sort() + return fns - base_fn = None - if args: - base_fn = args[0] - with util.tempdir() as tdir: +def copy(fn, where_to, verbose): + if verbose: + print("Copying %r --> %r" % (fn, where_to)) + if os.path.isfile(fn): + shutil.copy(fn, where_to) + elif os.path.isdir(fn) and not os.path.isdir(where_to): + os.makedirs(where_to) + else: + raise RuntimeError("Do not know how to copy %s" % (fn)) + + +def main(): - if not base_fn: - (stdout, _stderr) = util.subp(['bzr', 'revno']) - revno = stdout.strip() - - cmd = [sys.executable, - util.abs_join(os.pardir, 'tools', 'read-version')] - (stdout, _stderr) = util.subp(cmd) - version = stdout.strip() - base_fn = 'cloud-init-%s-%s' % (version, revno) + parser = optparse.OptionParser() + parser.add_option("-f", "--file", dest="filename", + help="write archive to FILE", metavar="FILE") + parser.add_option("-v", "--verbose", + action="store_true", dest="verbose", default=False, + help="show verbose messaging") + (options, args) = parser.parse_args() + + base_fn = options.filename + if not base_fn: + (stdout, _stderr) = util.subp(['bzr', 'revno']) + revno = stdout.strip() + cmd = [sys.executable, + util.abs_join(os.pardir, 'tools', 'read-version')] + (stdout, _stderr) = util.subp(cmd) + version = stdout.strip() + base_fn = 'cloud-init-%s-%s' % (version, revno) + + with util.tempdir() as tdir: util.ensure_dir(util.abs_join(tdir, base_fn)) arch_fn = '%s.tar.gz' % (base_fn) with util.chdir(os.pardir): - (stdout, _stderr) = util.subp(['bzr', 'ls', '--versioned']) - fns = [fn for fn in stdout.splitlines() - if fn and not fn.startswith('.')] - # TODO - only copy the right files - # ie do a recursive versioned... + fns = find_versioned_files() for fn in fns: - if os.path.isfile(fn): - shutil.copy(fn, util.abs_join(tdir, base_fn, fn)) - else: - shutil.copytree(fn, util.abs_join(tdir, base_fn, fn)) + copy(fn, util.abs_join(tdir, base_fn, fn), + verbose=options.verbose) - cmd = ['tar', '-czf', - util.abs_join(tdir, arch_fn), - '-C', tdir, base_fn] - util.subp(cmd) + arch_full_fn = util.abs_join(tdir, arch_fn) + cmd = ['tar', '-czvf', arch_full_fn, '-C', tdir, base_fn] + if options.verbose: + print("Creating an archive from directory %r to %r" % + (util.abs_join(tdir, base_fn), arch_full_fn)) + util.subp(cmd, capture=(not options.verbose)) shutil.move(util.abs_join(tdir, arch_fn), util.abs_join(os.getcwd(), arch_fn)) + print(os.path.abspath(arch_fn)) return 0 if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) + sys.exit(main()) -- cgit v1.2.3 From 95711130af22f1d597aa0ab6b5a39d0af16f8a28 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 6 Jul 2012 17:03:11 -0400 Subject: setup.py: rename "daemon type" to "init system" This brings with it other changes, and also makes an install install all of the requisite init files. (ie, cloud-init needs the -local and the non-local) --- initd/cloud-config | 124 ---------------------------------------- initd/cloud-final | 124 ---------------------------------------- initd/cloud-init | 124 ---------------------------------------- initd/cloud-init-local | 124 ---------------------------------------- packages/bddeb | 4 +- packages/brpm | 2 +- packages/debian/rules | 2 +- packages/redhat/cloud-init.spec | 2 +- setup.py | 52 ++++++----------- sysvinit/cloud-config | 124 ++++++++++++++++++++++++++++++++++++++++ sysvinit/cloud-final | 124 ++++++++++++++++++++++++++++++++++++++++ sysvinit/cloud-init | 124 ++++++++++++++++++++++++++++++++++++++++ sysvinit/cloud-init-local | 124 ++++++++++++++++++++++++++++++++++++++++ 13 files changed, 520 insertions(+), 534 deletions(-) delete mode 100755 initd/cloud-config delete mode 100755 initd/cloud-final delete mode 100755 initd/cloud-init delete mode 100755 initd/cloud-init-local create mode 100755 sysvinit/cloud-config create mode 100755 sysvinit/cloud-final create mode 100755 sysvinit/cloud-init create mode 100755 sysvinit/cloud-init-local (limited to 'packages/debian/rules') diff --git a/initd/cloud-config b/initd/cloud-config deleted file mode 100755 index dd0bca8b..00000000 --- a/initd/cloud-config +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Joshua Harlow -# -# 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 . -# - -# See: http://wiki.debian.org/LSBInitScripts -# See: http://tiny.cc/czvbgw -# See: http://www.novell.com/coolsolutions/feature/15380.html -# Also based on dhcpd in RHEL (for comparison) - -### BEGIN INIT INFO -# Provides: cloud-config -# Required-Start: cloud-init -# Should-Start: $time -# Required-Stop: -# Should-Stop: -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: The config cloud-init job -# Description: Start cloud-init and runs the config phase -# and any associated config modules as desired. -### END INIT INFO - -. /etc/init.d/functions - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -RETVAL=0 - -prog="cloud-init" -cloud_init="/usr/bin/cloud-init" -conf="/etc/cloud/cloud.cfg" - -# If there exists a sysconfig variable override file use it... -[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init - -start() { - [ -x $cloud_init ] || return 5 - [ -f $conf ] || return 6 - - echo -n $"Starting $prog: " - $cloud_init $CLOUDINITARGS modules --mode config - RETVAL=$? - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog: " - # No-op - RETVAL=7 - return $RETVAL -} - -. /etc/init.d/functions - -case "$1" in - start) - start - RETVAL=$? - ;; - stop) - stop - RETVAL=$? - ;; - restart|try-restart|condrestart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - # - ## Note: try-restart is now part of LSB (as of 1.9). - ## RH has a similar command named condrestart. - start - RETVAL=$? - ;; - reload|force-reload) - # It does not support reload - RETVAL=3 - ;; - status) - echo -n $"Checking for service $prog:" - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - RETVAL=3 - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" - RETVAL=3 - ;; -esac - -exit $RETVAL diff --git a/initd/cloud-final b/initd/cloud-final deleted file mode 100755 index 2e462c17..00000000 --- a/initd/cloud-final +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Joshua Harlow -# -# 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 . -# - -# See: http://wiki.debian.org/LSBInitScripts -# See: http://tiny.cc/czvbgw -# See: http://www.novell.com/coolsolutions/feature/15380.html -# Also based on dhcpd in RHEL (for comparison) - -### BEGIN INIT INFO -# Provides: cloud-final -# Required-Start: $all cloud-init cloud-config -# Should-Start: $time -# Required-Stop: -# Should-Stop: -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: The final cloud-init job -# Description: Start cloud-init and runs the final phase -# and any associated final modules as desired. -### END INIT INFO - -. /etc/init.d/functions - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -RETVAL=0 - -prog="cloud-init" -cloud_init="/usr/bin/cloud-init" -conf="/etc/cloud/cloud.cfg" - -# If there exists a sysconfig variable override file use it... -[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init - -start() { - [ -x $cloud_init ] || return 5 - [ -f $conf ] || return 6 - - echo -n $"Starting $prog: " - $cloud_init $CLOUDINITARGS modules --mode final - RETVAL=$? - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog: " - # No-op - RETVAL=7 - return $RETVAL -} - -. /etc/init.d/functions - -case "$1" in - start) - start - RETVAL=$? - ;; - stop) - stop - RETVAL=$? - ;; - restart|try-restart|condrestart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - # - ## Note: try-restart is now part of LSB (as of 1.9). - ## RH has a similar command named condrestart. - start - RETVAL=$? - ;; - reload|force-reload) - # It does not support reload - RETVAL=3 - ;; - status) - echo -n $"Checking for service $prog:" - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - RETVAL=3 - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" - RETVAL=3 - ;; -esac - -exit $RETVAL diff --git a/initd/cloud-init b/initd/cloud-init deleted file mode 100755 index 7726c452..00000000 --- a/initd/cloud-init +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Joshua Harlow -# -# 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 . -# - -# See: http://wiki.debian.org/LSBInitScripts -# See: http://tiny.cc/czvbgw -# See: http://www.novell.com/coolsolutions/feature/15380.html -# Also based on dhcpd in RHEL (for comparison) - -### BEGIN INIT INFO -# Provides: cloud-init -# Required-Start: $local_fs $network $named $remote_fs -# Should-Start: $time -# Required-Stop: -# Should-Stop: -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: The initial cloud-init job (net and fs contingent) -# Description: Start cloud-init and runs the initialization phase -# and any associated initial modules as desired. -### END INIT INFO - -. /etc/init.d/functions - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -RETVAL=0 - -prog="cloud-init" -cloud_init="/usr/bin/cloud-init" -conf="/etc/cloud/cloud.cfg" - -# If there exists a sysconfig variable override file use it... -[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init - -start() { - [ -x $cloud_init ] || return 5 - [ -f $conf ] || return 6 - - echo -n $"Starting $prog: " - $cloud_init $CLOUDINITARGS init - RETVAL=$? - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog: " - # No-op - RETVAL=7 - return $RETVAL -} - -. /etc/init.d/functions - -case "$1" in - start) - start - RETVAL=$? - ;; - stop) - stop - RETVAL=$? - ;; - restart|try-restart|condrestart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - # - ## Note: try-restart is now part of LSB (as of 1.9). - ## RH has a similar command named condrestart. - start - RETVAL=$? - ;; - reload|force-reload) - # It does not support reload - RETVAL=3 - ;; - status) - echo -n $"Checking for service $prog:" - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - RETVAL=3 - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" - RETVAL=3 - ;; -esac - -exit $RETVAL diff --git a/initd/cloud-init-local b/initd/cloud-init-local deleted file mode 100755 index bf5d409a..00000000 --- a/initd/cloud-init-local +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Joshua Harlow -# -# 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 . -# - -# See: http://wiki.debian.org/LSBInitScripts -# See: http://tiny.cc/czvbgw -# See: http://www.novell.com/coolsolutions/feature/15380.html -# Also based on dhcpd in RHEL (for comparison) - -### BEGIN INIT INFO -# Provides: cloud-init -# Required-Start: $local_fs $remote_fs -# Should-Start: $time -# Required-Stop: -# Should-Stop: -# Default-Start: 3 5 -# Default-Stop: -# Short-Description: The initial cloud-init job (local fs contingent) -# Description: Start cloud-init and runs the initialization phases -# and any associated initial modules as desired. -### END INIT INFO - -. /etc/init.d/functions - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -RETVAL=0 - -prog="cloud-init" -cloud_init="/usr/bin/cloud-init" -conf="/etc/cloud/cloud.cfg" - -# If there exists a sysconfig variable override file use it... -[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init - -start() { - [ -x $cloud_init ] || return 5 - [ -f $conf ] || return 6 - - echo -n $"Starting $prog: " - $cloud_init $CLOUDINITARGS init --local - RETVAL=$? - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog: " - # No-op - RETVAL=7 - return $RETVAL -} - -. /etc/init.d/functions - -case "$1" in - start) - start - RETVAL=$? - ;; - stop) - stop - RETVAL=$? - ;; - restart|try-restart|condrestart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - # - ## Note: try-restart is now part of LSB (as of 1.9). - ## RH has a similar command named condrestart. - start - RETVAL=$? - ;; - reload|force-reload) - # It does not support reload - RETVAL=3 - ;; - status) - echo -n $"Checking for service $prog:" - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - RETVAL=3 - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" - RETVAL=3 - ;; -esac - -exit $RETVAL diff --git a/packages/bddeb b/packages/bddeb index b5a70dd8..10ad08b3 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -29,7 +29,7 @@ PKG_MP = { } -def write_debian_folder(root, version, revno, daemon_type): +def write_debian_folder(root, version, revno, init_sys): deb_dir = util.abs_join(root, 'debian') os.makedirs(deb_dir) @@ -67,7 +67,7 @@ def write_debian_folder(root, version, revno, daemon_type): templater.render_to_file(util.abs_join('debian', 'rules'), util.abs_join(deb_dir, 'rules'), - params={'daemon_type': daemon_type}) + params={'init_sys': init_sys}) # Just copy the following directly for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']: diff --git a/packages/brpm b/packages/brpm index 1212b0e4..1d05bd2a 100755 --- a/packages/brpm +++ b/packages/brpm @@ -150,7 +150,7 @@ def generate_spec_contents(args, tmpl_fn): else: subs['systemd'] = False - subs['daemon_type'] = args.boot + subs['init_sys'] = args.boot return templater.render_from_file(tmpl_fn, params=subs) diff --git a/packages/debian/rules b/packages/debian/rules index 6814974f..87cd6538 100755 --- a/packages/debian/rules +++ b/packages/debian/rules @@ -7,7 +7,7 @@ binary-install/cloud-init::cloud-init-fixups include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk -DEB_PYTHON_INSTALL_ARGS_ALL += --daemon-type={{daemon_type}} +DEB_PYTHON_INSTALL_ARGS_ALL += --init-system={{init_sys}} DEB_DH_INSTALL_SOURCEDIR := debian/tmp diff --git a/packages/redhat/cloud-init.spec b/packages/redhat/cloud-init.spec index df13bcb7..d0f83a4b 100644 --- a/packages/redhat/cloud-init.spec +++ b/packages/redhat/cloud-init.spec @@ -63,7 +63,7 @@ ssh keys and to let the user run various scripts. rm -rf $RPM_BUILD_ROOT %{__python} setup.py install -O1 \ --skip-build --root $RPM_BUILD_ROOT \ - --daemon-type={{daemon_type}} + --init-system={{init_sys}} # Note that /etc/rsyslog.d didn't exist by default until F15. # el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420 diff --git a/setup.py b/setup.py index 50e95e9d..458d1a9e 100755 --- a/setup.py +++ b/setup.py @@ -38,31 +38,17 @@ def is_f(p): return os.path.isfile(p) -DAEMON_FILES = { - 'initd': filter((lambda x: is_f(x) - and x.find('local') == -1), glob('initd/*')), - 'initd-local': filter((lambda x: is_f(x) - and not x.endswith('cloud-init')), glob('initd/*')), +INITSYS_FILES = { + 'sysvinit': filter((lambda x: is_f(x)), glob('sysvinit/*')), 'systemd': filter((lambda x: is_f(x)), glob('systemd/*')), - 'upstart': filter((lambda x: is_f(x) - and x.find('local') == -1 - and x.find('nonet') == -1), glob('upstart/*')), - 'upstart-nonet': filter((lambda x: is_f(x) - and x.find('local') == -1 - and not x.endswith('cloud-init.conf')), glob('upstart/*')), - 'upstart-local': filter((lambda x: is_f(x) - and x.find('nonet') == -1 - and not x.endswith('cloud-init.conf')), glob('upstart/*')), + 'upstart': filter((lambda x: is_f(x)), glob('upstart/*')), } -DAEMON_ROOTS = { - 'initd': '/etc/rc.d/init.d', - 'initd-local': '/etc/rc.d/init.d', +INITSYS_ROOTS = { + 'sysvinit': '/etc/rc.d/init.d', 'systemd': '/etc/systemd/system/', 'upstart': '/etc/init/', - 'upstart-nonet': '/etc/init/', - 'upstart-local': '/etc/init/', } -DAEMON_TYPES = sorted(list(DAEMON_ROOTS.keys())) +INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) def tiny_p(cmd, capture=True): @@ -94,29 +80,29 @@ def read_requires(): # TODO: Is there a better way to do this?? -class DaemonInstallData(install): +class InitsysInstallData(install): user_options = install.user_options + [ - # This will magically show up in member variable 'daemon_type' - ('daemon-type=', None, - ('daemon type to configure (%s) [default: None]') % - (", ".join(DAEMON_TYPES)) + # This will magically show up in member variable 'init_sys' + ('init-system=', None, + ('init system to configure (%s) [default: None]') % + (", ".join(INITSYS_TYPES)) ), ] def initialize_options(self): install.initialize_options(self) - self.daemon_type = None + self.initsys = None def finalize_options(self): install.finalize_options(self) - if self.daemon_type and self.daemon_type not in DAEMON_TYPES: + if self.initsys and self.initsys not in INITSYS_TYPES: raise DistutilsArgError( ("You must specify one of (%s) when" - " specifying a daemon type!") % (", ".join(DAEMON_TYPES)) + " specifying a init system!") % (", ".join(INITSYS_TYPES)) ) - elif self.daemon_type: - self.distribution.data_files.append((DAEMON_ROOTS[self.daemon_type], - DAEMON_FILES[self.daemon_type])) + elif self.initsys: + self.distribution.data_files.append((INITSYS_ROOTS[self.initsys], + INITSYS_FILES[self.initsys])) # Force that command to reinitalize (with new file list) self.distribution.reinitialize_command('install_data', True) @@ -145,7 +131,7 @@ setuptools.setup(name='cloud-init', install_requires=read_requires(), cmdclass = { # Use a subclass for install that handles - # adding on the right daemon configuration files - 'install': DaemonInstallData, + # adding on the right init system configuration files + 'install': InitsysInstallData, }, ) diff --git a/sysvinit/cloud-config b/sysvinit/cloud-config new file mode 100755 index 00000000..dd0bca8b --- /dev/null +++ b/sysvinit/cloud-config @@ -0,0 +1,124 @@ +#!/bin/sh + +# +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Joshua Harlow +# +# 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 . +# + +# See: http://wiki.debian.org/LSBInitScripts +# See: http://tiny.cc/czvbgw +# See: http://www.novell.com/coolsolutions/feature/15380.html +# Also based on dhcpd in RHEL (for comparison) + +### BEGIN INIT INFO +# Provides: cloud-config +# Required-Start: cloud-init +# Should-Start: $time +# Required-Stop: +# Should-Stop: +# Default-Start: 3 5 +# Default-Stop: +# Short-Description: The config cloud-init job +# Description: Start cloud-init and runs the config phase +# and any associated config modules as desired. +### END INIT INFO + +. /etc/init.d/functions + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +RETVAL=0 + +prog="cloud-init" +cloud_init="/usr/bin/cloud-init" +conf="/etc/cloud/cloud.cfg" + +# If there exists a sysconfig variable override file use it... +[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init + +start() { + [ -x $cloud_init ] || return 5 + [ -f $conf ] || return 6 + + echo -n $"Starting $prog: " + $cloud_init $CLOUDINITARGS modules --mode config + RETVAL=$? + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + # No-op + RETVAL=7 + return $RETVAL +} + +. /etc/init.d/functions + +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|try-restart|condrestart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + # + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + start + RETVAL=$? + ;; + reload|force-reload) + # It does not support reload + RETVAL=3 + ;; + status) + echo -n $"Checking for service $prog:" + # Return value is slightly different for the status command: + # 0 - service up and running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running (unused) + # 4 - service status unknown :-( + # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) + RETVAL=3 + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" + RETVAL=3 + ;; +esac + +exit $RETVAL diff --git a/sysvinit/cloud-final b/sysvinit/cloud-final new file mode 100755 index 00000000..2e462c17 --- /dev/null +++ b/sysvinit/cloud-final @@ -0,0 +1,124 @@ +#!/bin/sh + +# +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Joshua Harlow +# +# 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 . +# + +# See: http://wiki.debian.org/LSBInitScripts +# See: http://tiny.cc/czvbgw +# See: http://www.novell.com/coolsolutions/feature/15380.html +# Also based on dhcpd in RHEL (for comparison) + +### BEGIN INIT INFO +# Provides: cloud-final +# Required-Start: $all cloud-init cloud-config +# Should-Start: $time +# Required-Stop: +# Should-Stop: +# Default-Start: 3 5 +# Default-Stop: +# Short-Description: The final cloud-init job +# Description: Start cloud-init and runs the final phase +# and any associated final modules as desired. +### END INIT INFO + +. /etc/init.d/functions + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +RETVAL=0 + +prog="cloud-init" +cloud_init="/usr/bin/cloud-init" +conf="/etc/cloud/cloud.cfg" + +# If there exists a sysconfig variable override file use it... +[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init + +start() { + [ -x $cloud_init ] || return 5 + [ -f $conf ] || return 6 + + echo -n $"Starting $prog: " + $cloud_init $CLOUDINITARGS modules --mode final + RETVAL=$? + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + # No-op + RETVAL=7 + return $RETVAL +} + +. /etc/init.d/functions + +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|try-restart|condrestart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + # + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + start + RETVAL=$? + ;; + reload|force-reload) + # It does not support reload + RETVAL=3 + ;; + status) + echo -n $"Checking for service $prog:" + # Return value is slightly different for the status command: + # 0 - service up and running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running (unused) + # 4 - service status unknown :-( + # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) + RETVAL=3 + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" + RETVAL=3 + ;; +esac + +exit $RETVAL diff --git a/sysvinit/cloud-init b/sysvinit/cloud-init new file mode 100755 index 00000000..7726c452 --- /dev/null +++ b/sysvinit/cloud-init @@ -0,0 +1,124 @@ +#!/bin/sh + +# +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Joshua Harlow +# +# 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 . +# + +# See: http://wiki.debian.org/LSBInitScripts +# See: http://tiny.cc/czvbgw +# See: http://www.novell.com/coolsolutions/feature/15380.html +# Also based on dhcpd in RHEL (for comparison) + +### BEGIN INIT INFO +# Provides: cloud-init +# Required-Start: $local_fs $network $named $remote_fs +# Should-Start: $time +# Required-Stop: +# Should-Stop: +# Default-Start: 3 5 +# Default-Stop: +# Short-Description: The initial cloud-init job (net and fs contingent) +# Description: Start cloud-init and runs the initialization phase +# and any associated initial modules as desired. +### END INIT INFO + +. /etc/init.d/functions + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +RETVAL=0 + +prog="cloud-init" +cloud_init="/usr/bin/cloud-init" +conf="/etc/cloud/cloud.cfg" + +# If there exists a sysconfig variable override file use it... +[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init + +start() { + [ -x $cloud_init ] || return 5 + [ -f $conf ] || return 6 + + echo -n $"Starting $prog: " + $cloud_init $CLOUDINITARGS init + RETVAL=$? + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + # No-op + RETVAL=7 + return $RETVAL +} + +. /etc/init.d/functions + +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|try-restart|condrestart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + # + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + start + RETVAL=$? + ;; + reload|force-reload) + # It does not support reload + RETVAL=3 + ;; + status) + echo -n $"Checking for service $prog:" + # Return value is slightly different for the status command: + # 0 - service up and running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running (unused) + # 4 - service status unknown :-( + # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) + RETVAL=3 + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" + RETVAL=3 + ;; +esac + +exit $RETVAL diff --git a/sysvinit/cloud-init-local b/sysvinit/cloud-init-local new file mode 100755 index 00000000..bf5d409a --- /dev/null +++ b/sysvinit/cloud-init-local @@ -0,0 +1,124 @@ +#!/bin/sh + +# +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Joshua Harlow +# +# 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 . +# + +# See: http://wiki.debian.org/LSBInitScripts +# See: http://tiny.cc/czvbgw +# See: http://www.novell.com/coolsolutions/feature/15380.html +# Also based on dhcpd in RHEL (for comparison) + +### BEGIN INIT INFO +# Provides: cloud-init +# Required-Start: $local_fs $remote_fs +# Should-Start: $time +# Required-Stop: +# Should-Stop: +# Default-Start: 3 5 +# Default-Stop: +# Short-Description: The initial cloud-init job (local fs contingent) +# Description: Start cloud-init and runs the initialization phases +# and any associated initial modules as desired. +### END INIT INFO + +. /etc/init.d/functions + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +RETVAL=0 + +prog="cloud-init" +cloud_init="/usr/bin/cloud-init" +conf="/etc/cloud/cloud.cfg" + +# If there exists a sysconfig variable override file use it... +[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init + +start() { + [ -x $cloud_init ] || return 5 + [ -f $conf ] || return 6 + + echo -n $"Starting $prog: " + $cloud_init $CLOUDINITARGS init --local + RETVAL=$? + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + # No-op + RETVAL=7 + return $RETVAL +} + +. /etc/init.d/functions + +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|try-restart|condrestart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + # + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + start + RETVAL=$? + ;; + reload|force-reload) + # It does not support reload + RETVAL=3 + ;; + status) + echo -n $"Checking for service $prog:" + # Return value is slightly different for the status command: + # 0 - service up and running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running (unused) + # 4 - service status unknown :-( + # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) + RETVAL=3 + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" + RETVAL=3 + ;; +esac + +exit $RETVAL -- cgit v1.2.3