|
Line 0
Link Here
|
|
|
1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
### BEGIN INIT INFO |
| 19 |
# Provides: koha-zebra-daemon |
| 20 |
# Required-Start: $syslog $remote_fs |
| 21 |
# Required-Stop: $syslog $remote_fs |
| 22 |
# Default-Start: 2 3 4 5 |
| 23 |
# Default-Stop: 0 1 6 |
| 24 |
# Short-Description: Zebra server daemon for Koha indexing |
| 25 |
### END INIT INFO |
| 26 |
|
| 27 |
USER=ere |
| 28 |
GROUP=users |
| 29 |
DBNAME=koha3 |
| 30 |
NAME=koha-zebra-ctl.koha3 |
| 31 |
LOGDIR=/home/ere/koha-dev/var/log |
| 32 |
ERRLOG=$LOGDIR/koha-zebradaemon.err |
| 33 |
STDOUT=$LOGDIR/koha-zebradaemon.log |
| 34 |
OUTPUT=$LOGDIR/koha-zebradaemon-output.log |
| 35 |
KOHA_CONF=/home/ere/koha-dev/etc/koha-conf.xml |
| 36 |
RUNDIR=/home/ere/koha-dev/var/run |
| 37 |
LOCKDIR=/home/ere/koha-dev/var/lock |
| 38 |
# you may need to change this depending on where zebrasrv is installed |
| 39 |
ZEBRASRV=/usr/bin/zebrasrv |
| 40 |
ZEBRAOPTIONS="-v none,fatal,warn" |
| 41 |
|
| 42 |
test -f $ZEBRASRV || exit 0 |
| 43 |
|
| 44 |
OTHERUSER='' |
| 45 |
if [[ $EUID -eq 0 ]]; then |
| 46 |
OTHERUSER="--user=$USER.$GROUP" |
| 47 |
fi |
| 48 |
|
| 49 |
case "$1" in |
| 50 |
start) |
| 51 |
echo "Starting Zebra Server" |
| 52 |
|
| 53 |
# create run and lock directories if needed; |
| 54 |
# /var/run and /var/lock are completely cleared at boot |
| 55 |
# on some platforms |
| 56 |
if [[ ! -d $RUNDIR ]]; then |
| 57 |
umask 022 |
| 58 |
mkdir -p $RUNDIR |
| 59 |
if [[ $EUID -eq 0 ]]; then |
| 60 |
chown $USER:$GROUP $RUNDIR |
| 61 |
fi |
| 62 |
fi |
| 63 |
if [[ ! -d $LOCKDIR ]]; then |
| 64 |
umask 022 |
| 65 |
mkdir -p $LOCKDIR |
| 66 |
mkdir -p $LOCKDIR/biblios |
| 67 |
mkdir -p $LOCKDIR/authorities |
| 68 |
mkdir -p $LOCKDIR/rebuild |
| 69 |
if [[ $EUID -eq 0 ]]; then |
| 70 |
chown -R $USER:$GROUP $LOCKDIR |
| 71 |
fi |
| 72 |
fi |
| 73 |
|
| 74 |
daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV $ZEBRAOPTIONS -f $KOHA_CONF |
| 75 |
;; |
| 76 |
stop) |
| 77 |
echo "Stopping Zebra Server" |
| 78 |
daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- $ZEBRASRV -f $KOHA_CONF |
| 79 |
;; |
| 80 |
restart) |
| 81 |
echo "Restarting the Zebra Server" |
| 82 |
daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- $ZEBRASRV -f $KOHA_CONF |
| 83 |
;; |
| 84 |
*) |
| 85 |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" |
| 86 |
exit 1 |
| 87 |
;; |
| 88 |
esac |