Code

- Added vars for the various part
authoropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Oct 2009 08:52:57 +0000 (08:52 +0000)
committeropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Oct 2009 08:52:57 +0000 (08:52 +0000)
- Added a status item to check status of client and servers

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14566 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/debian/gosa-si-common.init

index 2f0dae5708a2e4f62c8bbc3364f7b80bb3ef93e4..c1a730e7209cddf9610c255d4537f1af09f17a1a 100755 (executable)
 #                    signaling for all communication partners.
 ### END INIT INFO
 
+# Start/stop the ctftpd daemon.
+SERVER="gosa-si-server"
+CLIENT="gosa-si-client"
+DAEMON_SERVER="/usr/sbin/${SERVER}"
+DAEMON_CLIENT="/usr/sbin/${CLIENT}"
+PIDFILE_SERVER="/var/run/${SERVER}.pid"
+PIDFILE_CLIENT="/var/run/${CLIENT}.pid"
+
 # Load defaults
 [ -r /etc/default/gosa-si ] && . /etc/default/gosa-si
 
 
 
 start_client() {
-       start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-client.pid --name gosa-si-client --startas /usr/sbin/gosa-si-client -- $DEBUG
+       start-stop-daemon --start --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT} --startas ${DAEMON_CLIENT} -- $DEBUG
 }
 
 
 start_server() {
-       start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-server.pid --name gosa-si-server --startas /usr/sbin/gosa-si-server -- $1 $DEBUG
+       start-stop-daemon --start --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER} --startas ${DAEMON_SERVER} -- $1 $DEBUG
 }
 
 
 stop_client() {
-       start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/gosa-si-client.pid --name gosa-si-client
+       start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT}
        kill `ps -C gosa-si-client -o pid=` > /dev/null 2>&1
        ! ps -C gosa-si-client -o pid= > /dev/null 2>&1
 }
 
 
 stop_server() {
-       start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/gosa-si-server.pid --name gosa-si-server
+       start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER}
        kill `ps -C gosa-si-server -o pid=` > /dev/null 2>&1
        ! ps -C gosa-si-server -o pid= > /dev/null 2>&1
 }
@@ -46,52 +54,78 @@ stop_server() {
 
 case "$1" in
 start)  log_daemon_msg "Starting GOsa support infrastructure"
-       if [ -x /usr/sbin/gosa-si-server ]; then
+       if [ -x ${DAEMON_SERVER} ]; then
                log_progress_msg "daemon"
                start_server
        fi
-       if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+       if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
                log_progress_msg "client"
                start_client
        fi
         log_end_msg $?
        ;;
 stop)   log_daemon_msg "Stopping GOsa support infrastructure"
-       if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+       if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
                log_progress_msg "client"
                stop_client
        fi
-       if [ -x /usr/sbin/gosa-si-server ]; then
+       if [ -x ${DAEMON_SERVER} ]; then
                log_progress_msg "daemon"
                stop_server
        fi
         log_end_msg $?
         ;;
 reload|force-reload|restart) log_daemon_msg "Restarting GOsa support infrastructure" 
-       if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+       if [ "$START_CLIENT" = "1" -a -x {DAEMON_CLIENT} ]; then
                stop_client
        fi
-       if [ -x /usr/sbin/gosa-si-server ]; then
+       if [ -x {DAEMON_SERVER} ]; then
                stop_server
                start_server
        fi
-       if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+       if [ "$START_CLIENT" = "1" -a -x {DAEMON_CLIENT} ]; then
                start_client
        fi
        log_progress_msg "done"
         log_end_msg $?
         ;;
 restart-client) log_daemon_msg "Restarting GOsa support infrastructure client"
-        if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+        if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
                 stop_client
         fi
-        if [ "$START_CLIENT" = "1" -a -x /usr/sbin/gosa-si-client ]; then
+        if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
                 start_client
         fi
         log_progress_msg "done"
         log_end_msg $?
         ;;
-*)     log_action_msg "Usage: /etc/init.d/gosa-si {start|stop|restart|restart-client|reload|force-reload}"
+status)
+        status=0
+        pidofproc -p "${PIDFILE_SERVER}" "${DAEMON_SERVER}" >/dev/null || status="$?"
+        log_daemon_msg "Status of GOsa-si server" "${NAME}"
+        if [ "$status" = 0 ]; then
+               log_progress_msg "is running"
+               log_end_msg 0
+        else
+               log_progress_msg "is not running"
+               log_end_msg $status
+        fi
+
+        if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
+               status=0
+               pidofproc -p "${PIDFILE_SERVER}" "${DAEMON_SERVER}" >/dev/null || status="$?"
+               log_daemon_msg "Status of GOsa-si server" "${NAME}"
+               if [ "$status" = 0 ]; then
+                               log_progress_msg "is running"
+                               log_end_msg 0
+               else
+                               log_progress_msg "is not running"
+                               log_end_msg $status
+               fi
+       fi
+        ;;
+
+*)     log_action_msg "Usage: /etc/init.d/gosa-si {start|stop|restart|restart-client|reload|force-reload|status}"
         exit 2
         ;;
 esac