From c70fb0fcd625701d0f3d01f0c8faa17468bba54c Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Mon, 10 Dec 2012 18:57:04 +1300 Subject: [PATCH] Bug 9250 - [SIGNED-OFF] provide commands to manage the SIP server This adds commands required to control the SIP server. These commands are: * koha-enable-sip - copies the SIP config to the sites directory * koha-start-sip - starts the SIP server processes * koha-stop-sip - stops the SIP server processes It also calls these as appropriate from the koha-common init script. To use: 1) sudo koha-enable-sip instancename 2) sudo vim /etc/koha/sites/instancename/SIPconfig.xml Do whatever is needed for your site's SIP configuration 3) sudo koha-start-sip instancename To test: 1) Build packages with this patch 2) Ensure that sudo koha-start-sip instancename doesn't do anything 3) Run sudo koha-enable-sip instancename 4) Edit /etc/koha/sites/instancename/SIPconfig.xml if needed (probably not required for testing) 5) Run sudo koha-start-sip instancename 6) Note that the sip processes are now running 7) Run sudo koha-stop-sip instancename 8) Note that the sip processes have gone 9) Reboot your Koha server 10) Note that the sip processes are back Sponsored-By: Waitaki District Council Libraries Sponsored-By: South Taranaki District Council Libraries Sponsored-By: Horowhenua District Council Libraries Sponsored-By: Rangitikei District Council Libraries Signed-off-by: Magnus Enger Works as advertised. koha-start-sip without a prior koha-enable-sip does nothing. koha-enable-sip copies the SIP config file to the instance directory. After koha-enable-sip, koha-start-sip and koha-stop-sip works as expected. After a reboot, the SIP processes are still running. I have not actually tested the SIP servers after they have been started, but assume they work the same as always. The man pages look good. The new commands should also have been added to the man page for koha-common. I'll do a followup for that. Signed-off-by: Jared Camins-Esakov (cherry picked from commit 3dc22e7fb27162b3a461477bc40f5c38a1739516) Signed-off-by: Jared Camins-Esakov --- debian/docs/koha-enable-sip.xml | 57 +++++++++++++++++++++++++++++++++ debian/docs/koha-start-sip.xml | 53 ++++++++++++++++++++++++++++++ debian/docs/koha-stop-sip.xml | 52 ++++++++++++++++++++++++++++++ debian/koha-common.init | 4 +++ debian/koha-common.install | 3 ++ debian/scripts/koha-enable-sip | 38 ++++++++++++++++++++++ debian/scripts/koha-start-sip | 49 ++++++++++++++++++++++++++++ debian/scripts/koha-stop-sip | 52 ++++++++++++++++++++++++++++++ 8 files changed, 308 insertions(+) create mode 100644 debian/docs/koha-enable-sip.xml create mode 100644 debian/docs/koha-start-sip.xml create mode 100644 debian/docs/koha-stop-sip.xml create mode 100755 debian/scripts/koha-enable-sip create mode 100755 debian/scripts/koha-start-sip create mode 100755 debian/scripts/koha-stop-sip diff --git a/debian/docs/koha-enable-sip.xml b/debian/docs/koha-enable-sip.xml new file mode 100644 index 0000000000..3ce3b09b30 --- /dev/null +++ b/debian/docs/koha-enable-sip.xml @@ -0,0 +1,57 @@ +
+koha-enable-sip + + Koha is the first free software library automation package. + + + Robin + Sheat + + + Catalyst IT + http://www.catalyst.net.nz + + Author + + + + + + + koha-enable-sip + 8 + + + + koha-enable-sip + Copies the SIP configuration file to allow SIP to be controlled by init scripts. + UNIX/Linux + + + + + koha-enable-sip + instancename + + + + Description + This copies the default SIP configuration file /etc/koha/SIPconfig.xml to the + /etc/koha/sites/instancename directory. This allows it to be started by + koha-start-sip(8), and koha-stop-sip. In turn, + this means that it will be started on boot and stopped on shutdown. + After running this, you will need to edit the newly created file to configure it + for your site. + To disable SIP again, delete or rename the configuration file. + + + See also + + koha-start-sip(8) + koha-stop-sip(8) + + + + + +
diff --git a/debian/docs/koha-start-sip.xml b/debian/docs/koha-start-sip.xml new file mode 100644 index 0000000000..b6a18dd848 --- /dev/null +++ b/debian/docs/koha-start-sip.xml @@ -0,0 +1,53 @@ +
+koha-start-sip + + Koha is the first free software library automation package. + + + Robin + Sheat + + + Catalyst IT + http://www.catalyst.net.nz + + Author + + + + + + + koha-start-sip + 8 + + + + koha-start-sip + Starts the SIP daemon for the specified Koha instances. + UNIX/Linux + + + + + koha-start-sip + instancename + + + + Description + This will start the SIP daemon for the Koha instance specified by instancename. + If the SIP configuration is not present for the supplied instance, it will be silently skipped. + To enable SIP support for an instance, refer to koha-enable-sip(8). + + + See also + + koha-stop-sip(8) + koha-enable-sip(8) + + + + + +
diff --git a/debian/docs/koha-stop-sip.xml b/debian/docs/koha-stop-sip.xml new file mode 100644 index 0000000000..3e5a1793fa --- /dev/null +++ b/debian/docs/koha-stop-sip.xml @@ -0,0 +1,52 @@ +
+koha-stop-sip + + Koha is the first free software library automation package. + + + Robin + Sheat + + + Catalyst IT + http://www.catalyst.net.nz + + Author + + + + + + + koha-stop-sip + 8 + + + + koha-stop-sip + Stops the SIP daemon for the specified Koha instances. + UNIX/Linux + + + + + koha-stop-sip + instancename + + + + Description + This will stop the SIP daemon for the Koha instance specified by instancename. + If it's not running, an note will be displayed. + + + See also + + koha-start-sip(8) + koha-enable-sip(8) + + + + + +
diff --git a/debian/koha-common.init b/debian/koha-common.init index 5be77d36b9..9a285a36ac 100755 --- a/debian/koha-common.init +++ b/debian/koha-common.init @@ -45,6 +45,7 @@ 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) } # @@ -54,6 +55,7 @@ do_stop() { # We stop everything, including disabled ones. koha-stop-zebra $(koha-list) || true + koha-stop-sip $(koha-list) || true } # @@ -61,6 +63,8 @@ do_stop() # do_reload() { koha-restart-zebra $(koha-list --enabled) + koha-stop-sip $(koha-list) || true + koha-start-sip $(koha-list --enabled) } case "$1" in diff --git a/debian/koha-common.install b/debian/koha-common.install index 0e542bb85b..810aadc2b8 100644 --- a/debian/koha-common.install +++ b/debian/koha-common.install @@ -31,4 +31,7 @@ debian/scripts/koha-stop-zebra usr/sbin debian/scripts/koha-translate usr/sbin debian/scripts/koha-upgrade-schema usr/sbin debian/scripts/koha-upgrade-to-3.4 usr/sbin +debian/scripts/koha-start-sip usr/sbin +debian/scripts/koha-stop-sip usr/sbin +debian/scripts/koha-enable-sip usr/sbin debian/tmp_docbook/*.8 usr/share/man/man8 diff --git a/debian/scripts/koha-enable-sip b/debian/scripts/koha-enable-sip new file mode 100755 index 0000000000..1bcdd97571 --- /dev/null +++ b/debian/scripts/koha-enable-sip @@ -0,0 +1,38 @@ +#!/bin/sh +# +# koha-enable-sip -- Set up the config files to allow SIP to run +# Copyright 2012 Catalyst IT, Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +for name in "$@" +do + if [ ! -e /etc/koha/sites/${name}/koha-conf.xml ] ; + then + echo "No such instance: ${name}" > /dev/stderr + continue; + fi + sipfile=/etc/koha/sites/${name}/SIPconfig.xml + if [ -e ${sipfile} ] + then + echo "SIP already enabled for $name" + else + echo "Enabling SIP for $name - edit ${sipfile} to configure" + cp -v /etc/koha/SIPconfig.xml ${sipfile} + chown ${name}-koha:${name}-koha ${sipfile} + chmod 600 ${sipfile} + fi +done diff --git a/debian/scripts/koha-start-sip b/debian/scripts/koha-start-sip new file mode 100755 index 0000000000..791c6d3502 --- /dev/null +++ b/debian/scripts/koha-start-sip @@ -0,0 +1,49 @@ +#!/bin/sh +# +# koha-start-sip -- Start SIP server for named Koha instance +# Copyright 2012 Catalyst IT, Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +for name in "$@" +do + if [ ! -e /etc/koha/sites/${name}/koha-conf.xml ] ; + then + echo "No such instance: ${name}" > /dev/stderr + continue; + fi + [ -e /etc/koha/sites/${name}/SIPconfig.xml ] || continue + echo "Starting SIP server for $name" + mkdir -p /var/run/koha/${name} + chown "${name}-koha:${name}-koha" /var/run/koha/${name} + export KOHA_CONF PERL5LIB + KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml + PERL5LIB="/usr/share/koha/lib:/usr/share/koha/lib/C4/SIP" + daemon \ + --name="$name-koha-sip" \ + --errlog="/var/log/koha/$name/sip-error.log" \ + --stdout="/var/log/koha/$name/sip.log" \ + --output="/var/log/koha/$name/sip-output.log" \ + --verbose=1 \ + --respawn \ + --delay=30 \ + --pidfiles="/var/run/koha/${name}" \ + --user="$name-koha.$name-koha" \ + -- \ + perl \ + "/usr/share/koha/lib/C4/SIP/SIPServer.pm" \ + "/etc/koha/sites/${name}/SIPconfig.xml" +done diff --git a/debian/scripts/koha-stop-sip b/debian/scripts/koha-stop-sip new file mode 100755 index 0000000000..b0cbbe9614 --- /dev/null +++ b/debian/scripts/koha-stop-sip @@ -0,0 +1,52 @@ +#!/bin/sh +# +# koha-stop-sip -- Stop SIP server for named Koha instance +# Copyright 2012 Catalyst IT, Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +for name in "$@" +do + if [ ! -e /etc/koha/sites/${name}/koha-conf.xml ] ; + then + echo "No such instance: ${name}" > /dev/stderr + continue; + fi + if [ ! -e /var/run/koha/${name}/${name}-koha-sip.pid ] ; + then + echo "SIP server for ${name} not running." + continue; + fi + echo "Stopping SIP server for $name" + KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml + PERL5LIB=/usr/share/koha/lib + export KOHA_CONF PERL5LIB + daemon \ + --name="$name-koha-sip" \ + --errlog="/var/log/koha/$name/sip-error.log" \ + --stdout="/var/log/koha/$name/sip.log" \ + --output="/var/log/koha/$name/sip-output.log" \ + --verbose=1 \ + --respawn \ + --delay=30 \ + --pidfiles="/var/run/koha/${name}" \ + --user="$name-koha.$name-koha" \ + --stop \ + -- \ + perl \ + "/usr/share/koha/lib/C4/SIP/SIPServer.pm" \ + "/etc/koha/sites/${name}/SIPconfig.xml" +done -- 2.39.5