Permalink
Browse files

couchdb::source recipe; use File.join for pathing in rabbitmq

  • Loading branch information...
1 parent fd55157 commit 40c7fc028fe6ff402e5f2f75a884dfe8a454495e @jtimberman jtimberman committed Feb 19, 2010
Showing with 257 additions and 0 deletions.
  1. +21 −0 attributes/couchdb.rb
  2. +168 −0 files/default/couchdb.init
  3. +1 −0 metadata.rb
  4. +67 −0 recipes/source.rb
View
@@ -0,0 +1,21 @@
+#
+# Author:: Joshua Timberman <joshua@opscode.com>
+# Cookbook Name:: couchdb
+# Attributes:: couchdb
+#
+# 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.
+
+set[:couch_db][:src_version] = "0.10.1"
+set[:couch_db][:src_mirror] = "http://apache.osuosl.org/couchdb/#{couch_db.src_version}/apache-couchdb-#{couch_db.src_version}.tar.gz"
View
@@ -0,0 +1,168 @@
+#!/bin/sh -e
+
+# 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.
+
+### BEGIN INIT INFO
+# Provides: couchdb
+# Required-Start: $local_fs $remote_fs
+# Required-Stop: $local_fs $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Apache CouchDB init script
+# Description: Apache CouchDB init script for the database server.
+### END INIT INFO
+
+SCRIPT_OK=0
+SCRIPT_ERROR=1
+
+DESCRIPTION="database server"
+NAME=couchdb
+SCRIPT_NAME=`basename $0`
+COUCHDB=/usr/local/bin/couchdb
+CONFIGURATION_FILE=/usr/local/etc/default/couchdb
+RUN_DIR=/usr/local/var/run/couchdb
+LSB_LIBRARY=/lib/lsb/init-functions
+
+if test ! -x $COUCHDB; then
+ exit $SCRIPT_ERROR
+fi
+
+if test -r $CONFIGURATION_FILE; then
+ . $CONFIGURATION_FILE
+fi
+
+log_daemon_msg () {
+ # Dummy function to be replaced by LSB library.
+
+ echo $@
+}
+
+log_end_msg () {
+ # Dummy function to be replaced by LSB library.
+
+ if test "$1" != "0"; then
+ echo "Error with $DESCRIPTION: $NAME"
+ fi
+ return $1
+}
+
+if test -r $LSB_LIBRARY; then
+ . $LSB_LIBRARY
+fi
+
+start_couchdb () {
+ # Start Apache CouchDB as a background process.
+
+ command="$COUCHDB -b"
+ if test -n "$COUCHDB_STDOUT_FILE"; then
+ command="$command -o $COUCHDB_STDOUT_FILE"
+ fi
+ if test -n "$COUCHDB_STDERR_FILE"; then
+ command="$command -e $COUCHDB_STDERR_FILE"
+ fi
+ if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then
+ command="$command -r $COUCHDB_RESPAWN_TIMEOUT"
+ fi
+ if test -n "$COUCHDB_OPTIONS"; then
+ command="$command $COUCHDB_OPTIONS"
+ fi
+ mkdir -p "$RUN_DIR"
+ if test -n "$COUCHDB_USER"; then
+ chown $COUCHDB_USER "$RUN_DIR"
+ if su $COUCHDB_USER -c "$command" > /dev/null; then
+ return $SCRIPT_OK
+ else
+ return $SCRIPT_ERROR
+ fi
+ else
+ if $command > /dev/null; then
+ return $SCRIPT_OK
+ else
+ return $SCRIPT_ERROR
+ fi
+ fi
+}
+
+stop_couchdb () {
+ # Stop the running Apache CouchDB process.
+
+ command="$COUCHDB -d"
+ if test -n "$COUCHDB_OPTIONS"; then
+ command="$command $COUCHDB_OPTIONS"
+ fi
+ if test -n "$COUCHDB_USER"; then
+ if su $COUCHDB_USER -c "$command" > /dev/null; then
+ return $SCRIPT_OK
+ else
+ return $SCRIPT_ERROR
+ fi
+ else
+ if $command > /dev/null; then
+ return $SCRIPT_OK
+ else
+ return $SCRIPT_ERROR
+ fi
+ fi
+}
+
+display_status () {
+ # Display the status of the running Apache CouchDB process.
+
+ $COUCHDB -s
+}
+
+parse_script_option_list () {
+ # Parse arguments passed to the script and take appropriate action.
+
+ case "$1" in
+ start)
+ log_daemon_msg "Starting $DESCRIPTION" $NAME
+ if start_couchdb; then
+ log_end_msg $SCRIPT_OK
+ else
+ log_end_msg $SCRIPT_ERROR
+ fi
+ ;;
+ stop)
+ log_daemon_msg "Stopping $DESCRIPTION" $NAME
+ if stop_couchdb; then
+ log_end_msg $SCRIPT_OK
+ else
+ log_end_msg $SCRIPT_ERROR
+ fi
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESCRIPTION" $NAME
+ if stop_couchdb; then
+ if start_couchdb; then
+ log_end_msg $SCRIPT_OK
+ else
+ log_end_msg $SCRIPT_ERROR
+ fi
+ else
+ log_end_msg $SCRIPT_ERROR
+ fi
+ ;;
+ status)
+ display_status
+ ;;
+ *)
+ cat << EOF >&2
+Usage: $SCRIPT_NAME {start|stop|restart|force-reload|status}
+EOF
+ exit $SCRIPT_ERROR
+ ;;
+ esac
+}
+
+parse_script_option_list $@
View
@@ -11,6 +11,7 @@
EOH
version "0.8"
+depends "erlang"
supports "ubuntu", ">= 8.10" # for package in APT
supports "debian", ">= 5.0" # for package in APT
supports "openbsd"
View
@@ -0,0 +1,67 @@
+#
+# Author:: Joshua Timberman <joshua@opscode.com>
+# Cookbook Name:: couchdb
+# 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 "erlang"
+
+couchdb_tar_gz = File.join(Chef::Config[:file_cache_path], "/", "apache-couchdb-#{node[:couch_db][:src_version]}.tar.gz")
+
+case node[:platform]
+when "debian", "ubuntu"
+ %w{ libmozjs-dev libicu-dev libcurl4-openssl-dev }.each do |pkg|
+ package "pkg"
+ end
+end
+
+remote_file couchdb_tar_gz do
+ checksum "2c6af7216537d0e399674a83e4505dc04a02abe1bdd966f69074564c3521c66b"
+ source node[:couch_db][:src_mirror]
+end
+
+bash "install couchdb #{node[:couch_db][:src_version]}" do
+ cwd Chef::Config[:file_cache_path]
+ code <<-EOH
+ ./configure && make && make install
+ EOH
+end
+
+user "couchdb" do
+ home "/usr/local/var/lib/couchdb"
+ comment "CouchDB Administrator"
+ supports :manage_home => false
+end
+
+%w{ var/lib/couchdb var/log/couchdb var/run etc/couchdb }.each do |dir|
+ directory "/usr/local/#{dir}" do
+ owner "couchdb"
+ group "couchdb"
+ mode "0770"
+ end
+end
+
+remote_file "/etc/init.d/couchdb" do
+ source "couchdb.init"
+ owner "root"
+ group "root"
+ mode "0755"
+end
+
+service "couchdb" do
+ supports [ :restart, :status ]
+ action [:enable, :start]
+end

0 comments on commit 40c7fc0

Please sign in to comment.