From f881112dd79db6f451b69c9d9526cfbd12ff65fd Mon Sep 17 00:00:00 2001 From: Pongtawat C Date: Fri, 12 Jan 2018 17:10:50 +0700 Subject: [PATCH 1/1] Bug 19962 - Introduce koha-sip to replace koha-*-sip --- ...62-Introduce-koha-sip-to-replace-koha-sip.patch | 456 +++++++++++++++++++++ debian/scripts/koha-enable-sip | 25 +- debian/scripts/koha-sip | 280 +++++++++++++ debian/scripts/koha-start-sip | 55 +-- debian/scripts/koha-stop-sip | 32 +- 5 files changed, 745 insertions(+), 103 deletions(-) create mode 100644 0001-Bug-19962-Introduce-koha-sip-to-replace-koha-sip.patch create mode 100755 debian/scripts/koha-sip diff --git a/0001-Bug-19962-Introduce-koha-sip-to-replace-koha-sip.patch b/0001-Bug-19962-Introduce-koha-sip-to-replace-koha-sip.patch new file mode 100644 index 0000000000..e55b5432e9 --- /dev/null +++ b/0001-Bug-19962-Introduce-koha-sip-to-replace-koha-sip.patch @@ -0,0 +1,456 @@ +From 12be9e6fe44d7ab30a291ae7de74760feefa36d1 Mon Sep 17 00:00:00 2001 +From: Pongtawat C +Date: Fri, 12 Jan 2018 17:09:34 +0700 +Subject: [PATCH 1/1] Bug 19962 - Introduce koha-sip to replace koha-*-sip + +--- + debian/scripts/koha-enable-sip | 25 +--- + debian/scripts/koha-sip | 280 +++++++++++++++++++++++++++++++++++++++++ + debian/scripts/koha-start-sip | 55 +------- + debian/scripts/koha-stop-sip | 32 +---- + 4 files changed, 289 insertions(+), 103 deletions(-) + create mode 100755 debian/scripts/koha-sip + +diff --git a/debian/scripts/koha-enable-sip b/debian/scripts/koha-enable-sip +index 1bcdd97571..a1c784cb97 100755 +--- a/debian/scripts/koha-enable-sip ++++ b/debian/scripts/koha-enable-sip +@@ -1,7 +1,7 @@ + #!/bin/sh + # +-# koha-enable-sip -- Set up the config files to allow SIP to run +-# Copyright 2012 Catalyst IT, Ltd ++# koha-start-sip -- Enable SIP server for named Koha instance (compat) ++# Copyright 2018 Punsarn Asia + # + # 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 +@@ -16,23 +16,4 @@ + # 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 ++koha-sip --enable $@ +diff --git a/debian/scripts/koha-sip b/debian/scripts/koha-sip +new file mode 100755 +index 0000000000..0d450f714f +--- /dev/null ++++ b/debian/scripts/koha-sip +@@ -0,0 +1,280 @@ ++#!/bin/bash ++# ++# koha-sip - Manage SIP Daemons for Koha instances ++# ++# Copyright 2015 Theke Solutions ++# Copyright 2018 Punsarn Asia ++# ++# This file is part of Koha. ++# ++# 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 <. + +-set -e +- +-# 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 +- +-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} +- +- adjust_paths_dev_install $name +- export KOHA_CONF PERL5LIB +- KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml +- # PERL5LIB has been read already +- if [ "$DEV_INSTALL" = "" ]; then +- LIBDIR=$KOHA_HOME/lib +- else +- LIBDIR=$KOHA_HOME +- fi +- +- 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 \ +- "$LIBDIR/C4/SIP/SIPServer.pm" \ +- "/etc/koha/sites/${name}/SIPconfig.xml" +-done ++koha-sip --start $@ +diff --git a/debian/scripts/koha-stop-sip b/debian/scripts/koha-stop-sip +index bfe7cd31c6..0cc885b854 100755 +--- a/debian/scripts/koha-stop-sip ++++ b/debian/scripts/koha-stop-sip +@@ -1,7 +1,7 @@ + #!/bin/sh + # +-# koha-stop-sip -- Stop SIP server for named Koha instance +-# Copyright 2012 Catalyst IT, Ltd ++# koha-start-sip -- Stop SIP server for named Koha instance (compat) ++# Copyright 2018 Punsarn Asia + # + # 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 +@@ -16,30 +16,4 @@ + # 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" +- 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 +-done ++koha-sip --stop $@ +-- +2.15.1 + diff --git a/debian/scripts/koha-enable-sip b/debian/scripts/koha-enable-sip index 1bcdd97571..393eabb94a 100755 --- a/debian/scripts/koha-enable-sip +++ b/debian/scripts/koha-enable-sip @@ -1,7 +1,7 @@ #!/bin/sh # -# koha-enable-sip -- Set up the config files to allow SIP to run -# Copyright 2012 Catalyst IT, Ltd +# koha-enable-sip -- Enable SIP server for named Koha instance (compat) +# Copyright 2018 Punsarn Asia # # 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 @@ -16,23 +16,4 @@ # 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 +koha-sip --enable $@ diff --git a/debian/scripts/koha-sip b/debian/scripts/koha-sip new file mode 100755 index 0000000000..0d450f714f --- /dev/null +++ b/debian/scripts/koha-sip @@ -0,0 +1,280 @@ +#!/bin/bash +# +# koha-sip - Manage SIP Daemons for Koha instances +# +# Copyright 2015 Theke Solutions +# Copyright 2018 Punsarn Asia +# +# This file is part of Koha. +# +# 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 <. -set -e - -# 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 - -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} - - adjust_paths_dev_install $name - export KOHA_CONF PERL5LIB - KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml - # PERL5LIB has been read already - if [ "$DEV_INSTALL" = "" ]; then - LIBDIR=$KOHA_HOME/lib - else - LIBDIR=$KOHA_HOME - fi - - 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 \ - "$LIBDIR/C4/SIP/SIPServer.pm" \ - "/etc/koha/sites/${name}/SIPconfig.xml" -done +koha-sip --start $@ diff --git a/debian/scripts/koha-stop-sip b/debian/scripts/koha-stop-sip index bfe7cd31c6..b1cb22b06f 100755 --- a/debian/scripts/koha-stop-sip +++ b/debian/scripts/koha-stop-sip @@ -1,7 +1,7 @@ #!/bin/sh # -# koha-stop-sip -- Stop SIP server for named Koha instance -# Copyright 2012 Catalyst IT, Ltd +# koha-stop-sip -- Stop SIP server for named Koha instance (compat) +# Copyright 2018 Punsarn Asia # # 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 @@ -16,30 +16,4 @@ # 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" - 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 -done +koha-sip --stop $@ -- 2.15.1