Permalink
Browse files

Import daemontools version 0.9.0

  • Loading branch information...
1 parent f7845c1 commit c300a933a8a074060aac0eea062859f54167438a @smith smith committed Aug 26, 2011
View
@@ -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.
@@ -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
@@ -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
+}
@@ -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
@@ -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
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit c300a93

Please sign in to comment.