X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=debian%2Fkoha-common.init;h=1ba591dfd302aaf7fa6285b01936449ad0893ff1;hb=HEAD;hp=719a5841bc08592a2d89256c4fba3afe38a95b10;hpb=6241d54c52b9ad1e8f1117b260cbbc86c4d37faa;p=koha.git diff --git a/debian/koha-common.init b/debian/koha-common.init index 719a5841bc..1ba591dfd3 100755 --- a/debian/koha-common.init +++ b/debian/koha-common.init @@ -18,17 +18,20 @@ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Koha ILS" -NAME=daemonexecutablename -DAEMON=/usr/sbin/$NAME -DAEMON_ARGS="--options args" -PIDFILE=/var/run/$NAME.pid +NAME="koha-common" SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x /usr/sbin/koha-start-zebra ] || exit 0 # Read configuration variable file if it is present -# [ -r /etc/default/$NAME ] && . /etc/default/$NAME +if [ -r /etc/default/$NAME ]; then + # Debian / Ubuntu + . /etc/default/$NAME +elif [ -r /etc/sysconfig/$NAME ]; then + # RedHat / SuSE + . /etc/sysconfig/$NAME +fi # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -42,7 +45,10 @@ SCRIPTNAME=/etc/init.d/$NAME # do_start() { + # We insure all required directories exist, including disabled ones. + koha-create-dirs $(koha-list) koha-start-zebra $(koha-list --enabled) + koha-start-sip $(koha-list --enabled) } # @@ -52,6 +58,7 @@ do_stop() { # We stop everything, including disabled ones. koha-stop-zebra $(koha-list) || true + koha-stop-sip $(koha-list) || true } # @@ -59,6 +66,77 @@ do_stop() # do_reload() { koha-restart-zebra $(koha-list --enabled) + koha-stop-sip $(koha-list) || true + koha-start-sip $(koha-list --enabled) +} + +# +# Function that checks zebrasrv is running for the specified instance +# +is_zebra_running() +{ + local instancename=$1 + + if daemon --name="$instancename-koha-zebra" \ + --user="$instancename-koha.$instancename-koha" \ + --running ; then + return 0 + else + return 1 + fi +} + +# +# Function that checks SIP server is running for the specified instance +# +is_sip_running() +{ + local instancename=$1 + + if daemon --name="$instancename-koha-sip" \ + --pidfiles="/var/run/koha/$instancename" \ + --user="$instancename-koha.$instancename-koha" \ + --running ; then + return 0 + else + return 1 + fi +} + +# +# Function that shows the status of the zebrasrv daemon for +# enabled instances +# +zebra_status() +{ + for instance in $(koha-list --enabled); do + + log_daemon_msg "Zebra server running for instace $instance" + + if is_zebra_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + +# +# Function that shows the status of the SIP server daemon for +# enabled instances +# +sip_status() +{ + for instance in $(koha-list --enabled --sip); do + + log_daemon_msg "SIP server running for instace $instance" + + if is_sip_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done } case "$1" in @@ -78,18 +156,6 @@ case "$1" in *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; -# status) -# status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? -# ;; - #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 $? - #;; restart|force-reload) # # If the "reload" option is implemented then remove the @@ -111,9 +177,12 @@ case "$1" in ;; esac ;; + status) + zebra_status + sip_status + ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - #echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac