Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Import daemontools version 0.9.0

  • Loading branch information...
commit c300a933a8a074060aac0eea062859f54167438a 1 parent f7845c1
@smith smith authored
View
43 daemontools/README.md
@@ -0,0 +1,43 @@
+Description
+===========
+
+Installs DJB's Daemontools and includes a service LWRP.
+
+Requirements
+============
+
+Should work on ArchLinux, Debian and Ubuntu. May work on Red Hat family distributions.
+
+Requires build-essential and ucspi-tcp cookbooks.
+
+Attributes
+==========
+
+* `node[:daemontools][:bin_dir]` - Sets the location of the binaries for daemontools, default is selected by platform, or '/usr/local/bin' as a fallback.
+
+Resource/Provider
+=================
+
+This cookbook includes an LWRP for managing daemontools services.
+
+Usage
+=====
+
+License and Author
+==================
+
+Author: Joshua Timberman (<joshua@opscode.com>)
+
+Copyright 2010, Opscode, Inc.
+
+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.
View
42 daemontools/attributes/default.rb
@@ -0,0 +1,42 @@
+#
+# Cookbook Name:: daemontools
+# Attributes:: default
+#
+# Copyright 2010, Opscode, Inc
+#
+# 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.
+#
+case platform
+when "ubuntu"
+ if platform_version.to_f >= 9.04
+ set[:daemontools][:bin_dir] = "/usr/bin"
+ set[:daemontools][:service_dir] = "/etc/service"
+ else
+ set[:daemontools][:bin_dir] = "/usr/local/bin"
+ set[:daemontools][:service_dir] = "/etc/service"
+ end
+when "debian"
+ if platform_version.to_f >= 5.0
+ set[:daemontools][:bin_dir] = "/usr/bin"
+ set[:daemontools][:service_dir] = "/etc/service"
+ else
+ set[:daemontools][:bin_dir] = "/usr/local/bin"
+ set[:daemontools][:service_dir] = "/etc/service"
+ end
+when "arch"
+ set[:daemontools][:bin_dir] = "/usr/sbin"
+ set[:daemontools][:service_dir] = "/etc/service"
+else
+ set[:daemontools][:bin_dir] = "/usr/local/bin"
+ set[:daemontools][:service_dir] = "/etc/service"
+end
View
36 daemontools/files/arch/PKGBUILD
@@ -0,0 +1,36 @@
+# Contributor: jianingy <jianingy.yang@gmail.com>
+
+pkgname=daemontools
+pkgrel=4
+pkgver=0.76
+pkgdesc="daemontools is a collection of tools for managing UNIX services."
+arch=(i686 x86_64)
+url="http://cr.yp.to/daemontools.html"
+license=('public domain')
+depends=('pacman>=3.1.0')
+backups=('/etc/inittab')
+install=daemontools.install
+source=(
+ "http://cr.yp.to/daemontools/$pkgname-$pkgver.tar.gz"
+ 'daemontools-0.76.errno.patch'
+ 'daemontools-0.76.svscanboot-path-fix.patch'
+)
+md5sums=(
+ '1871af2453d6e464034968a0fbcb2bfc'
+ '1ab80be37239e920542425baa8f1c5b9'
+ '1854f01aed93f0fd1577db2da51f1935'
+)
+sha1sums=(
+ '70a1be67e7dbe0192a887905846acc99ad5ce5b7'
+ 'ee5b43b333dae9ee3ad0d2f9aeb9c1e2537f0978'
+ '5fd9c45aab2e9bd83e71440092dfb0e2482bfb4f'
+)
+
+build() {
+ cd $srcdir/admin/$pkgname-$pkgver || exit 1
+ patch -p1 < $srcdir/daemontools-0.76.errno.patch || exit 1
+ patch -p1 < $srcdir/daemontools-0.76.svscanboot-path-fix.patch || exit 1
+ package/compile || exit 1
+ mkdir -pv $pkgdir/usr/sbin $pkgdir/etc/service || exit 1
+ cp -a command/* $pkgdir/usr/sbin || exit 1
+}
View
13 daemontools/files/arch/daemontools-0.76.svscanboot-path-fix.patch
@@ -0,0 +1,13 @@
+diff -Nur daemontools-0.76.old/src/svscanboot.sh daemontools-0.76/src/svscanboot.sh
+--- daemontools-0.76.old/src/svscanboot.sh 2001-07-13 00:49:49.000000000 +0800
++++ daemontools-0.76/src/svscanboot.sh 2009-11-07 23:46:47.000000000 +0800
+@@ -5,7 +5,7 @@
+ exec >/dev/null
+ exec 2>/dev/null
+
+-/command/svc -dx /service/* /service/*/log
++/usr/sbin/svc -dx /etc/service/* /etc/service/*/log
+
+-env - PATH=$PATH svscan /service 2>&1 | \
++env - PATH=$PATH svscan /etc/service 2>&1 | \
+ env - PATH=$PATH readproctitle service errors: ................................................................................................................................................................................................................................................................................................................................................................................................................
View
45 daemontools/metadata.json
@@ -0,0 +1,45 @@
+{
+ "name": "daemontools",
+ "description": "Installs/Configures daemontools",
+ "long_description": "Description\n===========\n\nInstalls DJB's Daemontools and includes a service LWRP.\n\nRequirements\n============\n\nShould work on ArchLinux, Debian and Ubuntu. May work on Red Hat family distributions.\n\nRequires build-essential and ucspi-tcp cookbooks.\n\nAttributes\n==========\n\n* `node[:daemontools][:bin_dir]` - Sets the location of the binaries for daemontools, default is selected by platform, or '/usr/local/bin' as a fallback.\n\nResource/Provider\n=================\n\nThis cookbook includes an LWRP for managing daemontools services.\n\nUsage\n=====\n\nLicense and Author\n==================\n\nAuthor: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright 2010, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "debian": [
+
+ ],
+ "ubuntu": [
+
+ ],
+ "arch": [
+
+ ]
+ },
+ "dependencies": {
+ "build-essential": [
+
+ ],
+ "ucspi-tcp": [
+
+ ]
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "daemontools": "Installs daemontools by source or package depending on platform"
+ },
+ "version": "0.9.0"
+}
View
15 daemontools/metadata.rb
@@ -0,0 +1,15 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs/Configures daemontools"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "0.9.0"
+recipe "daemontools", "Installs daemontools by source or package depending on platform"
+
+%w{ build-essential ucspi-tcp }.each do |cb|
+ depends cb
+end
+
+%w{ debian ubuntu arch }.each do |os|
+ supports os
+end
View
191 daemontools/providers/service.rb
@@ -0,0 +1,191 @@
+#
+# Cookbook Name:: daemontools
+# Provider:: service
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+require 'chef/mixin/command'
+require 'chef/mixin/language'
+include Chef::Mixin::Command
+
+def load_current_resource
+ @svc = Chef::Resource::DaemontoolsService.new(new_resource.name)
+ @svc.service_name(new_resource.service_name)
+
+ Chef::Log.debug("Checking status of service #{new_resource.service_name}")
+
+ begin
+ if run_command_with_systems_locale(:command => "svok #{new_resource.directory}") == 0
+ @svc.running(true)
+ end
+ rescue Chef::Exceptions::Exec
+ @svc.running(false)
+ nil
+ end
+
+ if ::File.symlink?("#{node['daemontools']['service_dir']}/#{new_resource.service_name}") && ::File.exists?("#{node['daemontools']['service_dir']}/#{new_resource.service_name}/run")
+ @svc.enabled(true)
+ else
+ @svc.enabled(false)
+ end
+end
+
+action :enable do
+ unless @svc.enabled
+ directory new_resource.directory do
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ end
+
+ if new_resource.template
+ template "#{new_resource.directory}/run" do
+ source "sv-#{new_resource.template}-run.erb"
+ cookbook new_resource.cookbook if new_resource.cookbook
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ variables :variables => new_resource.variables unless new_resource.variables.empty?
+ end
+ if new_resource.log
+ directory "#{new_resource.directory}/log" do
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ end
+ template "#{new_resource.directory}/log/run" do
+ source "sv-#{new_resource.template}-log-run.erb"
+ cookbook new_resource.cookbook if new_resource.cookbook
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ end
+ end
+ if new_resource.finish
+ template "#{new_resource.directory}/finish" do
+ source "sv-#{new_resource.template}-finish.erb"
+ cookbook new_resource.cookbook if new_resource.cookbook
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ end
+ end
+ end
+
+ unless new_resource.env.empty?
+ directory "#{new_resource.directory}/env" do
+ owner new_resource.owner
+ group new_resource.group
+ mode 0755
+ end
+ new_resource.env.each do |var, value|
+ file "#{new_resource.directory}/env/#{var}" do
+ content value
+ owner new_resource.owner
+ group new_resource.group
+ mode 0644
+ end
+ end
+ end
+
+ link"#{node['daemontools']['service_dir']}/#{new_resource.service_name}" do
+ to new_resource.directory
+ end
+ end
+end
+
+action :start do
+ unless @svc.running
+ execute "svc -u #{new_resource.service_name}"
+ end
+end
+
+action :disable do
+ if @svc.enabled
+ link "#{node['daemontools']['service_dir']}/#{new_resource.service_name}" do
+ action :delete
+ end
+ execute "svc -dx . log" do
+ cwd new_resource.directory
+ end
+ end
+end
+
+action :stop do
+ if @svc.running
+ execute "svc -p #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :restart do
+ if @svc.running
+ execute "svc -t #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :up do
+ if @svc.running
+ execute "svc -u #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :once do
+ if @svc.running
+ execute "svc -o #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :pause do
+ if @svc.running
+ execute "svc -p #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :cont do
+ if @svc.running
+ execute "svc -c #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :hup do
+ if @svc.running
+ execute "svc -h #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :alrm do
+ if @svc.running
+ execute "svc -a #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :int do
+ if @svc.running
+ execute "svc -i #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :term do
+ if @svc.running
+ execute "svc -t #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
+
+action :kill do
+ if @svc.running
+ execute "svc -k #{node['daemontools']['service_dir']}/#{new_resource.service_name}"
+ end
+end
View
70 daemontools/recipes/default.rb
@@ -0,0 +1,70 @@
+#
+# Cookbook Name:: daemontools
+# Recipe:: source
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+include_recipe "build-essential"
+include_recipe "ucspi-tcp"
+
+installation_method = value_for_platform(
+ "arch" => { "default" => "aur" },
+ "debian" => { "4.0" => "source", "default" => "package" },
+ "ubuntu" => {
+ "6.06" => "source",
+ "6.10" => "source",
+ "7.04" => "source",
+ "7.10" => "source",
+ "8.04" => "source",
+ "8.10" => "source",
+ "default" => "package"
+ },
+ "default" => { "default" => "source" }
+)
+
+case installation_method
+when "package"
+ package "daemontools" do
+ action :install
+ end
+ case node[:platform]
+ when "debian","ubuntu"
+ package "daemontools-run" do
+ action :install
+ end
+ end
+when "aur"
+ pacman_aur "daemontools" do
+ patches ["daemontools-0.76.svscanboot-path-fix.patch"]
+ pkgbuild_src true
+ action [:build,:install]
+ end
+when "source"
+ bash "install_daemontools" do
+ user "root"
+ cwd "/tmp"
+ code <<-EOH
+ (cd /tmp; wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz)
+ (cd /tmp; tar zxvf daemontools-0.76.tar.gz)
+ (cd /tmp/admin/daemontools-0.76; perl -pi -e 's/extern int errno;/\#include <errno.h>/' src/error.h)
+ (cd /tmp/admin/daemontools-0.76; package/compile)
+ (cd /tmp/admin/daemontools-0.76; mv command/* #{node[:daemontools][:bin_dir]})
+ EOH
+ only_if {::File.exists?("#{node[:daemontools][:bin_dir]}/svscan")}
+ end
+else
+ Chef::Log.info("Could not find a method to install Daemon Tools for platform #{node[:platform]}, version #{node[:platform_version]}")
+end
View
44 daemontools/resources/service.rb
@@ -0,0 +1,44 @@
+#
+# Cookbook Name:: daemontools
+# Resource:: service
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+# -u: Up. If the service is not running, start it. If the service stops, restart it.
+# -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.
+# -o: Once. If the service is not running, start it. Do not restart it if it stops.
+# -p: Pause. Send the service a STOP signal.
+# -c: Continue. Send the service a CONT signal.
+# -h: Hangup. Send the service a HUP signal.
+# -a: Alarm. Send the service an ALRM signal.
+# -i: Interrupt. Send the service an INT signal.
+# -t: Terminate. Send the service a TERM signal.
+# -k: Kill. Send the service a KILL signal.
+
+actions :start, :stop, :status, :restart, :up, :down, :once, :pause, :cont, :hup, :alrm, :int, :term, :kill, :enable, :disable
+
+attribute :service_name, :name_attribute => true
+attribute :directory, :kind_of => String, :required => true
+attribute :template, :kind_of => [String, FalseClass], :default => :service_name
+attribute :cookbook, :kind_of => String
+attribute :enabled, :default => false
+attribute :running, :default => false
+attribute :variables, :kind_of => Hash, :default => {}
+attribute :owner, :regex => Chef::Config[:user_valid_regex]
+attribute :group, :regex => Chef::Config[:group_valid_regex]
+attribute :finish, :kind_of => [TrueClass, FalseClass]
+attribute :log, :kind_of => [TrueClass, FalseClass]
+attribute :env, :kind_of => Hash, :default => {}
Please sign in to comment.
Something went wrong with that request. Please try again.