Bug 13947: Correct call to GetBiblio to receive correct return value
[koha.git] / debian / scripts / koha-functions.sh
blob8090fc534c47aec585713c4766cc07ee4a095424
1 #!/bin/sh
3 # koha-functions.sh -- shared library of helper functions for koha-* scripts
4 # Copyright 2014 - Tomas Cohen Arazi
5 # Universidad Nacional de Cordoba
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 die()
23 echo "$@" 1>&2
24 exit 1
27 warn()
29 echo "$@" 1>&2
32 get_apache_config_for()
34 local site=$1
35 local sitefile="/etc/apache2/sites-available/$site"
37 if is_instance $site; then
38 if [ -f "$sitefile.conf" ]; then
39 echo "$sitefile.conf"
40 elif [ -f "$sitefile" ]; then
41 echo "$sitefile"
46 is_enabled()
48 local site=$1
49 local instancefile=$(get_apache_config_for $site)
51 if [ "$instancefile" = "" ]; then
52 return 1
55 if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
56 "$instancefile" ; then
57 return 1
58 else
59 return 0
63 is_instance()
65 local instancename=$1
67 if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
68 -type d -printf '%f\n'\
69 | grep -q -x "$instancename" ; then
70 return 0
71 else
72 return 1
76 is_email_enabled()
78 local instancename=$1
80 if [ -e /var/lib/koha/$instancename/email.enabled ]; then
81 return 0
82 else
83 return 1
87 is_sip_enabled()
89 local instancename=$1
91 if [ -e /etc/koha/sites/$instancename/SIPconfig.xml ]; then
92 return 0
93 else
94 return 1
98 is_zebra_running()
100 local instancename=$1
102 if daemon --name="$instancename-koha-zebra" \
103 --user="$instancename-koha.$instancename-koha" \
104 --running ; then
105 return 0
106 else
107 return 1
111 is_indexer_running()
113 local instancename=$1
115 if daemon --name="$instancename-koha-indexer" \
116 --user="$instancename-koha.$instancename-koha" \
117 --running ; then
118 return 0
119 else
120 return 1
124 get_instances()
126 find /etc/koha/sites -mindepth 1 -maxdepth 1\
127 -type d -printf '%f\n' | sort