Changes of Revision 16
[-] | Changed | couchdb.spec |
x 1
2 License: GPL 3 Source0: %{name}-%{version}.tar.gz 4 Source1: couchdb.apache.conf 5 +Source2: couchdb.suse.init 6 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 7 8 BuildRequires: libicu-devel curl-devel libxml2-devel 9
10 Requires: mozilla-xulrunner181 >= 1.8.1 11 Requires: erlang apache2 libicu-devel 12 13 -%description 14 +# Macro that print mesages to syslog at package (un)install time 15 +%define nnmmsg logger -t %{name}/rpm 16 + 17 18 +%description 19 +A CouchDB server hosts named databases, which store documents. 20 +Each document is uniquely named in the database, and CouchDB 21 +provides a [WWW] RESTful HTTP API for reading and 22 +updating (add, edit, delete) database documents. 23 24 %prep 25 %setup 26
27 rmdir %{buildroot}/%{_sysconfdir}/rc.d 28 rmdir %{buildroot}/%{_sysconfdir}/default 29 rm -Rf %{buildroot}%{_datadir}/doc/%{name} 30 -sed -i s@default@sysconfig@g %{buildroot}/%{_sysconfdir}/init.d/%{name} 31 +# this was used with original init script 32 +#sed -i s@default@sysconfig@g %{buildroot}/%{_sysconfdir}/init.d/%{name} 33 +# replace original init script with Source2 34 +%{__install} -m 755 %{S:2} %{buildroot}/%{_sysconfdir}/init.d/%{name} 35 # match entrys in config file 36 mkdir -p %{buildroot}/var/log/%{name} 37 mkdir -p %{buildroot}/var/lib/%{name} 38
39 # Create `couchdb' user on the system if necessary 40 if /usr/bin/id %{name} > /dev/null 2>&1 ; then 41 : # user already exists 42 + /usr/sbin/usermod -d -d %{_localstatedir}/lib/%{name} -g www -s /bin/bash %{name} || \ 43 + %nnmmsg Unexpected error changing user "%{name}". Aborting update process. 44 else 45 - /usr/sbin/useradd -r -d %{_datadir}/%{name} -g www -s /bin/bash -c "CouchDB" %{name} || \ 46 + /usr/sbin/useradd -r -d %{_localstatedir}/lib/%{name} -g www -s /bin/bash -c "CouchDB" %{name} || \ 47 %nnmmsg Unexpected error adding user "%{name}". Aborting install process. 48 fi 49 50
51 %dir /var/lib/%{name} 52 53 %changelog 54 +* Thu Mar 27 2008 Carsten Schoene <cs@linux-administrator.com> 55 +- fix postun 56 +- replace init script 57 +- changed couchdb users homedir 58 + 59 * Fri Mar 21 2008 Carsten Schoene <cs@linux-administrator.com> 60 - initial svn build 61 |
||
[+] | Added | couchdb.suse.init ^ |
@@ -0,0 +1,169 @@ +#!/bin/sh -e + +# etc/init/couchdb.tpl. Generated from couchdb.tpl.in by configure. + +# 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/bin/couchdb +CONFIGURATION_FILE=/etc/sysconfig/couchdb + +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 +} + +start_couchdb () { + # Start Apache CouchDB as a background process. + + command="$COUCHDB -b" + if test -n "$COUCHDB_INI_FILE"; then + command="$command -c $COUCHDB_INI_FILE" + fi + if test -n "$COUCHDB_PID_FILE"; then + command="$command -p $COUCHDB_PID_FILE" + fi + 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_USER"; then + if test -n "$COUCHDB_PID_FILE"; then + touch $COUCHDB_PID_FILE + chown $COUCHDB_USER $COUCHDB_PID_FILE + fi + 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_PID_FILE"; then + command="$command -p $COUCHDB_PID_FILE" + 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 $@ |