]> git.pld-linux.org Git - packages/apache-tomcat.git/blob - apache-tomcat.init
- add status
[packages/apache-tomcat.git] / apache-tomcat.init
1 #!/bin/sh
2 #
3 # tomcat        Jakarta Tomcat Servlet/JSP container
4 #
5 # chkconfig:    345  84 16
6 #
7 # description:  Jakarta Tomcat Servlet/JSP container
8 #
9 # $Id$
10
11
12 # Source function library
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Get service config - may override defaults
19 [ -f /etc/sysconfig/tomcat ] && . /etc/sysconfig/tomcat
20
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24                 msg_network_down tomcat
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 start() {
32         # Check if the service is already running?
33         if [ ! -f /var/lock/subsys/tomcat ]; then
34                 msg_starting tomcat
35                 busy
36                 su tomcat -s /bin/sh -c '/usr/share/tomcat/bin/catalina.sh start' >/dev/null 2>&1
37                 [ $? -ne 0 ] && RETVAL=1
38                 if [ $RETVAL -eq 0 ]; then
39                         ok
40                         touch /var/lock/subsys/tomcat
41                 else
42                         fail
43                 fi
44         else
45                 msg_already_running tomcat
46         fi
47 }
48
49 stop() {
50         if [ -f /var/lock/subsys/tomcat ]; then
51                 # Stop daemons.
52                 msg_stopping tomcat
53                 busy
54                 su tomcat -s /bin/sh -c '/usr/share/tomcat/bin/catalina.sh stop' >/dev/null 2>&1
55                 [ $? -eq 0 ] && ok || fail
56                 rm -f /var/lock/subsys/tomcat
57         else
58                 msg_not_running tomcat
59         fi
60 }
61
62 condrestart() {
63         if [ -f /var/lock/subsys/tomcat ]; then
64                 stop
65                 start
66         else
67                 msg_not_running tomcat
68                 RETVAL=$1
69         fi
70 }
71
72 RETVAL=0
73 # See how we were called.
74 case "$1" in
75   start)
76         start
77         ;;
78   stop)
79         stop
80         ;;
81   restart)
82         stop
83         start
84         ;;
85   try-restart)
86         condrestart 0
87         ;;
88   force-reload)
89         condrestart 7
90         ;;
91   status)
92         status tomcat java
93         RETVAL=0
94         ;;
95   *)
96         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
97         exit 3
98 esac
99
100 exit $RETVAL
This page took 0.095378 seconds and 3 git commands to generate.