From c9ca18549ca06c7443ee354b0aa74e56a020acb5 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 30 Jan 2019 08:42:53 -0300 Subject: [PATCH] Bug 18562: Add koha-sip maintenance script This patch introduces a single script to handle all actions on SIP servers for Koha instances. It is intended to be a replacement for: - koha-start-sip - koha-stop-sip - koha-enable-sip It adds a function called is_sip_running to koha-functions.sh. To test: - Apply this patch - Run: $ misc4dev/cp_debian_files.pl $ sudo koha-sip --enable kohadev $ sudo koha-sip --start kohadev $ sudo koha-sip --status kohadev => SUCCESS: The SIP server is running for kohadev - Run: $ sudo koha-sip --restart --verbose kohadev $ sudo koha-sip --status kohadev => SUCCESS: The SIP server is running for kohadev - Run: $ sudo koha-sip --stop kohadev $ sudo koha-sip --status kohadev => SUCCESS: The SIP server is not running for kohadev - Play with other combinations like enabling an already enabled instance, etc. Remember you need to remove the /etc/koha/sites/kohadev/SIPconfig.xml file so it is considered disabled. - Sign off :-D Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 6ec979057b2b4f10fe469d2655fa0fcb47af1cb7) Signed-off-by: Martin Renvoize --- debian/koha-common.install | 1 + debian/scripts/koha-functions.sh | 14 ++ debian/scripts/koha-sip | 308 +++++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100755 debian/scripts/koha-sip diff --git a/debian/koha-common.install b/debian/koha-common.install index f31bfdef8e..6c54fc28fa 100644 --- a/debian/koha-common.install +++ b/debian/koha-common.install @@ -37,4 +37,5 @@ debian/scripts/koha-zebra usr/sbin debian/scripts/koha-start-sip usr/sbin debian/scripts/koha-stop-sip usr/sbin debian/scripts/koha-enable-sip usr/sbin +debian/scripts/koha-sip usr/sbin debian/tmp_docbook/*.8 usr/share/man/man8 diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index c6f79b4933..3a04db7851 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -157,6 +157,20 @@ is_sitemap_enabled() fi } +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 +} + is_zebra_running() { local instancename=$1 diff --git a/debian/scripts/koha-sip b/debian/scripts/koha-sip new file mode 100755 index 0000000000..da6909ba43 --- /dev/null +++ b/debian/scripts/koha-sip @@ -0,0 +1,308 @@ +#!/bin/bash + +# koha-sip - Manage SIP server for Koha instances +# Copyright 2019 Theke Solutions +# 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 + +. /lib/lsb/init-functions + +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + +usage() +{ + local scriptname=$(basename $0) + + cat <