|
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=kivilahtio |
| 28 |
loggedInUser=`whoami` |
| 29 |
NAME=koha-api-daemon |
| 30 |
KOHA_PATH=/home/koha/kohaclone/ |
| 31 |
## See Koha/REST/V1.pm for more info about the environmental variables. |
| 32 |
export MOJO_CONFIG=$KOHA_PATH/api/v1/hypnotoad.conf |
| 33 |
#You get 3 logfiles here, .log, .stderr, .stdout |
| 34 |
export MOJO_LOGFILES=/home/koha/koha-dev/var/log/kohaapi.mojo |
| 35 |
export MOJO_LOGLEVEL=debug |
| 36 |
|
| 37 |
##ABOUT CHANGING THE process name/command visible by programs like 'top' and 'ps'. |
| 38 |
# |
| 39 |
# You can make a small incision to /usr/local/share/perl/5.14.2/Mojo/Server.pm or wherever your |
| 40 |
# Mojo::Server is located at. |
| 41 |
# Go to load_app(), and after perl code line |
| 42 |
# 60: FindBin->again; |
| 43 |
# add |
| 44 |
# $0 = 'koha-api-daemon'; |
| 45 |
# This renames all hypnotoad processes as koha-api-daemon. |
| 46 |
# No side-effects encoutered so far but minimal testing here! |
| 47 |
|
| 48 |
if [[ $EUID -ne 0 && $loggedInUser -ne $USER ]]; then |
| 49 |
echo "You must run this script as 'root' or as '$USER'"; |
| 50 |
exit 1; |
| 51 |
fi |
| 52 |
|
| 53 |
function start { |
| 54 |
echo "Starting Hypnotoad" |
| 55 |
su -c "hypnotoad $KOHA_PATH/api/v1/script.cgi" $USER |
| 56 |
echo "ALL GLORY TO THE HYPNOTOAD." |
| 57 |
} |
| 58 |
function stop { |
| 59 |
su -c "hypnotoad $KOHA_PATH/api/v1/script.cgi -s" $USER |
| 60 |
} |
| 61 |
|
| 62 |
case "$1" in |
| 63 |
start) |
| 64 |
start |
| 65 |
;; |
| 66 |
stop) |
| 67 |
stop |
| 68 |
;; |
| 69 |
restart) |
| 70 |
echo "Restarting Hypnotoad" |
| 71 |
stop |
| 72 |
start |
| 73 |
;; |
| 74 |
*) |
| 75 |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" |
| 76 |
exit 1 |
| 77 |
;; |
| 78 |
esac |