[Koha-patches] [PATCH] Bug 9250 - provide commands to manage the SIP server

Robin Sheat robin at catalyst.net.nz
Tue Dec 11 03:28:52 CET 2012


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
---
 debian/docs/koha-enable-sip.xml |   58 +++++++++++++++++++++++++++++++++++++++
 debian/docs/koha-start-sip.xml  |   53 +++++++++++++++++++++++++++++++++++
 debian/docs/koha-stop-sip.xml   |   53 +++++++++++++++++++++++++++++++++++
 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, 310 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 0000000..c9c0d7c
--- /dev/null
+++ b/debian/docs/koha-enable-sip.xml
@@ -0,0 +1,58 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-enable-sip</title>
+<info>
+    <productname>Koha</productname> is the first free software library automation package.
+    <author>
+        <personname>
+            <firstname>Robin</firstname>
+            <surname>Sheat</surname>
+        </personname>
+        <affiliation>
+            <orgname>Catalyst IT</orgname>
+            <uri>http://www.catalyst.net.nz</uri>
+        </affiliation>
+        <contrib>Author</contrib> 
+    </author>
+</info>
+
+<refentry xml:id="koha-enable-sip">
+
+    <refmeta>
+        <refentrytitle>koha-enable-sip</refentrytitle>
+        <manvolnum>8</manvolnum>
+    </refmeta>
+
+    <refnamediv>
+        <refname>koha-enable-sip</refname>
+        <refpurpose>Copies the SIP configuration file to allow SIP to be controlled by init scripts.</refpurpose>
+        <refclass>UNIX/Linux</refclass>
+    </refnamediv>
+
+    <refsynopsisdiv>
+        <cmdsynopsis>
+            <command>koha-enable-sip</command> 
+            <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+        </cmdsynopsis>
+    </refsynopsisdiv>
+
+    <refsect1><title>Description</title>
+        <para>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
+            <command>koha-start-sip(8)</command>, and <command>koha-stop-sip</command>. In turn,
+            this means that it will be started on boot and stopped on shutdown.</para>
+        <para>After running this, you will need to edit the newly created file to configure it
+            for your site.</para>
+        <para>To disable SIP again, delete or rename the configuration file.</para>
+    </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-start-sip(8)</command></member>
+    <member><command>koha-stop-sip(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
+
diff --git a/debian/docs/koha-start-sip.xml b/debian/docs/koha-start-sip.xml
new file mode 100644
index 0000000..e49eb41
--- /dev/null
+++ b/debian/docs/koha-start-sip.xml
@@ -0,0 +1,53 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-start-sip</title>
+<info>
+    <productname>Koha</productname> is the first free software library automation package.
+    <author>
+        <personname>
+            <firstname>Robin</firstname>
+            <surname>Sheat</surname>
+        </personname>
+        <affiliation>
+            <orgname>Catalyst IT</orgname>
+            <uri>http://www.catalyst.net.nz</uri>
+        </affiliation>
+        <contrib>Author</contrib> 
+    </author>
+</info>
+
+<refentry xml:id="koha-start-sip">
+
+    <refmeta>
+        <refentrytitle>koha-start-sip</refentrytitle>
+        <manvolnum>8</manvolnum>
+    </refmeta>
+
+    <refnamediv>
+        <refname>koha-start-sip</refname>
+        <refpurpose>Starts the SIP daemon for the specified Koha instances.</refpurpose>
+        <refclass>UNIX/Linux</refclass>
+    </refnamediv>
+
+    <refsynopsisdiv>
+        <cmdsynopsis>
+            <command>koha-start-sip</command> 
+            <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+        </cmdsynopsis>
+    </refsynopsisdiv>
+
+    <refsect1><title>Description</title>
+        <para>This will start the SIP daemon for the Koha instance specified by <arg>instancename</arg>.</para>
+        <para>If the SIP configuration is not present for the supplied instance, it will be silently skipped.</para>
+        <para>To enable SIP support for an instance, refer to <command>koha-enable-sip(8)</command>.</para>
+    </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-stop-sip(8)</command></member>
+    <member><command>koha-enable-sip(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
diff --git a/debian/docs/koha-stop-sip.xml b/debian/docs/koha-stop-sip.xml
new file mode 100644
index 0000000..1c72a47
--- /dev/null
+++ b/debian/docs/koha-stop-sip.xml
@@ -0,0 +1,53 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-stop-sip</title>
+<info>
+    <productname>Koha</productname> is the first free software library automation package.
+    <author>
+        <personname>
+            <firstname>Robin</firstname>
+            <surname>Sheat</surname>
+        </personname>
+        <affiliation>
+            <orgname>Catalyst IT</orgname>
+            <uri>http://www.catalyst.net.nz</uri>
+        </affiliation>
+        <contrib>Author</contrib> 
+    </author>
+</info>
+
+<refentry xml:id="koha-stop-sip">
+
+    <refmeta>
+        <refentrytitle>koha-stop-sip</refentrytitle>
+        <manvolnum>8</manvolnum>
+    </refmeta>
+
+    <refnamediv>
+        <refname>koha-stop-sip</refname>
+        <refpurpose>Stops the SIP daemon for the specified Koha instances.</refpurpose>
+        <refclass>UNIX/Linux</refclass>
+    </refnamediv>
+
+    <refsynopsisdiv>
+        <cmdsynopsis>
+            <command>koha-stop-sip</command> 
+            <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+        </cmdsynopsis>
+    </refsynopsisdiv>
+
+    <refsect1><title>Description</title>
+        <para>This will stop the SIP daemon for the Koha instance specified by <arg>instancename</arg>.</para>
+        <para>If it's not running, an note will be displayed.</para>
+    </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-start-sip(8)</command></member>
+    <member><command>koha-enable-sip(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
+
diff --git a/debian/koha-common.init b/debian/koha-common.init
index 5be77d3..5089803 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-sop $(koha-list --enabled)
 }
 
 case "$1" in
diff --git a/debian/koha-common.install b/debian/koha-common.install
index 50affbd..7ad13ee 100644
--- a/debian/koha-common.install
+++ b/debian/koha-common.install
@@ -28,4 +28,7 @@ debian/scripts/koha-start-zebra             usr/sbin
 debian/scripts/koha-stop-zebra              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 0000000..1bcdd97
--- /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 <http://www.gnu.org/licenses/>.
+
+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 0000000..c104af3
--- /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 <http://www.gnu.org/licenses/>.
+
+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
+    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 0000000..a6110e4
--- /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 <http://www.gnu.org/licenses/>.
+
+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
-- 
1.7.9.5



More information about the Koha-patches mailing list