From 589cb88d57a727f6a7fa2f30328862b4e51f7966 Mon Sep 17 00:00:00 2001 From: "Sam Bisbee (icehouse)" Date: Wed, 1 Sep 2010 17:07:52 +0000 Subject: [PATCH 01/22] First pass at making the init file more system independent (still LSB). --- src/main/tools/etc/init.d/couchdb-lucene | 190 ++++++++++------------- 1 file changed, 80 insertions(+), 110 deletions(-) diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index d792a37d..a88ec605 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -9,21 +9,22 @@ # Description: Initscript for CouchDB-Lucene ### END INIT INFO -# Author: Sebastian Cohnen -# - # Do NOT "set -e" +SCRIPT_OK=0 +SCRIPT_ERROR=1 + PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="Description of the service" +DESC="CouchDB Lucene index" NAME="couchdb-lucene" DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run -PIDFILE=/var/run/$NAME.pid +PIDFILE=/var/run/$NAME/$NAME.pid DAEMON_ARGS="$PIDFILE" -SCRIPTNAME=/etc/init.d/$NAME +SCRIPTNAME=`basename $0` +LSB_LIBRARY=/lib/lsb/init-functions # Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 +[ -x "$DAEMON" ] || exit $SCRIPT_ERROR # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME @@ -31,27 +32,25 @@ SCRIPTNAME=/etc/init.d/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions +# We use LSB, so require that we can find the lib. +[ ! -r $LSB_LIBRARY ] && echo "$NAME cannot find the LSB functions! Did you set LSB_LIBRARY?" && exit $SCRIPT_ERROR + +. $LSB_LIBRARY # # Function that starts the daemon/service # do_start() { - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 - # Add code here, if necessary, that waits for the process to be ready - # to handle requests from services started subsequently which depend - # on this one. As a last resort, sleep for some time. + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 } # @@ -59,102 +58,73 @@ do_start() # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# -# Function that sends a SIGHUP to the daemon/service -# -do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" } case "$1" in start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) - #status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - if [ ! -f $PIDFILE -o ! -d /proc/`cat $PIDFILE` ] - then - log_failure_msg "$NAME is not running" - else - log_success_msg "$NAME is running" - fi - ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; + status_of_proc "$DAEMON" "$NAME" && exit $SCRIPT_OK || exit $? + ;; + restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg $SCRIPT_OK ;; + 1) log_end_msg $SCRIPT_ERROR ;; # Old process is still running + *) log_end_msg $SCRIPT_ERROR ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg $SCRIPT_ERROR + ;; + esac + ;; + *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; esac : From c621d0ed9271d4ee954088c472bfdbd9d639a125 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 18:51:28 +0000 Subject: [PATCH 02/22] Rewriting the run binary to deal with its life better. --- src/main/bin/run | 74 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/src/main/bin/run b/src/main/bin/run index c4a210fe..84d01cdc 100644 --- a/src/main/bin/run +++ b/src/main/bin/run @@ -1,20 +1,66 @@ #!/bin/sh +BACKGROUND=false #whether to run in the background or not +STDOUT_FILE="" #where to send background stdout to (defaults to &1) + +SCRIPT_OK=0 +SCRIPT_ERROR=1 + +start() +{ + JAVA_OPTS="-server -Xmx1g" + CLASS="com.github.rnewson.couchdb.lucene.Main" + + CLASSPATH="conf" + for JAR in `ls lib/*.jar` + do + CLASSPATH="$CLASSPATH:$JAR" + done + + command="java $JAVA_OPTS -cp $CLASSPATH $CLASS" + + if [ "$BACKGROUND" != "true" ] + then + eval $command + else + [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE" + + eval "$command &" + echo $? > $PID_FILE + fi +} + +checkEnvironment() +{ + prepend="couchdb-lucene needs read access to" + [ ! -w $STDOUT_FILE ] && echo "$prepend output file $STDOUT_FILE" && exit $SCRIPT_ERROR + unset prepend + + # Don't overwrite an existing pid file path - it's probably from init. + [ -z "$PID_FILE" ] && PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" +} + +parseOptions() +{ + opts=`getopt o:hb $@` + set -- $opts + while [ $# -gt 0 ] + do + case "$1" in + -h) shift; printUsage; exit $SCRIPT_OK;; + -o) shift; STDOUT_FILE="$1"; shift;; + -b) shift; BACKGROUND=true;; + --) shift; break;; + *) echo "Unknown option: $1" >&2; exit $SCRIPT_ERROR;; + esac + done +} + +parseOptions $@ +checkEnvironment + [ -z $CL_BASEDIR ] && CL_BASEDIR=`dirname "$0"` cd $CL_BASEDIR/.. -JAVA_OPTS="-server -Xmx1g" -CLASS=com.github.rnewson.couchdb.lucene.Main +start -CLASSPATH="conf" -for JAR in `ls lib/*.jar` -do - CLASSPATH="$CLASSPATH:$JAR" -done - -if [ -z $PIDFILE ]; then - exec java $JAVA_OPTS -cp $CLASSPATH $CLASS -else - java $JAVA_OPTS -cp $CLASSPATH $CLASS & - echo $! > $PIDFILE -fi From 5bf88e7a3f6b406cdf18d2d8437b0a46afb55137 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 20:08:51 +0000 Subject: [PATCH 03/22] fixing typo --- src/main/bin/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bin/run b/src/main/bin/run index 84d01cdc..aedc0515 100644 --- a/src/main/bin/run +++ b/src/main/bin/run @@ -32,7 +32,7 @@ start() checkEnvironment() { - prepend="couchdb-lucene needs read access to" + prepend="couchdb-lucene needs write access to" [ ! -w $STDOUT_FILE ] && echo "$prepend output file $STDOUT_FILE" && exit $SCRIPT_ERROR unset prepend From c307979b425d9922cc3f06eb7f2fccd266d7459f Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 20:45:41 +0000 Subject: [PATCH 04/22] Fixing wrong value to pid file --- src/main/bin/run | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/bin/run b/src/main/bin/run index aedc0515..f45c0e47 100644 --- a/src/main/bin/run +++ b/src/main/bin/run @@ -2,6 +2,7 @@ BACKGROUND=false #whether to run in the background or not STDOUT_FILE="" #where to send background stdout to (defaults to &1) +PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" SCRIPT_OK=0 SCRIPT_ERROR=1 @@ -26,7 +27,7 @@ start() [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE" eval "$command &" - echo $? > $PID_FILE + echo $! > $PID_FILE fi } @@ -35,9 +36,6 @@ checkEnvironment() prepend="couchdb-lucene needs write access to" [ ! -w $STDOUT_FILE ] && echo "$prepend output file $STDOUT_FILE" && exit $SCRIPT_ERROR unset prepend - - # Don't overwrite an existing pid file path - it's probably from init. - [ -z "$PID_FILE" ] && PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" } parseOptions() From 0b9cf6dfca6ce1c0519f9cd0bdc89847fd31b558 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 20:57:50 +0000 Subject: [PATCH 05/22] Prevent start if the pid file is there. --- src/main/bin/run | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/main/bin/run diff --git a/src/main/bin/run b/src/main/bin/run old mode 100644 new mode 100755 index f45c0e47..9cdd90de --- a/src/main/bin/run +++ b/src/main/bin/run @@ -1,5 +1,6 @@ #!/bin/sh +NAME="couchdb-lucene" BACKGROUND=false #whether to run in the background or not STDOUT_FILE="" #where to send background stdout to (defaults to &1) PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" @@ -7,6 +8,12 @@ PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" SCRIPT_OK=0 SCRIPT_ERROR=1 +getPid() +{ + [ -f $PID_FILE ] && PID=`cat $PID_FILE` + echo $PID +} + start() { JAVA_OPTS="-server -Xmx1g" @@ -24,10 +31,17 @@ start() then eval $command else - [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE" + PID=`getPid` + + if [ -z "$PID" ] + then + [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE" - eval "$command &" - echo $! > $PID_FILE + eval "$command &" + echo $! > $PID_FILE + else + echo "$NAME is already running ($PID_FILE)." + fi fi } From a082b153ac66d209da554cd30f8136a6c477d55e Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 21:07:03 +0000 Subject: [PATCH 06/22] Making some LSB codes more explicit with variables --- src/main/tools/etc/init.d/couchdb-lucene | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index a88ec605..3b1aabdd 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -13,6 +13,8 @@ SCRIPT_OK=0 SCRIPT_ERROR=1 +SCRIPT_ERROR_NOT_IMPLEMENTED=3 +SCRIPT_ERROR_NOT_INSTALLED=5 PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="CouchDB Lucene index" @@ -24,7 +26,7 @@ SCRIPTNAME=`basename $0` LSB_LIBRARY=/lib/lsb/init-functions # Exit if the package is not installed -[ -x "$DAEMON" ] || exit $SCRIPT_ERROR +[ -x "$DAEMON" ] || exit $SCRIPT_ERROR_NOT_INSTALLED # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME @@ -123,7 +125,7 @@ case "$1" in *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 + exit $SCRIPT_ERROR_NOT_IMPLEMENTED ;; esac From 4100865bc405676e123c23d1ac36b15bfcdc4a34 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 21:12:20 +0000 Subject: [PATCH 07/22] Fixing start code --- src/main/tools/etc/init.d/couchdb-lucene | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index 3b1aabdd..55e3a22f 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -48,11 +48,8 @@ do_start() # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started - PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - PIDFILE=$PIDFILE start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2 } # From 08c015076c0a196effa129d97f2a579b13c76600 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 21:18:13 +0000 Subject: [PATCH 08/22] Fixing var order --- src/main/bin/run | 2 +- src/main/tools/etc/init.d/couchdb-lucene | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/bin/run b/src/main/bin/run index 9cdd90de..14b79972 100755 --- a/src/main/bin/run +++ b/src/main/bin/run @@ -3,7 +3,7 @@ NAME="couchdb-lucene" BACKGROUND=false #whether to run in the background or not STDOUT_FILE="" #where to send background stdout to (defaults to &1) -PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid" +PID_FILE=/var/run/couchdb-lucene/couchdb-lucene.pid SCRIPT_OK=0 SCRIPT_ERROR=1 diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index 55e3a22f..625d7db7 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -19,9 +19,9 @@ SCRIPT_ERROR_NOT_INSTALLED=5 PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="CouchDB Lucene index" NAME="couchdb-lucene" -DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run PIDFILE=/var/run/$NAME/$NAME.pid -DAEMON_ARGS="$PIDFILE" +DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run +DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b" SCRIPTNAME=`basename $0` LSB_LIBRARY=/lib/lsb/init-functions From 97a9e8529735a237e234d19f7a257d184ddd1e9a Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Wed, 1 Sep 2010 17:36:30 -0400 Subject: [PATCH 09/22] Adding the usage output --- src/main/bin/run | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/bin/run b/src/main/bin/run index 14b79972..fe055a6d 100755 --- a/src/main/bin/run +++ b/src/main/bin/run @@ -8,6 +8,23 @@ PID_FILE=/var/run/couchdb-lucene/couchdb-lucene.pid SCRIPT_OK=0 SCRIPT_ERROR=1 +printUsage() +{ + cat << EOF +Usage: `$basename $0` [OPTIONS] + +Starts the couchdb-lucene server component. + +Options: + + -h displays this short help message and exits + + -b spawn as a background process + -o FILE redirect background process's stdout to FILE (defaults to none) + -p FILE set the background process's PID FILE +EOF +} + getPid() { [ -f $PID_FILE ] && PID=`cat $PID_FILE` From cb00be87930f64ee5a2b7a9a7301e0a8f0a4e969 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 21:51:27 -0400 Subject: [PATCH 10/22] Adding to thanks file --- THANKS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/THANKS.md b/THANKS.md index 2d261c6e..2a098d89 100644 --- a/THANKS.md +++ b/THANKS.md @@ -2,3 +2,4 @@ * Thanks to Paul Davis for contributing the enhanced Javascript indexing API. * Thanks to Adam Lofts for the performance boosting JSONDocumentAdapter et al. * Thanks to Santiago M. Mola for the termvector option. +* Thanks to Sam Bisbee. From e4ae3e207d1b65603e941a92c6ef19bbeb9af5ab Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:04:06 -0400 Subject: [PATCH 11/22] Rearranging package format to match the *nix file structure. --- src/main/assembly/dist.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index 3502f37c..71d9736d 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -11,7 +11,7 @@ ${project.basedir}/LICENSE* ${project.basedir}/NOTICE* - / + /share/doc/couchdb-lucene @@ -23,28 +23,28 @@ ${project.basedir}/src/main/conf/couchdb-lucene.ini 644 - /conf + /etc/couchdb-lucene ${project.basedir}/src/main/conf/log4j.xml 644 - /conf + /etc/couchdb-lucene ${project.basedir}/couchdb-external-hook.py 755 - /tools + /bin ${project.basedir}/src/main/tools/etc/init.d/couchdb-lucene 755 - /tools/etc/init.d/couchdb-lucene + /etc/init.d runtime - /lib + /lib/couchdb-lucene From dba9760904e4245a299f3e1fcff49e9dfaeb083b Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:06:56 -0400 Subject: [PATCH 12/22] Adding the other doc files to the package. --- src/main/assembly/dist.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index 71d9736d..f6e14dba 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -10,6 +10,9 @@ ${project.basedir}/README* ${project.basedir}/LICENSE* ${project.basedir}/NOTICE* + ${project.basedir}/BREAKING_CHANGES* + ${project.basedir}/TODO* + ${project.basedir}/THANKS* /share/doc/couchdb-lucene From a71a89edae0841897b61d2be0f9bbae6d917ad75 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:11:16 -0400 Subject: [PATCH 13/22] Renaming the binary, and updating the init file accordingly --- src/main/bin/{run => couchdb-lucene} | 0 src/main/tools/etc/init.d/couchdb-lucene | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/bin/{run => couchdb-lucene} (100%) diff --git a/src/main/bin/run b/src/main/bin/couchdb-lucene similarity index 100% rename from src/main/bin/run rename to src/main/bin/couchdb-lucene diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index 625d7db7..e86c1dab 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -20,7 +20,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="CouchDB Lucene index" NAME="couchdb-lucene" PIDFILE=/var/run/$NAME/$NAME.pid -DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run +DAEMON=$NAME DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b" SCRIPTNAME=`basename $0` LSB_LIBRARY=/lib/lsb/init-functions From c9a76e244875b08190e9a006b2129f45c9e8428e Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:14:14 -0400 Subject: [PATCH 14/22] Shouldn't overwrite PATH. --- src/main/tools/etc/init.d/couchdb-lucene | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index e86c1dab..68485e75 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -16,7 +16,6 @@ SCRIPT_ERROR=1 SCRIPT_ERROR_NOT_IMPLEMENTED=3 SCRIPT_ERROR_NOT_INSTALLED=5 -PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="CouchDB Lucene index" NAME="couchdb-lucene" PIDFILE=/var/run/$NAME/$NAME.pid From 49a369d75b93be91a1838fee4f894ffeee14f65b Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:21:55 -0400 Subject: [PATCH 15/22] Fixing the assembly file from the shell script rename. --- src/main/assembly/dist.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index f6e14dba..89f7c468 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -19,7 +19,7 @@ - ${project.basedir}/src/main/bin/run + ${project.basedir}/src/main/bin/couchdb-lucene 755 /bin From 717db0fa5d2e917de758f0dec2f6b3f8e9e881f3 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 21 Sep 2010 22:24:40 -0400 Subject: [PATCH 16/22] Implementing the -p PID file arg and using in the init file. --- src/main/bin/couchdb-lucene | 1 + src/main/tools/etc/init.d/couchdb-lucene | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/bin/couchdb-lucene b/src/main/bin/couchdb-lucene index fe055a6d..c1b55d6d 100755 --- a/src/main/bin/couchdb-lucene +++ b/src/main/bin/couchdb-lucene @@ -79,6 +79,7 @@ parseOptions() -h) shift; printUsage; exit $SCRIPT_OK;; -o) shift; STDOUT_FILE="$1"; shift;; -b) shift; BACKGROUND=true;; + -p) shift; PID_FILE="$1"; shift;; --) shift; break;; *) echo "Unknown option: $1" >&2; exit $SCRIPT_ERROR;; esac diff --git a/src/main/tools/etc/init.d/couchdb-lucene b/src/main/tools/etc/init.d/couchdb-lucene index 68485e75..5cf4033f 100644 --- a/src/main/tools/etc/init.d/couchdb-lucene +++ b/src/main/tools/etc/init.d/couchdb-lucene @@ -20,7 +20,7 @@ DESC="CouchDB Lucene index" NAME="couchdb-lucene" PIDFILE=/var/run/$NAME/$NAME.pid DAEMON=$NAME -DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b" +DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b -p $PIDFILE" SCRIPTNAME=`basename $0` LSB_LIBRARY=/lib/lsb/init-functions From fa35de38e9a387afb135dce5daa8163a24385243 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Mon, 27 Sep 2010 17:48:14 +0000 Subject: [PATCH 17/22] Forgot to tell getopts to parse the -p arg. --- src/main/bin/couchdb-lucene | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/bin/couchdb-lucene b/src/main/bin/couchdb-lucene index c1b55d6d..17ccd328 100755 --- a/src/main/bin/couchdb-lucene +++ b/src/main/bin/couchdb-lucene @@ -71,7 +71,7 @@ checkEnvironment() parseOptions() { - opts=`getopt o:hb $@` + opts=`getopt o:hbp: $@` set -- $opts while [ $# -gt 0 ] do From 05e02ddf0ed586bf0db83f1f70819dc8f9cae80f Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 28 Sep 2010 15:14:59 +0000 Subject: [PATCH 18/22] Adding the main class to the jar's manifest - we can now call by jar, not class. --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 9bf8446c..56058ec3 100644 --- a/pom.xml +++ b/pom.xml @@ -165,6 +165,7 @@ true true + com.github.rnewson.couchdb.lucene.Main From 3eb06a5dd5c9eb69dc8f237a63d6799b18cc8854 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 28 Sep 2010 15:26:41 +0000 Subject: [PATCH 19/22] Changing how we create the CLASSPATH to play friendlier with our new package layout. --- src/main/bin/couchdb-lucene | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/bin/couchdb-lucene b/src/main/bin/couchdb-lucene index 17ccd328..26832073 100755 --- a/src/main/bin/couchdb-lucene +++ b/src/main/bin/couchdb-lucene @@ -33,16 +33,10 @@ getPid() start() { - JAVA_OPTS="-server -Xmx1g" - CLASS="com.github.rnewson.couchdb.lucene.Main" + CLASSPATH="$CL_BASEDIR/etc/couchdb-lucene:$CL_BASEDIR/lib/couchdb-lucene/*" + JAVA_OPTS="-server -Xmx1g -cp $CLASSPATH" - CLASSPATH="conf" - for JAR in `ls lib/*.jar` - do - CLASSPATH="$CLASSPATH:$JAR" - done - - command="java $JAVA_OPTS -cp $CLASSPATH $CLASS" + command="java $JAVA_OPTS $JAR com.github.rnewson.couchdb.lucene.Main" if [ "$BACKGROUND" != "true" ] then @@ -89,8 +83,8 @@ parseOptions() parseOptions $@ checkEnvironment -[ -z $CL_BASEDIR ] && CL_BASEDIR=`dirname "$0"` -cd $CL_BASEDIR/.. +[ -z $CL_BASEDIR ] && CL_BASEDIR=`dirname "$0"`"/.." +cd $CL_BASEDIR start From 87395a73968275679bcac8063077e772870825d4 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 28 Sep 2010 17:20:42 +0000 Subject: [PATCH 20/22] Prevent the indexes from being written to the jar or wrapper's cwd. --- src/main/conf/couchdb-lucene.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/conf/couchdb-lucene.ini b/src/main/conf/couchdb-lucene.ini index 23e8826e..09b6603f 100644 --- a/src/main/conf/couchdb-lucene.ini +++ b/src/main/conf/couchdb-lucene.ini @@ -1,6 +1,6 @@ [lucene] # The output directory for Lucene indexes. -dir=indexes +dir=/var/lib/couchdb-lucene/indexes # The local host name that couchdb-lucene binds to host=localhost From 0a413b91c3b0463621c88340ae5785c7ba699bf9 Mon Sep 17 00:00:00 2001 From: Sam Bisbee Date: Tue, 28 Sep 2010 17:46:39 +0000 Subject: [PATCH 21/22] Put documentation in usr/share/doc/couchdb-lucene --- src/main/assembly/dist.xml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index 89f7c468..e83d23a3 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -6,15 +6,16 @@ + ${project.basedir} + /usr/share/doc/couchdb-lucene - ${project.basedir}/README* - ${project.basedir}/LICENSE* - ${project.basedir}/NOTICE* - ${project.basedir}/BREAKING_CHANGES* - ${project.basedir}/TODO* - ${project.basedir}/THANKS* + README* + LICENSE* + NOTICE* + BREAKING_CHANGES* + TODO* + THANKS* - /share/doc/couchdb-lucene From 2988b7ad74e3c0c3ae48ecaebcaf7de684100bda Mon Sep 17 00:00:00 2001 From: Tim Kuijsten Date: Wed, 21 Dec 2011 15:27:31 +0100 Subject: [PATCH 22/22] support for configurable root directories destRootDir destVarDir destVarLibDir destEtcDir destBinDir destDocDir example: mvn -DdestRootDir="" -DdestDocDir="/usr/local/share" --- pom.xml | 7 +++++++ src/main/assembly/dist.xml | 16 ++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 79ad5f39..5aed387b 100644 --- a/pom.xml +++ b/pom.xml @@ -110,6 +110,13 @@ 1.0 6.1.20 4.0.1 + default + /usr/local + ${destRootDir}/var + ${destVarDir}/lib + ${destRootDir}/etc + ${destRootDir}/bin + ${destRootDir}/share/doc github diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index e53b81f7..596ccb2e 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -7,7 +7,7 @@ ${project.basedir} - /usr/share/doc/couchdb-lucene + ${destDocDir}/couchdb-lucene README* LICENSE* @@ -22,38 +22,38 @@ ${project.basedir}/src/main/bin/couchdb-lucene 755 - /usr/local/bin + ${destBinDir} ${project.basedir}/src/main/bin/kill_ppid 755 - /usr/local/bin + ${destVarLibDir}/couchdb-lucene ${project.basedir}/src/main/resources/couchdb-lucene.ini 644 - /etc/couchdb-lucene + ${destEtcDir}/couchdb-lucene ${project.basedir}/src/main/resources/log4j.xml 644 - /etc/couchdb-lucene + ${destEtcDir}/couchdb-lucene ${project.basedir}/couchdb-external-hook.py 755 - /usr/local/bin + ${destBinDir} ${project.basedir}/src/main/tools/etc/init.d/couchdb-lucene 755 - /etc/init.d + ${destEtcDir}/init.d runtime - /lib/couchdb-lucene + ${destVarLibDir}/couchdb-lucene