debian-apache-tika – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #! /bin/sh |
2 | ### BEGIN INIT INFO |
||
3 | # Provides: tika |
||
4 | # Required-Start: $remote_fs $syslog |
||
5 | # Required-Stop: $remote_fs $syslog |
||
6 | # Default-Start: 2 3 4 5 |
||
7 | # Default-Stop: 0 1 6 |
||
8 | # Short-Description: Apache tika content indexing. |
||
9 | # Description: This file starts the Apache tika server. |
||
10 | ### END INIT INFO |
||
11 | |||
12 | # Author: Wizardry and Steamworks <office@grimore.org> |
||
13 | |||
14 | # Do NOT "set -e" |
||
15 | |||
16 | # Skip systemd redirect. |
||
17 | _SYSTEMCTL_SKIP_REDIRECT=OHYES |
||
18 | |||
19 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
||
3 | office | 20 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
21 | DESC="Apache Tika content indexing" |
||
1 | office | 22 | NAME=tika |
23 | DAEMON=/usr/bin/java |
||
24 | PIDFILE=/var/run/$NAME.pid |
||
25 | SCRIPTNAME=/etc/init.d/$NAME |
||
26 | |||
27 | # Exit if the package is not installed |
||
3 | office | 28 | [ -x "$DAEMON" ] || exit 0 |
1 | office | 29 | |
30 | # Read configuration variable file if it is present |
||
31 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME |
||
32 | |||
33 | # Load the VERBOSE setting and other rcS variables |
||
34 | . /lib/init/vars.sh |
||
35 | |||
36 | # Define LSB log_* functions. |
||
37 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present |
||
38 | # and status_of_proc is working. |
||
39 | . /lib/lsb/init-functions |
||
3 | office | 40 | |
41 | # Turn on berbose logging. |
||
42 | VERBOSE=yes |
||
43 | # Daemon arguments. |
||
44 | DAEMON_ARGS="-jar /usr/share/java/tika-server.jar -h ${HOST} -p ${PORT}" |
||
45 | |||
1 | office | 46 | # |
47 | # Function that starts the daemon/service |
||
48 | # |
||
49 | do_start() |
||
50 | { |
||
3 | office | 51 | # Return |
52 | # 0 if daemon has been started |
||
53 | # 1 if daemon was already running |
||
54 | # 2 if daemon could not be started |
||
55 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1 |
||
56 | start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON --background --chuid tika --group tika --startas $DAEMON -- $DAEMON_ARGS > /dev/null || return 2 |
||
1 | office | 57 | } |
3 | office | 58 | |
1 | office | 59 | do_stop() |
60 | { |
||
3 | office | 61 | # Return |
62 | # 0 if daemon has been stopped |
||
63 | # 1 if daemon was already stopped |
||
64 | # 2 if daemon could not be stopped |
||
65 | # other if a failure occurred |
||
66 | start-stop-daemon --quiet --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $DAEMON |
||
67 | RETVAL="$?" |
||
68 | [ "$RETVAL" = 2 ] && return 2 |
||
69 | # Wait for children to finish too if this is a daemon that forks |
||
70 | # and if the daemon is only ever run from this initscript. |
||
71 | # If the above conditions are not satisfied then add some other code |
||
72 | # that waits for the process to drop all resources that could be |
||
73 | # needed by services started subsequently. A last resort is to |
||
74 | # sleep for some time. |
||
75 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON |
||
76 | [ "$?" = 2 ] && return 2 |
||
77 | # Many daemons don't delete their pidfiles when they exit. |
||
78 | rm -f $PIDFILE |
||
79 | return "$RETVAL" |
||
1 | office | 80 | } |
3 | office | 81 | |
1 | office | 82 | case "$1" in |
83 | start) |
||
3 | office | 84 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
85 | do_start |
||
86 | case "$?" in |
||
87 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
||
88 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
||
89 | esac |
||
90 | ;; |
||
1 | office | 91 | stop) |
3 | office | 92 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
93 | do_stop |
||
94 | case "$?" in |
||
95 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
||
96 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
||
97 | esac |
||
98 | ;; |
||
1 | office | 99 | restart|force-reload) |
3 | office | 100 | log_daemon_msg "Restarting $DESC" "$NAME" |
101 | do_stop |
||
102 | case "$?" in |
||
103 | 0|1) |
||
104 | do_start |
||
105 | case "$?" in |
||
106 | 0) log_end_msg 0 ;; |
||
107 | 1) log_end_msg 1 ;; # Old process is still running |
||
108 | *) log_end_msg 1 ;; # Failed to start |
||
109 | esac |
||
110 | ;; |
||
111 | *) |
||
112 | # Failed to stop |
||
113 | log_end_msg 1 |
||
114 | ;; |
||
115 | esac |
||
116 | ;; |
||
1 | office | 117 | *) |
3 | office | 118 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
119 | exit 3 |
||
120 | ;; |
||
1 | office | 121 | esac |