Line 0
Link Here
|
0 |
- |
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-api-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: Hypnotoad Mojolicious Server for handling Koha API requests |
25 |
### END INIT INFO |
26 |
|
27 |
USER=__KOHA_USER__ |
28 |
loggedInUser=`whoami` |
29 |
NAME=koha-api-daemon |
30 |
KOHA_PATH=__INTRANET_WWW_DIR__ |
31 |
|
32 |
test -f $ZEBRASRV || exit 0 |
33 |
|
34 |
OTHERUSER='' |
35 |
if [[ $EUID -ne 0 && $loggedInUser -ne $USER ]]; then |
36 |
echo "You must run this script as 'root' or as '$USER'"; |
37 |
exit 1; |
38 |
fi |
39 |
|
40 |
function start { |
41 |
echo "Starting Hypnotoad" |
42 |
echo "ALL GLORY TO THE HYPNOTOAD." |
43 |
su -c "hypnotoad $PERL5LIB/api/v1/script.cgi" $USER |
44 |
} |
45 |
function stop { |
46 |
echo "Stopping Hypnotoad" |
47 |
su -c "hypnotoad $PERL5LIB/api/v1/script.cgi -s" $USER |
48 |
} |
49 |
|
50 |
case "$1" in |
51 |
start) |
52 |
start |
53 |
;; |
54 |
stop) |
55 |
stop |
56 |
;; |
57 |
restart) |
58 |
echo "Restarting Hypnotoad" |
59 |
stop |
60 |
start |
61 |
;; |
62 |
*) |
63 |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" |
64 |
exit 1 |
65 |
;; |
66 |
esac |