Skip to content

Commit 1890cdc

Browse files
committedJun 10, 2017
rubocop cleanups, special case default recipe when pkgs are unavail
1 parent 41ec613 commit 1890cdc

File tree

10 files changed

+255
-80
lines changed

10 files changed

+255
-80
lines changed
 

‎.kitchen.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ verifier:
1919

2020
platforms:
2121
- name: centos-6.9
22-
- name: centos-7.2
22+
- name: centos-7.3
2323
- name: debian-7.11
2424
- name: debian-8.7
2525
- name: ubuntu-12.04
@@ -28,7 +28,11 @@ platforms:
2828
suites:
2929
- name: default
3030
run_list:
31+
- recipe[apt::default]
3132
- recipe[couchdb]
33+
verifier:
34+
inspec_tests:
35+
- test/smoke/inspec
3236
- name: source
3337
run_list:
3438
- recipe[apt::default]

‎CHANGELOG.md

+16-20
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,38 @@ This file is used to list changes made in each version of the CouchDB cookbook.
44

55
v2.5.3
66
------
7-
Multiple fixes for CentOS, recent Debian/Ubuntu builds
8-
Prefer /usr/lib64/ over /usr/lib when present
9-
Store CouchDB UUID into host-specific local.ini file
7+
* Multiple fixes for CentOS, recent Debian/Ubuntu builds
8+
* Prefer /usr/lib64/ over /usr/lib when present
9+
* Store CouchDB UUID into host-specific local.ini file
1010

1111
v2.5.2
1212
------
13-
Add nohup to running couch to make it work with Test Kitchen
14-
adding case for libmozjs package for ubuntu 14.04
15-
Specify upstart service provider for ubuntu >=13.10
16-
13+
* Add nohup to running couch to make it work with Test Kitchen
14+
* adding case for libmozjs package for ubuntu 14.04
15+
* Specify upstart service provider for ubuntu >=13.10
1716

1817
v2.5.1
1918
------
20-
New cookbook maintainer
21-
Update default version to CouchDB 1.5.0
22-
Update source download URL to new format
23-
Fix testkitchen support
24-
Fix stray "w" in 1.5.0
19+
* New cookbook maintainer
20+
* Update default version to CouchDB 1.5.0
21+
* Update source download URL to new format
22+
* Fix testkitchen support
23+
* Fix stray "w" in 1.5.0
2524

2625

2726
v2.5.0
2827
------
29-
Porting to use cookbook yum ~> 3.0
30-
Fixing up style to pass rubocop
31-
Updating testing bits
32-
28+
* Porting to use cookbook yum ~> 3.0
29+
* Fixing up style to pass rubocop
30+
* Updating testing bits
3331

3432
v2.4.8
3533
------
36-
fixing metadata version error. locking to 3.0"
37-
34+
* fixing metadata version error. locking to 3.0
3835

3936
v2.4.6
4037
------
41-
Locking yum dependency to '< 3'
42-
38+
* Locking yum dependency to '< 3'
4339

4440
v2.4.4
4541
------

‎README.md

+28-29
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ Tested via Test Kitchen:
1616
* Debian 7, 8
1717
* Ubuntu 12.04, 14.04
1818

19-
**NOTE** Ubuntu 16.04 (xenial) does not have an old enough version of Erlang available to support CouchDB 1.x! This cookbook will move to support CouchDB 2.x soon, resolving this issue.
19+
**NOTE** Ubuntu 16.04 (xenial) does not have an old enough version of Erlang
20+
available to support CouchDB 1.x! This cookbook will move to support CouchDB 2.x
21+
soon, resolving this issue.
2022

2123
## Cookbooks
2224

2325
* erlang
2426

25-
When using the `couchdb::source` recipe, the `build-essential` recipe
26-
is required. It is not a direct dependency of this cookbook as it is
27-
an optional installation method, and package installation is
28-
recommended.
27+
When using the `couchdb::source` recipe, the `build-essential` recipe is
28+
required. It is not a direct dependency of this cookbook as it is an optional
29+
installation method, and package installation is recommended.
2930

3031
Attributes
3132
==========
@@ -52,24 +53,23 @@ Will result in the following lines in the `local.ini` file:
5253
[httpd]
5354
bind_address = "0.0.0.0"
5455

55-
The attributes file contains default values for platform-independent
56-
parameters. All parameter values that expect a path argument are
57-
not set by default. The default values that are currently set have
58-
been taken from the CouchDB configuration
59-
[wiki page](http://wiki.apache.org/couchdb/Configurationfile_couch.ini).
56+
The attributes file contains default values for platform-independent parameters.
57+
All parameter values that expect a path argument are not set by default. The
58+
default values that are currently set have been taken from the CouchDB
59+
configuration [wiki
60+
page](http://wiki.apache.org/couchdb/Configurationfile_couch.ini).
6061

6162
The resulting configuration file is now dynamically rendered from the
62-
attributes. Each subkey below the `config` key is a specific section
63-
of the `local.ini` file. Then each subkey in a section is a parameter
64-
associated with a value.
63+
attributes. Each subkey below the `config` key is a specific section of the
64+
`local.ini` file. Then each subkey in a section is a parameter associated with a
65+
value.
6566

66-
You should consult the CouchDB documentation for specific
67-
configuration details.
67+
You should consult the CouchDB documentation for specific configuration details.
6868

69-
For values that are "on" or "off", they should be specified as literal
70-
`true` or `false`. Any configuration option set to the literal `nil` will
71-
be skipped entirely. All other values (e.g., string, numeric literals) will
72-
be used as is. So for example:
69+
For values that are "on" or "off", they should be specified as literal `true` or
70+
`false`. Any configuration option set to the literal `nil` will be skipped
71+
entirely. All other values (e.g., string, numeric literals) will be used as is.
72+
So for example:
7373

7474
node.default['couch_db']['config']['couchdb']['os_process_timeout'] = 5000
7575
node.default['couch_db']['config']['couchdb']['delayed_commits'] = true
@@ -91,8 +91,8 @@ Will result in the following config lines:
9191

9292
### Defaults
9393

94-
Here the list of attributes that are already provided by the recipe
95-
and their associated default value.
94+
Here the list of attributes that are already provided by the recipe and their
95+
associated default value.
9696

9797
#### Section [couchdb]
9898

@@ -153,17 +153,16 @@ Can be used to create a database on a CouchDB install.
153153
License and Author
154154
==================
155155

156-
Licensed under the Apache License, Version 2.0 (the "License");
157-
you may not use this file except in compliance with the License.
158-
You may obtain a copy of the License at
156+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
157+
this file except in compliance with the License. You may obtain a copy of the
158+
License at
159159

160160
http://www.apache.org/licenses/LICENSE-2.0
161161

162-
Unless required by applicable law or agreed to in writing, software
163-
distributed under the License is distributed on an "AS IS" BASIS,
164-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
165-
See the License for the specific language governing permissions and
166-
limitations under the License.
162+
Unless required by applicable law or agreed to in writing, software distributed
163+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
164+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
165+
specific language governing permissions and limitations under the License.
167166

168167
* Author: Joshua Timberman (<joshua@opscode.com>)
169168
* Author: Matthieu Vachon (<matthieu.o.vachon@gmail.com>)

‎Rakefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ desc 'Run all tasks'
1414
task all: [:doc, :rubocop, :foodcritic, :spec, 'kitchen:all']
1515

1616
desc 'Build documentation'
17-
#task doc: [:knifecookbookdoc, :yard]
17+
# task doc: [:knifecookbookdoc, :yard]
1818
task doc: [:yard]
1919

2020
desc 'Run kitchen integration tests'
2121
task test: ['kitchen:all']
2222

23-
#desc 'Generate README.md from _README.md.erb'
24-
#KnifeCookbookDoc::RakeTask.new(:knifecookbookdoc)
23+
# desc 'Generate README.md from _README.md.erb'
24+
# KnifeCookbookDoc::RakeTask.new(:knifecookbookdoc)
2525

2626
FoodCritic::Rake::LintTask.new do |t|
2727
t.options = { fail_tags: ['all'] }

‎attributes/default.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
default['couch_db']['src_mirror'] = "https://archive.apache.org/dist/couchdb/source/#{node['couch_db']['src_version']}/apache-couchdb-#{node['couch_db']['src_version']}.tar.gz"
2323
default['couch_db']['install_erlang'] = true
2424
# CouchDB 1.x doesn't support Erlang newer than 17.x!
25-
node.set['erlang']['esl']['version'] = '17.5.3'
25+
node.default['erlang']['esl']['version'] = '17.5.3'
2626

2727
# Attributes below are used to configure your couchdb instance.
2828
# These defaults were extracted from this url:
+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/sh -e
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4+
# use this file except in compliance with the License. You may obtain a copy of
5+
# the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations under
13+
# the License.
14+
15+
### BEGIN INIT INFO
16+
# Provides: couchdb
17+
# Required-Start: $local_fs $remote_fs
18+
# Required-Stop: $local_fs $remote_fs
19+
# Default-Start: 2 3 4 5
20+
# Default-Stop: 0 1 6
21+
# Short-Description: Apache CouchDB init script
22+
# Description: Apache CouchDB init script for the database server.
23+
### END INIT INFO
24+
25+
SCRIPT_OK=0
26+
SCRIPT_ERROR=1
27+
28+
DESCRIPTION="database server"
29+
NAME=couchdb
30+
SCRIPT_NAME=`basename $0`
31+
COUCHDB=/usr/bin/couchdb
32+
CONFIGURATION_FILE=/etc/default/couchdb
33+
RUN_DIR=/var/run/couchdb
34+
LSB_LIBRARY=/lib/lsb/init-functions
35+
36+
if test ! -x $COUCHDB; then
37+
exit $SCRIPT_ERROR
38+
fi
39+
40+
if test -r $CONFIGURATION_FILE; then
41+
. $CONFIGURATION_FILE
42+
fi
43+
44+
log_daemon_msg () {
45+
# Dummy function to be replaced by LSB library.
46+
47+
echo $@
48+
}
49+
50+
log_end_msg () {
51+
# Dummy function to be replaced by LSB library.
52+
53+
if test "$1" != "0"; then
54+
echo "Error with $DESCRIPTION: $NAME"
55+
fi
56+
return $1
57+
}
58+
59+
if test -r $LSB_LIBRARY; then
60+
. $LSB_LIBRARY
61+
fi
62+
63+
start_couchdb () {
64+
# Start Apache CouchDB as a background process.
65+
66+
command="$COUCHDB -b"
67+
if test -n "$COUCHDB_STDOUT_FILE"; then
68+
command="$command -o $COUCHDB_STDOUT_FILE"
69+
fi
70+
if test -n "$COUCHDB_STDERR_FILE"; then
71+
command="$command -e $COUCHDB_STDERR_FILE"
72+
fi
73+
if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then
74+
command="$command -r $COUCHDB_RESPAWN_TIMEOUT"
75+
fi
76+
if test -n "$COUCHDB_OPTIONS"; then
77+
command="$command $COUCHDB_OPTIONS"
78+
fi
79+
mkdir -p "$RUN_DIR"
80+
if test -n "$COUCHDB_USER"; then
81+
chown $COUCHDB_USER "$RUN_DIR"
82+
if nohup su $COUCHDB_USER -c "$command" > /dev/null; then
83+
return $SCRIPT_OK
84+
else
85+
return $SCRIPT_ERROR
86+
fi
87+
else
88+
if $command > /dev/null; then
89+
return $SCRIPT_OK
90+
else
91+
return $SCRIPT_ERROR
92+
fi
93+
fi
94+
}
95+
96+
stop_couchdb () {
97+
# Stop the running Apache CouchDB process.
98+
retval=0
99+
if ! $COUCHDB -s >/dev/null 2>&1; then
100+
log_daemon_msg "already stopped"
101+
else
102+
pkill -u $COUCHDB_USER beam\*
103+
retval=$?
104+
[ $retval -eq 0 ] && return $SCRIPT_OK || return $SCRIPT_ERROR
105+
fi
106+
return $retval
107+
}
108+
109+
display_status () {
110+
# Display the status of the running Apache CouchDB process.
111+
112+
$COUCHDB -s
113+
}
114+
115+
parse_script_option_list () {
116+
# Parse arguments passed to the script and take appropriate action.
117+
118+
case "$1" in
119+
start)
120+
log_daemon_msg "Starting $DESCRIPTION" $NAME
121+
if start_couchdb; then
122+
log_end_msg $SCRIPT_OK
123+
else
124+
log_end_msg $SCRIPT_ERROR
125+
fi
126+
;;
127+
stop)
128+
log_daemon_msg "Stopping $DESCRIPTION" $NAME
129+
if stop_couchdb; then
130+
log_end_msg $SCRIPT_OK
131+
else
132+
log_end_msg $SCRIPT_ERROR
133+
fi
134+
;;
135+
restart|force-reload)
136+
log_daemon_msg "Restarting $DESCRIPTION" $NAME
137+
if stop_couchdb; then
138+
if start_couchdb; then
139+
log_end_msg $SCRIPT_OK
140+
else
141+
log_end_msg $SCRIPT_ERROR
142+
fi
143+
else
144+
log_end_msg $SCRIPT_ERROR
145+
fi
146+
;;
147+
status)
148+
display_status
149+
;;
150+
*)
151+
cat << EOF >&2
152+
Usage: $SCRIPT_NAME {start|stop|restart|force-reload|status}
153+
EOF
154+
exit $SCRIPT_ERROR
155+
;;
156+
esac
157+
}
158+
159+
parse_script_option_list $@

0 commit comments

Comments
 (0)
Please sign in to comment.