Lines 18-107
Link Here
|
18 |
|
18 |
|
19 |
set -e |
19 |
set -e |
20 |
|
20 |
|
21 |
die() |
21 |
# include helper functions |
22 |
{ |
22 |
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then |
23 |
echo "$@" 1>&2 |
23 |
. "/usr/share/koha/bin/koha-functions.sh" |
|
|
24 |
else |
25 |
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 |
24 |
exit 1 |
26 |
exit 1 |
25 |
} |
27 |
fi |
26 |
|
|
|
27 |
warn() |
28 |
{ |
29 |
echo "$@" 1>&2 |
30 |
} |
31 |
|
32 |
is_enabled() |
33 |
{ |
34 |
local instancename=$1 |
35 |
local instancefile="/etc/apache2/sites-available/$instancename.conf" |
36 |
|
37 |
if ! is_instance $instancename; then |
38 |
return 1 |
39 |
fi |
40 |
|
41 |
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \ |
42 |
"$instancefile" ; then |
43 |
return 1 |
44 |
else |
45 |
return 0 |
46 |
fi |
47 |
} |
48 |
|
49 |
is_instance() |
50 |
{ |
51 |
local instancename=$1 |
52 |
|
53 |
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \ |
54 |
-type d -printf '%f\n'\ |
55 |
| grep -q -x $instancename ; then |
56 |
return 0 |
57 |
else |
58 |
return 1 |
59 |
fi |
60 |
} |
61 |
|
62 |
is_zebra_running() |
63 |
{ |
64 |
local instancename=$1 |
65 |
|
66 |
if daemon --name="$instancename-koha-zebra" \ |
67 |
--user="$instancename-koha.$instancename-koha" \ |
68 |
--running ; then |
69 |
return 0 |
70 |
else |
71 |
return 1 |
72 |
fi |
73 |
} |
74 |
|
28 |
|
75 |
start_zebra_instance() |
29 |
start_zebra_instance() |
76 |
{ |
30 |
{ |
77 |
local instancename=$1 |
31 |
local instancename=$1 |
78 |
|
32 |
|
79 |
if is_enabled $instancename; then |
33 |
echo "Starting Zebra server for $instancename" |
80 |
echo "Starting Zebra server for $instancename" |
34 |
touch "/var/log/koha/$instancename/zebra-error.log" \ |
81 |
touch "/var/log/koha/$instancename/zebra-error.log" \ |
35 |
"/var/log/koha/$instancename/zebra.log" \ |
82 |
"/var/log/koha/$instancename/zebra.log" \ |
36 |
"/var/log/koha/$instancename/zebra-output.log" |
83 |
"/var/log/koha/$instancename/zebra-output.log" |
37 |
chown "$instancename-koha:$instancename-koha" \ |
84 |
chown "$instancename-koha:$instancename-koha" \ |
38 |
"/var/log/koha/$instancename/zebra-error.log" \ |
85 |
"/var/log/koha/$instancename/zebra-error.log" \ |
39 |
"/var/log/koha/$instancename/zebra.log" \ |
86 |
"/var/log/koha/$instancename/zebra.log" \ |
40 |
"/var/log/koha/$instancename/zebra-output.log" |
87 |
"/var/log/koha/$instancename/zebra-output.log" |
41 |
daemon \ |
88 |
daemon \ |
42 |
--name="$instancename-koha-zebra" \ |
89 |
--name="$instancename-koha-zebra" \ |
43 |
--errlog="/var/log/koha/$instancename/zebra-error.log" \ |
90 |
--errlog="/var/log/koha/$instancename/zebra-error.log" \ |
44 |
--stdout="/var/log/koha/$instancename/zebra.log" \ |
91 |
--stdout="/var/log/koha/$instancename/zebra.log" \ |
45 |
--output="/var/log/koha/$instancename/zebra-output.log" \ |
92 |
--output="/var/log/koha/$instancename/zebra-output.log" \ |
46 |
--verbose=1 \ |
93 |
--verbose=1 \ |
47 |
--respawn \ |
94 |
--respawn \ |
48 |
--delay=30 \ |
95 |
--delay=30 \ |
49 |
--user="$instancename-koha.$instancename-koha" \ |
96 |
--user="$instancename-koha.$instancename-koha" \ |
50 |
-- \ |
97 |
-- \ |
51 |
zebrasrv \ |
98 |
zebrasrv \ |
52 |
-v none,fatal,warn \ |
99 |
-v none,fatal,warn \ |
53 |
-f "/etc/koha/sites/$instancename/koha-conf.xml" && \ |
100 |
-f "/etc/koha/sites/$instancename/koha-conf.xml" && \ |
54 |
return 0 || \ |
101 |
return 0 |
|
|
102 |
else |
103 |
return 1 |
55 |
return 1 |
104 |
fi |
|
|
105 |
} |
56 |
} |
106 |
|
57 |
|
107 |
usage() |
58 |
usage() |