</variablelist>
</refsect2>
+ <refsect2><title>SIP2-related</title>
+ <variablelist>
+
+ <varlistentry>
+ <term><option>koha-enable-sip</option></term>
+ <listitem>
+ <para>Copies the SIP configuration file to allow SIP to be controlled by init scripts.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>koha-start-sip</option></term>
+ <listitem>
+ <para>Starts the SIP daemon for the specified Koha instances.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>koha-stop-sip</option></term>
+ <listitem>
+ <para>Stops the SIP daemon for the specified Koha instances.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+
<refsect2><title>Misc</title>
<variablelist>
<refnamediv>
<refname>koha-disable</refname>
- <refpurpose>Disable a Koha instance.</refpurpose>
+ <refpurpose>Disable Koha instances.</refpurpose>
<refclass>UNIX/Linux</refclass>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
- <command>koha-disable</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
+ <command>koha-disable</command> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
- <para>Disable a Koha instance.</para>
+ <para>Disable Koha instances.</para>
</refsect1>
<refsect1><title>See also</title>
--- /dev/null
+<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>
<refnamediv>
<refname>koha-enable</refname>
- <refpurpose>Enable a Koha instance. New instances are enabled by default. You only need this command if you have previously disabled a site with koha-disable.</refpurpose>
+ <refpurpose>Enable one or more Koha instances. New instances are enabled by default. You only need this command if you have previously disabled an instance with koha-disable.</refpurpose>
<refclass>UNIX/Linux</refclass>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
- <command>koha-enable</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
+ <command>koha-enable</command> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
- <para>Enable a Koha instance. New instances are enabled by default. You only need this command if you have previously disabled a site with koha-disable.</para>
+ <para>Enable one or more Koha instances. New instances are enabled by default. You only need this command if you have previously disabled am instance with koha-disable.</para>
</refsect1>
<refsect1><title>See also</title>
--- /dev/null
+<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>
--- /dev/null
+<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>
--- /dev/null
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-translate</title>
+<info>
+<productname>Koha</productname> is the first free software library automation package.
+<author>
+ <orgname>The Koha Community</orgname>
+ <uri>http://koha-community.org/</uri>
+</author>
+</info>
+
+<refentry xml:id="koha-translate">
+
+ <refmeta>
+ <refentrytitle>koha-translate</refentrytitle>
+ <manvolnum>8</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>koha-translate</refname>
+ <refpurpose>Manage Koha templates translations</refpurpose>
+ <refclass>UNIX/Linux</refclass>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>koha-translate</command> <arg><option>-i</option>|<option>--install</option></arg> <arg><option>-u</option>|<option>--update</option></arg> <arg><option>-r</option>|<option>--remove</option></arg> <arg><option>-c</option>|<option>--check</option></arg> <arg choice="req" rep="norepeat"><replaceable>lang_code</replaceable></arg>
+ <command>koha-translate</command> <arg><option>-l</option>|<option>--list</option></arg> <arg><option>-a</option>|<option>--available</option></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1><title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>-a, --available</option></term>
+ <listitem>
+ <para>(For use with --list) List the available language translations.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-c, --check</option></term>
+ <listitem>
+ <para>Check if all the .PO files are present for the specified language.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-i, --install</option></term>
+ <listitem>
+ <para>Install the specified lang_code language translation.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-l, --list</option></term>
+ <listitem>
+ <para>List the installed or available (combined with -a) language translations.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-r, --remove</option></term>
+ <listitem>
+ <para>Remove the specified lang_code language translation.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-u, --update</option></term>
+ <listitem>
+ <para>Update the specified lang_code language translation.</para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+
+ <refsect1><title>Description</title>
+ <para>Manage Koha templates translations.</para>
+ </refsect1>
+
+</refentry>
+
+</article>
# 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)
}
#
{
# We stop everything, including disabled ones.
koha-stop-zebra $(koha-list) || true
+ koha-stop-sip $(koha-list) || true
}
#
#
do_reload() {
koha-restart-zebra $(koha-list --enabled)
+ koha-stop-sip $(koha-list) || true
+ koha-start-sip $(koha-list --enabled)
}
case "$1" in
debian/scripts/koha-shell usr/sbin
debian/scripts/koha-start-zebra usr/sbin
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
#!/bin/sh
#
-# koha-disable -- disable a Koha instance.
+# koha-disable - disable Koha instances.
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
set -e
-die() {
+die()
+{
echo "$@" 1>&2
exit 1
}
+warn()
+{
+ echo "$@" 1>&2
+}
+
+is_enabled()
+{
+ local instancename=$1
+
+ if ! is_instance $instancename; then
+ return 1
+ fi
+
+ if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
+ "/etc/apache2/sites-available/$instancename" ; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+is_instance()
+{
+ local instancename=$1
+
+ if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
+ -type d -printf '%f\n'\
+ | grep -q -x $instancename ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+disable_instance()
+{
+ local instancename=$1
+
+ if is_enabled $instancename; then
+ sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-disable.conf\)$:\1:' \
+ "/etc/apache2/sites-available/$instancename"
+ return 0
+ else
+ return 1
+ fi
+}
+
+usage()
+{
+ local scriptname=$0
+ cat <<EOF
+Disables Koha instances.
+
+Usage: $scriptname instancename1 instancename2...
+
+EOF
+}
# Parse command line.
-[ "$#" = 1 ] || die "Usage: $0 instancename..."
+[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
+restart_apache="no"
for name in "$@"
do
- sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-disable.conf\)$:\1:' \
- "/etc/apache2/sites-available/$name"
+ if is_instance $name ; then
+ if disable_instance $name; then
+ restart_apache="yes"
+ else
+ warn "Instance $name already disabled."
+ fi
+ else
+ warn "Unknown instance $name."
+ fi
done
-/etc/init.d/apache2 restart
+if [ "$restart_apache" = "yes" ]; then
+ /etc/init.d/apache2 restart
+fi
+
+exit 0
set -e
-die() {
+die()
+{
echo "$@" 1>&2
exit 1
}
+warn()
+{
+ echo "$@" 1>&2
+}
+
+is_enabled()
+{
+ local instancename=$1
+
+ if ! is_instance $instancename; then
+ return 1
+ fi
+
+ if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
+ "/etc/apache2/sites-available/$instancename" ; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+is_instance()
+{
+ local instancename=$1
+
+ if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
+ -type d -printf '%f\n'\
+ | grep -q -x $instancename ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+enable_instance()
+{
+ local instancename=$1
+
+ if ! is_enabled $instancename; then
+ sed -i 's:^\(\s*Include /etc/koha/apache-shared-disable.conf\)$:#\1:' \
+ "/etc/apache2/sites-available/$instancename"
+ return 0
+ else
+ return 1
+ fi
+}
+
+usage()
+{
+ local scriptname=$0
+ cat <<EOF
+Enables Koha instances.
+
+Usage: $scriptname instancename1 instancename2...
+
+EOF
+}
# Parse command line.
-[ "$#" = 1 ] || die "Usage: $0 instancename..."
+[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
+restart_apache="no"
for name in "$@"
do
- sed -i 's:^\(\s*Include /etc/koha/apache-shared-disable.conf\)$:#\1:' \
- "/etc/apache2/sites-available/$name"
+ if is_instance $name ; then
+ if enable_instance $name; then
+ restart_apache="yes"
+ else
+ warn "Instance $name already enabled."
+ fi
+ else
+ warn "Unknown instance $name."
+ fi
done
-/etc/init.d/apache2 restart
+if [ "$restart_apache" = "yes" ]; then
+ /etc/init.d/apache2 restart
+fi
+
+exit 0
--- /dev/null
+#!/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
#!/bin/sh
#
-# koha-restart-zebra -- Restart Zebra for named Koha instandes
+# koha-restart-zebra - Restart Zebra for named Koha instances
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
set -e
+die()
+{
+ echo "$@" 1>&2
+ exit 1
+}
+
+warn()
+{
+ echo "$@" 1>&2
+}
+
+is_enabled()
+{
+ local instancename=$1
+
+ if ! is_instance $instancename; then
+ return 1
+ fi
+
+ if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
+ "/etc/apache2/sites-available/$instancename" ; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+is_instance()
+{
+ local instancename=$1
+
+ if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
+ -type d -printf '%f\n'\
+ | grep -q -x $instancename ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+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
+}
+
+restart_zebra_instance()
+{
+ local instancename=$1
+
+ if is_zebra_running $instancename; then
+ echo "Restarting Zebra server for $instancename"
+ daemon \
+ --name="$instancename-koha-zebra" \
+ --errlog="/var/log/koha/$instancename/zebra-error.log" \
+ --stdout="/var/log/koha/$instancename/zebra.log" \
+ --output="/var/log/koha/$instancename/zebra-output.log" \
+ --verbose=1 \
+ --respawn \
+ --delay=30 \
+ --user="$instancename-koha.$instancename-koha" \
+ --restart \
+ -- \
+ zebrasrv \
+ -v none,fatal,warn \
+ -f "/etc/koha/sites/$instancename/koha-conf.xml" && \
+ return 0
+ else
+ return 1
+ fi
+}
+
+start_zebra_instance()
+{
+ local instancename=$1
+
+ if is_enabled $instancename; then
+ echo "Starting Zebra server for $instancename"
+ daemon \
+ --name="$instancename-koha-zebra" \
+ --errlog="/var/log/koha/$instancename/zebra-error.log" \
+ --stdout="/var/log/koha/$instancename/zebra.log" \
+ --output="/var/log/koha/$instancename/zebra-output.log" \
+ --verbose=1 \
+ --respawn \
+ --delay=30 \
+ --user="$instancename-koha.$instancename-koha" \
+ -- \
+ zebrasrv \
+ -v none,fatal,warn \
+ -f "/etc/koha/sites/$instancename/koha-conf.xml" && \
+ return 0
+ else
+ return 1
+ fi
+}
+
+usage()
+{
+ local scriptname=$0
+ cat <<EOF
+Restart Zebra for Koha instances.
+
+Usage: $scriptname instancename1 instancename2...
+
+EOF
+}
+
+# Parse command line.
+[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
+
+# Loop through the instance names
for name in "$@"
do
- echo "Restarting Zebra server for $name"
- daemon \
- --name="$name-koha-zebra" \
- --errlog="/var/log/koha/$name/zebra-error.log" \
- --stdout="/var/log/koha/$name/zebra.log" \
- --output="/var/log/koha/$name/zebra-output.log" \
- --verbose=1 \
- --respawn \
- --delay=30 \
- --user="$name-koha.$name-koha" \
- --restart \
- -- \
- zebrasrv \
- -v none,fatal,warn \
- -f "/etc/koha/sites/$name/koha-conf.xml"
+ if is_instance $name ; then
+ if is_enabled $name ; then
+
+ if ! is_zebra_running $name; then
+ warn "Zebra does not appear to have been running for instance $name."
+
+ if ! start_zebra_instance $name ; then
+ warn "Something went wrong starting Zebra for $name."
+ fi
+ else
+ if ! restart_zebra_instance $name; then
+ warn "Something went wrong restarting Zebra for $name."
+ fi
+ fi
+ else
+ warn "Instance $name disabled. No action taken."
+ fi
+ else
+ warn "Unknown instance $name."
+ fi
done
+
+exit 0
--- /dev/null
+#!/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:/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
#!/bin/sh
#
-# koha-start-zebra -- Start Zebra for named Koha instandes
+# koha-start-zebra - Start Zebra for named Koha instances
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
set -e
+die()
+{
+ echo "$@" 1>&2
+ exit 1
+}
+
+warn()
+{
+ echo "$@" 1>&2
+}
+
+is_enabled()
+{
+ local instancename=$1
+
+ if ! is_instance $instancename; then
+ return 1
+ fi
+
+ if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
+ "/etc/apache2/sites-available/$instancename" ; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+is_instance()
+{
+ local instancename=$1
+
+ if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
+ -type d -printf '%f\n'\
+ | grep -q -x $instancename ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+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
+}
+
+start_zebra_instance()
+{
+ local instancename=$1
+
+ if is_enabled $instancename; then
+ echo "Starting Zebra server for $instancename"
+ daemon \
+ --name="$instancename-koha-zebra" \
+ --errlog="/var/log/koha/$instancename/zebra-error.log" \
+ --stdout="/var/log/koha/$instancename/zebra.log" \
+ --output="/var/log/koha/$instancename/zebra-output.log" \
+ --verbose=1 \
+ --respawn \
+ --delay=30 \
+ --user="$instancename-koha.$instancename-koha" \
+ -- \
+ zebrasrv \
+ -v none,fatal,warn \
+ -f "/etc/koha/sites/$instancename/koha-conf.xml" && \
+ return 0
+ else
+ return 1
+ fi
+}
+
+usage()
+{
+ local scriptname=$0
+ cat <<EOF
+Starts Zebra for Koha instances.
+
+Usage: $scriptname instancename1 instancename2...
+
+EOF
+}
+
+# Parse command line.
+[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
+
+# Loop through the instance names
for name in "$@"
do
- echo "Starting Zebra server for $name"
- daemon \
- --name="$name-koha-zebra" \
- --errlog="/var/log/koha/$name/zebra-error.log" \
- --stdout="/var/log/koha/$name/zebra.log" \
- --output="/var/log/koha/$name/zebra-output.log" \
- --verbose=1 \
- --respawn \
- --delay=30 \
- --user="$name-koha.$name-koha" \
- -- \
- zebrasrv \
- -v none,fatal,warn \
- -f "/etc/koha/sites/$name/koha-conf.xml"
+ if is_instance $name ; then
+ if is_enabled $name ; then
+ if ! is_zebra_running $name; then
+ if ! start_zebra_instance $name; then
+ warn "Something went wrong starting Zebra for $name."
+ fi
+ else
+ warn "Zebra already running for instance $name."
+ fi
+ else
+ warn "Instance $name disabled. No action taken."
+ fi
+ else
+ warn "Unknown instance $name."
+ fi
done
+
+exit 0
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/sh
+#
+# koha-translate -- Manage Koha translations.
+# Copyright 2013 Tomás Cohen Arazi
+# Universidad Nacional de Córdoba
+#
+# 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
+
+usage()
+{
+ local scriptname=$(basename $0)
+
+ cat <<EOF
+$scriptname
+
+This script lets you manage your Koha templates translations.
+
+Usage:
+$scriptname --list|-l [--all|-a]
+$scriptname --check|-c language_code
+$scriptname --install|-i language_code
+$scriptname --update|-u language_code
+$scriptname --remove|-r language_code
+$scriptname -h
+
+ -l | --list List the installed or available (combined with -a)
+ language translations
+ -a | --available Used in conjunction with -l to show all languages
+ -c | --check Check that the language .PO files are present
+ -i | --install Install the specified language translations
+ -u | --update Update the specified language translations
+ -r | --remove Remove the specified language translations
+ -h | --help Display this help message
+
+EOF
+}
+
+die()
+{
+ echo "$@" 1>&2
+ exit 1
+}
+
+list()
+{
+ all=$1
+
+ if [ "$all" != "" ]; then
+ print_available
+ else
+ print_installed
+ fi
+}
+
+print_available()
+{
+ # Loop over only one opac theme
+ for i in $( ls $PO_DIR | grep opac-t-prog ); do
+ echo `basename $i -i-opac-t-prog-v-3006000.po`
+ done
+}
+
+print_installed()
+{
+ ls $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/ | \
+ grep -v -e images -e itemtypeimg
+}
+
+install_lang()
+{
+ lang=$1
+
+ if [ "$lang" != "" ]; then
+
+ if [ "$lang" = "en" ]; then
+ die "Error: the default language (en) is already installed."
+ fi
+
+ if print_available | grep -q $lang; then
+ if print_installed | grep -q $lang; then
+ die "Error: the selected language is already installed. Try --update if you want to re-install it."
+ else
+ # Check po files are present
+ check_lang_po_files $lang
+ env PERL5LIB="$KOHA_LIB_DIR:$TRANSLATE_DIR" KOHA_CONF="$KOHA_CONF_FILE"\
+ $PERL_CMD $TRANSLATE_DIR/translate install $lang
+ fi
+ else
+ die "Error: the selected language is not currently available."
+ fi
+
+ else
+ die "Error: no language code supplied."
+ fi
+}
+
+update_lang()
+{
+ lang=$1
+
+ if [ "$lang" != "" ]; then
+
+ if [ "$lang" = "en" ]; then
+ die "Error: the default language (en) cannot be updated."
+ fi
+
+ if print_installed | grep -q $lang; then
+ # Check po files are present
+ check_lang_po_files $lang
+ remove_lang $lang
+ install_lang $lang
+ else
+ die "Error: the selected language is not currently installed. Try --install."
+ fi
+ else
+ die "Error: no language code supplied."
+ fi
+}
+
+remove_lang()
+{
+ lang=$1
+
+ if [ "$lang" != "" ]; then
+
+ if [ "$lang" = "en" ]; then
+ die "Error: the default language (en) cannot be removed."
+ fi
+
+ if print_installed | grep -q $lang; then
+ rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/$lang
+ rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/ccsr/$lang
+ rm -rf $KOHA_INSTALL_DIR/intranet/htdocs/intranet-tmpl/prog/$lang
+ else
+ die "Error: the selected language is not already installed."
+ fi
+ else
+ die "Error: no language code supplied."
+ fi
+}
+
+check_lang_po_files()
+{
+ lang=$1
+
+ po_files="$PO_DIR/$lang-i-opac-t-prog-v-3006000.po
+ $PO_DIR/$lang-opac-ccsr.po
+ $PO_DIR/$lang-i-staff-t-prog-v-3006000.po
+ $PO_DIR/$lang-pref.po"
+
+ if [ "$lang" != "" ]; then
+
+ for po_file in $po_files; do
+ if [ ! -f $po_file ]; then
+ die "Error: $po_file not found."
+ fi
+ done
+ else
+ die "Error: no language code supplied."
+ fi
+}
+
+set_action()
+{
+ if [ "$op" = "" ]; then
+ op=$1
+ else
+ die "Error: only one action can be specified."
+ fi
+}
+
+# Global PATH variables
+KOHA_INSTALL_DIR="/usr/share/koha"
+KOHA_LIB_DIR="/usr/share/koha/lib"
+KOHA_CONF_FILE="/etc/koha/koha-conf-site.xml.in"
+TRANSLATE_DIR="$KOHA_INSTALL_DIR/misc/translator"
+PO_DIR="$TRANSLATE_DIR/po"
+PERL_CMD=`which perl`
+
+# Control variables
+list_all=""
+op=""
+language=""
+
+# We accept at most 2 parameters
+[ $# -ge 1 ] && [ $# -le 3 ] || ( usage ; die "Error: wrong parameters" )
+
+# Read parameters
+while [ $# -gt 0 ]; do
+
+ case "$1" in
+ -h|--help)
+ op="help"
+ break ;;
+ -c|--check)
+ set_action "check"
+ shift ;;
+ -i|--install)
+ set_action "install"
+ shift ;;
+ -u|--update)
+ set_action "update"
+ shift ;;
+ -r|--remove)
+ set_action "remove"
+ shift ;;
+ -l|--list)
+ set_action "list"
+ shift ;;
+ -a|--available)
+ list_all=1
+ shift ;;
+ -*)
+ usage
+ die "Error: unknown parameter $1." ;;
+ *)
+ language=$1
+ shift ;;
+ esac
+
+done
+
+# Process the requested actions
+case $op in
+ "help")
+ usage ;;
+ "list")
+ list $list_all ;;
+ "install")
+ install_lang $language ;;
+ "update")
+ update_lang $language ;;
+ "remove")
+ remove_lang $language ;;
+ "check")
+ check_lang_po_files $language ;;
+ *)
+ usage
+ die "Error: wrong parameters..." ;;
+esac
+
+exit 0