]> git.pld-linux.org Git - packages/gearmand.git/commitdiff
pldize initscript
authorElan Ruusamäe <glen@delfi.ee>
Wed, 27 Jan 2016 21:57:26 +0000 (23:57 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Wed, 27 Jan 2016 21:57:26 +0000 (23:57 +0200)
gearmand.init [changed mode: 0644->0755]
gearmand.spec
gearmand.sysconfig

old mode 100644 (file)
new mode 100755 (executable)
index e2502aa..56142be
@@ -1,55 +1,79 @@
-#!/bin/bash
+#!/bin/sh
 #
 # gearmand        Startup script for the Gearman server
 #
-# chkconfig: - 85 15
+# chkconfig:   345 85 15
+#
 # description: Gearman is a distributed job system.
 # processname: gearmand
 # config: /etc/sysconfig/gearmand
 # pidfile: /var/run/gearmand/gearmand.pid
 #
-### BEGIN INIT INFO
-# Provides: gearmand
-# Required-Start: $local_fs $network
-# Required-Stop: $local_fs $network
-# Default-Start:
-# Default-Stop:
-# Short-Description: start and stop the Gearman server
-# Description: Gearman is a distributed job system.
-### END INIT INFO
 
-# Source function library.
+# Source function library
 . /etc/rc.d/init.d/functions
 
-if [ -f /etc/sysconfig/gearmand ]; then
-        . /etc/sysconfig/gearmand
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "Gearmand job server"
+               exit 1
+       fi
+else
+       exit 0
 fi
 
-[ -z "${PIDFILE}" ] && pidfile="/var/run/gearmand/gearmand.pid"
-[ -z "${LOCKFILE}" ] && lockfile="/var/lock/subsys/gearmand"
+# Set defaults
+OPTIONS=""
 
-gearmand=/usr/sbin/gearmand
-prog=gearmand
+# Get service config - may override defaults
+[ -f /etc/sysconfig/gearmand ] && . /etc/sysconfig/gearmand
 
-RETVAL=0
+pidfile="/var/run/gearmand.pid"
+lockfile="/var/lock/subsys/gearmand"
+gearmand="/usr/sbin/gearmand"
+procname="gearmand"
 
 start() {
-        echo -n $"Starting $prog: "
-        daemon --pidfile=$pidfile --user=gearmand $gearmand -d $OPTIONS
-        RETVAL=$?
-        echo
-        [ $RETVAL = 0 ] && (touch $lockfile; pgrep -f $gearmand > $pidfile)
-        return $RETVAL
+       # Check if the service is already running?
+       if [ -f $lockfile ]; then
+               msg_already_running "Gearmand job server"
+               return
+       fi
+
+       msg_starting "Gearmand job server"
+       daemon --pidfile $pidfile --user gearmand $gearmand -d $OPTIONS
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch $lockfile
 }
 
 stop() {
-       echo -n $"Stopping $prog: "
-       killproc -p $pidfile $gearmand
-       RETVAL=$?
-       echo
-       [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
+       if [ ! -f $lockfile ]; then
+               msg_not_running "Gearmand job server"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "Gearmand job server"
+       killproc --pidfile $pidfile $procname -TERM
+       rm -f $lockfile
+}
+
+condrestart() {
+       if [ ! -f $lockfile ]; then
+               msg_not_running "Gearmand job server"
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
 }
 
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
@@ -58,24 +82,23 @@ case "$1" in
   stop)
        stop
        ;;
-  status)
-        status -p $pidfile $gearmand
-       RETVAL=$?
-       ;;
-  restart|reload)
+  restart)
        stop
        start
        ;;
-  condrestart|try-restart)
-       if status -p $pidfile $gearmand >&/dev/null; then
-               stop
-               start
-       fi
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status --pidfile $pidfile $procname
+       RETVAL=$?
        ;;
   *)
-       echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
-       RETVAL=3
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
 esac
 
 exit $RETVAL
-
index a46c9507a5c3a6db91d8e5136ca364dc1b900526..8265d326236b2278077cf6ef4c952505c1a2c925 100644 (file)
@@ -63,7 +63,7 @@ Requires(pre):        /usr/bin/getgid
 Requires(pre): /usr/sbin/groupadd
 Requires(pre): /usr/sbin/useradd
 Requires:      procps
-Requires:      rc-scripts
+Requires:      rc-scripts >= 0.4.0.17
 Requires:      systemd-units >= 0.38
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
index bee2500dc07d2ffcf52127a59cb279d8d6ddd223..a493948b698a990c934d1bccfbb68b2a9b758202 100644 (file)
@@ -1,3 +1,5 @@
-### Settings for gearmand
-# OPTIONS=""
+#
+# Settings for gearmand
+#
 
+#OPTIONS=""
This page took 0.143889 seconds and 4 git commands to generate.