Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

merge sbisbee's work + configurable root dirs #148

Open
wants to merge 23 commits into from

3 participants

@timkuijsten

use configurable root dirs, default to /usr/local

sbisbee and others added some commits
@sbisbee sbisbee First pass at making the init file more system independent (still LSB). 589cb88
@sbisbee sbisbee Rewriting the run binary to deal with its life better. c621d0e
@sbisbee sbisbee fixing typo 5bf88e7
@sbisbee sbisbee Fixing wrong value to pid file c307979
@sbisbee sbisbee Prevent start if the pid file is there. 0b9cf6d
@sbisbee sbisbee Making some LSB codes more explicit with variables a082b15
@sbisbee sbisbee Fixing start code 4100865
@sbisbee sbisbee Fixing var order 08c0150
@sbisbee sbisbee Adding the usage output 97a9e85
@sbisbee sbisbee Adding to thanks file cb00be8
@sbisbee sbisbee Rearranging package format to match the *nix file structure. e4ae3e2
@sbisbee sbisbee Adding the other doc files to the package. dba9760
@sbisbee sbisbee Renaming the binary, and updating the init file accordingly a71a89e
@sbisbee sbisbee Shouldn't overwrite PATH. c9a76e2
@sbisbee sbisbee Fixing the assembly file from the shell script rename. 49a369d
@sbisbee sbisbee Implementing the -p PID file arg and using in the init file. 717db0f
@sbisbee sbisbee Forgot to tell getopts to parse the -p arg. fa35de3
@sbisbee sbisbee Adding the main class to the jar's manifest - we can now call by jar,…
… not class.
05e02dd
@sbisbee sbisbee Changing how we create the CLASSPATH to play friendlier with our new …
…package layout.
3eb06a5
@sbisbee sbisbee Prevent the indexes from being written to the jar or wrapper's cwd. 87395a7
@sbisbee sbisbee Put documentation in usr/share/doc/couchdb-lucene 0a413b9
@timkuijsten timkuijsten Merge remote branch 'sbisbee/master' into ubuntu
Conflicts:
	THANKS.md
	src/main/assembly/dist.xml
	src/main/bin/run
692ecd0
@timkuijsten timkuijsten support for configurable root directories
destRootDir
destVarDir
destVarLibDir
destEtcDir
destBinDir
destDocDir

example: mvn -DdestRootDir="" -DdestDocDir="/usr/local/share"
2988b7a
@timkuijsten

Succesfully built on Ubuntu Server 10.04 amd64 with: mvn -DdestRootDir="" -DdestDocDir="/usr/local/share" -DdestBinDir="/usr/local/bin"

@timkuijsten

but i do see some runtime errors now:
/usr/local/couchdb-lucene-0.8.0-SNAPSHOT$ ./usr/local/bin/couchdb-lucene
Exception in thread "main" java.lang.NoClassDefFoundError: com/github/rnewson/couchdb/lucene/Main
Caused by: java.lang.ClassNotFoundException: com.github.rnewson.couchdb.lucene.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: com.github.rnewson.couchdb.lucene.Main. Program will exit.

Have to investigate..

@rnewson rnewson commented on the diff
THANKS.md
@@ -2,3 +2,4 @@
* Thanks to Adam Lofts for the performance boosting JSONDocumentAdapter et al.
* Thanks to Santiago M. Mola for the termvector option.
* Thanks to Joe Hillenbrand for adding default result limit to config.
+* Thanks to Sam Bisbee.
@rnewson Owner
rnewson added a note

You should add yourself too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
@@ -110,6 +110,13 @@
<tika-version>1.0</tika-version>
<jetty-version>6.1.20</jetty-version>
<http-version>4.0.1</http-version>
+ <env>default</env>
+ <destRootDir>/usr/local</destRootDir>
+ <destVarDir>${destRootDir}/var</destVarDir>
+ <destVarLibDir>${destVarDir}/lib</destVarLibDir>
+ <destEtcDir>${destRootDir}/etc</destEtcDir>
+ <destBinDir>${destRootDir}/bin</destBinDir>
+ <destDocDir>${destRootDir}/share/doc</destDocDir>
@rnewson Owner
rnewson added a note

I'd keep destRootDir and to do the /var etc thing where it's used. The abstraction here isn't useful as these variables almost never vary. It's only the top-level that is altered and {root}/etc, {root}/bin are assumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/assembly/dist.xml
((24 lines not shown))
<fileMode>755</fileMode>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>${destBinDir}</outputDirectory>
@rnewson Owner
rnewson added a note

i.e, ${destRootDir}/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/bin/couchdb-lucene
@@ -0,0 +1,90 @@
+#!/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
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/resources/couchdb-lucene.ini
@@ -1,6 +1,6 @@
[lucene]
# The output directory for Lucene indexes.
-dir=indexes
+dir=/var/lib/couchdb-lucene/indexes
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/tools/etc/init.d/couchdb-lucene
((17 lines not shown))
NAME="couchdb-lucene"
-DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="$PIDFILE"
-SCRIPTNAME=/etc/init.d/$NAME
+PIDFILE=/var/run/$NAME/$NAME.pid
+DAEMON=$NAME
+DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b -p $PIDFILE"
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/tools/etc/init.d/couchdb-lucene
((17 lines not shown))
NAME="couchdb-lucene"
-DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="$PIDFILE"
-SCRIPTNAME=/etc/init.d/$NAME
+PIDFILE=/var/run/$NAME/$NAME.pid
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rnewson rnewson commented on the diff
src/main/tools/etc/init.d/couchdb-lucene
((17 lines not shown))
NAME="couchdb-lucene"
-DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="$PIDFILE"
-SCRIPTNAME=/etc/init.d/$NAME
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 1, 2010
  1. @sbisbee
  2. @sbisbee
  3. @sbisbee

    fixing typo

    sbisbee authored
  4. @sbisbee
  5. @sbisbee
  6. @sbisbee
  7. @sbisbee

    Fixing start code

    sbisbee authored
  8. @sbisbee

    Fixing var order

    sbisbee authored
  9. @sbisbee

    Adding the usage output

    sbisbee authored
Commits on Sep 22, 2010
  1. @sbisbee

    Adding to thanks file

    sbisbee authored
  2. @sbisbee
  3. @sbisbee
  4. @sbisbee
  5. @sbisbee

    Shouldn't overwrite PATH.

    sbisbee authored
  6. @sbisbee
  7. @sbisbee
Commits on Sep 28, 2010
  1. @sbisbee
  2. @sbisbee
  3. @sbisbee
  4. @sbisbee
  5. @sbisbee
Commits on Dec 21, 2011
  1. @timkuijsten

    Merge remote branch 'sbisbee/master' into ubuntu

    timkuijsten authored
    Conflicts:
    	THANKS.md
    	src/main/assembly/dist.xml
    	src/main/bin/run
  2. @timkuijsten

    support for configurable root directories

    timkuijsten authored
    destRootDir
    destVarDir
    destVarLibDir
    destEtcDir
    destBinDir
    destDocDir
    
    example: mvn -DdestRootDir="" -DdestDocDir="/usr/local/share"
This page is out of date. Refresh to see the latest.
View
1  THANKS.md
@@ -2,3 +2,4 @@
* Thanks to Adam Lofts for the performance boosting JSONDocumentAdapter et al.
* Thanks to Santiago M. Mola for the termvector option.
* Thanks to Joe Hillenbrand for adding default result limit to config.
+* Thanks to Sam Bisbee.
@rnewson Owner
rnewson added a note

You should add yourself too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
8 pom.xml
@@ -110,6 +110,13 @@
<tika-version>1.0</tika-version>
<jetty-version>6.1.20</jetty-version>
<http-version>4.0.1</http-version>
+ <env>default</env>
+ <destRootDir>/usr/local</destRootDir>
+ <destVarDir>${destRootDir}/var</destVarDir>
+ <destVarLibDir>${destVarDir}/lib</destVarLibDir>
+ <destEtcDir>${destRootDir}/etc</destEtcDir>
+ <destBinDir>${destRootDir}/bin</destBinDir>
+ <destDocDir>${destRootDir}/share/doc</destDocDir>
@rnewson Owner
rnewson added a note

I'd keep destRootDir and to do the /var etc thing where it's used. The abstraction here isn't useful as these variables almost never vary. It's only the top-level that is altered and {root}/etc, {root}/bin are assumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
</properties>
<issueManagement>
<system>github</system>
@@ -179,6 +186,7 @@
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <mainClass>com.github.rnewson.couchdb.lucene.Main</mainClass>
</manifest>
</archive>
</configuration>
View
30 src/main/assembly/dist.xml
@@ -6,50 +6,54 @@
</formats>
<fileSets>
<fileSet>
+ <directory>${project.basedir}</directory>
+ <outputDirectory>${destDocDir}/couchdb-lucene</outputDirectory>
<includes>
- <include>${project.basedir}/README*</include>
- <include>${project.basedir}/LICENSE*</include>
- <include>${project.basedir}/NOTICE*</include>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>BREAKING_CHANGES*</include>
+ <include>TODO*</include>
+ <include>THANKS*</include>
</includes>
- <outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
- <source>${project.basedir}/src/main/bin/run</source>
+ <source>${project.basedir}/src/main/bin/couchdb-lucene</source>
<fileMode>755</fileMode>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>${destBinDir}</outputDirectory>
@rnewson Owner
rnewson added a note

i.e, ${destRootDir}/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
</file>
<file>
<source>${project.basedir}/src/main/bin/kill_ppid</source>
<fileMode>755</fileMode>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>${destVarLibDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/resources/couchdb-lucene.ini</source>
<fileMode>644</fileMode>
- <outputDirectory>/conf</outputDirectory>
+ <outputDirectory>${destEtcDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/resources/log4j.xml</source>
<fileMode>644</fileMode>
- <outputDirectory>/conf</outputDirectory>
+ <outputDirectory>${destEtcDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/couchdb-external-hook.py</source>
- <fileMode>777</fileMode>
- <outputDirectory>/tools</outputDirectory>
+ <fileMode>755</fileMode>
+ <outputDirectory>${destBinDir}</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/tools/etc/init.d/couchdb-lucene</source>
<fileMode>755</fileMode>
- <outputDirectory>/tools/etc/init.d/couchdb-lucene</outputDirectory>
+ <outputDirectory>${destEtcDir}/init.d</outputDirectory>
</file>
</files>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
- <outputDirectory>/lib</outputDirectory>
+ <outputDirectory>${destVarLibDir}/couchdb-lucene</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
View
90 src/main/bin/couchdb-lucene
@@ -0,0 +1,90 @@
+#!/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
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+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`
+ echo $PID
+}
+
+start()
+{
+ CLASSPATH="$CL_BASEDIR/etc/couchdb-lucene:$CL_BASEDIR/lib/couchdb-lucene/*"
+ JAVA_OPTS="-server -Xmx1g -cp $CLASSPATH"
+
+ command="java $JAVA_OPTS $JAR com.github.rnewson.couchdb.lucene.Main"
+
+ if [ "$BACKGROUND" != "true" ]
+ then
+ eval $command
+ else
+ PID=`getPid`
+
+ if [ -z "$PID" ]
+ then
+ [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE"
+
+ eval "$command &"
+ echo $! > $PID_FILE
+ else
+ echo "$NAME is already running ($PID_FILE)."
+ fi
+ fi
+}
+
+checkEnvironment()
+{
+ prepend="couchdb-lucene needs write access to"
+ [ ! -w $STDOUT_FILE ] && echo "$prepend output file $STDOUT_FILE" && exit $SCRIPT_ERROR
+ unset prepend
+}
+
+parseOptions()
+{
+ opts=`getopt o:hbp: $@`
+ 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;;
+ -p) shift; PID_FILE="$1"; shift;;
+ --) shift; break;;
+ *) echo "Unknown option: $1" >&2; exit $SCRIPT_ERROR;;
+ esac
+ done
+}
+
+parseOptions $@
+checkEnvironment
+
+[ -z $CL_BASEDIR ] && CL_BASEDIR=`dirname "$0"`"/.."
+cd $CL_BASEDIR
+
+start
+
View
2  src/main/resources/couchdb-lucene.ini
@@ -1,6 +1,6 @@
[lucene]
# The output directory for Lucene indexes.
-dir=indexes
+dir=/var/lib/couchdb-lucene/indexes
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
# The local host name that couchdb-lucene binds to
host=localhost
View
194 src/main/tools/etc/init.d/couchdb-lucene
@@ -9,21 +9,23 @@
# Description: Initscript for CouchDB-Lucene
### END INIT INFO
-# Author: Sebastian Cohnen <sebastian.cohnen@gmail.com>
-#
-
# Do NOT "set -e"
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="Description of the service"
+SCRIPT_OK=0
+SCRIPT_ERROR=1
+SCRIPT_ERROR_NOT_IMPLEMENTED=3
+SCRIPT_ERROR_NOT_INSTALLED=5
+
+DESC="CouchDB Lucene index"
NAME="couchdb-lucene"
-DAEMON=/usr/local/couchdb-lucene-0.5.5/bin/run
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="$PIDFILE"
-SCRIPTNAME=/etc/init.d/$NAME
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+PIDFILE=/var/run/$NAME/$NAME.pid
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+DAEMON=$NAME
+DAEMON_ARGS="-o /var/log/couchdb-lucene.log -b -p $PIDFILE"
@rnewson Owner
rnewson added a note

This is absolute, but should be relative to ${destRootDir} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+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_NOT_INSTALLED
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
@@ -31,27 +33,22 @@ 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
+ 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
}
#
@@ -59,102 +56,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 $SCRIPT_ERROR_NOT_IMPLEMENTED
+ ;;
esac
:
Something went wrong with that request. Please try again.