Package: sphinxsearch
Version: 2.0.1-2
Severity: minor

Current init script consists of repeating parts and have error with
reload action - it misses "--chuid sphinxsearch" option to
start-stop-daemon.

I've reorganized script to make it call functions for start/stop
actions. Also, I've changed exit code if template was not found, as
init script should exit with 0 status only on successfull start.

Patch is included.

-- System Information:
Debian Release: 6.0.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-openvz-amd64 (SMP w/24 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- sphinxsearch-2.0.3/debian/init.d    2011-12-01 21:41:08.000000000 +0400
+++ /home/coolcold/sphinxsearch 2012-01-18 16:01:56.320144034 +0400
@@ -82,7 +82,7 @@
     return 0
 }
 
-force_stop() {
+do_force_stop() {
 # Forcefully kill the process
     [ ! -f "$PIDFILE" ] && return
     if running ; then
@@ -101,21 +101,27 @@
     rm -f $PIDFILE
     return 0
 }
-
-case "$1" in
-  start)
-        echo -n "Starting $DESC: "
-
+do_start() {
         # Check if we have the configuration file
         if [ ! -f /etc/sphinxsearch/sphinx.conf ]; then
             echo "\n"
             echo "Please create an /etc/sphinxsearch/sphinx.conf configuration 
file."
             echo "A template is provided as 
/etc/sphinxsearch/sphinx.conf.sample."
-            exit 0
+            exit 1
         fi
 
         start-stop-daemon --start --pidfile $PIDFILE --chuid sphinxsearch 
--exec ${DAEMON}
-       [ -n "$STARTDELAY" ] && sleep $STARTDELAY
+}
+do_stop() {
+        start-stop-daemon --stop --quiet --oknodo --user sphinxsearch 
--pidfile $PIDFILE \
+            --exec $DAEMON
+}
+
+case "$1" in
+  start)
+        echo -n "Starting $DESC: "
+        do_start
+        [ -n "$STARTDELAY" ] && sleep $STARTDELAY
 
         if running ; then
             echo "$NAME."
@@ -125,13 +131,12 @@
         ;;
   stop)
         echo -n "Stopping $DESC: "
-        start-stop-daemon --stop --quiet --oknodo --user sphinxsearch 
--pidfile $PIDFILE \
-            --exec $DAEMON
+        do_stop
         echo "$NAME."
         ;;
   force-stop)
         echo -n "Forcefully stopping $DESC: "
-        force_stop
+        do_force_stop
         if ! running ; then
             echo "$NAME."
         else
@@ -140,10 +145,9 @@
         ;;
   restart|reload|force-reload)
     echo -n "Restarting $DESC: "
-        start-stop-daemon --stop --quiet --user sphinxsearch --oknodo 
--pidfile $PIDFILE \
-            --exec $DAEMON
+        do_stop
         [ -n "$DODTIME" ] && sleep $DODTIME
-        start-stop-daemon --start --exec ${DAEMON}
+        do_start
         echo "$NAME."
         ;;
 

Reply via email to