25
|
1 #! /bin/sh
|
|
2 #
|
|
3
|
|
4 . /etc/rc.config
|
|
5
|
|
6 # Determine the base and follow a runlevel link name.
|
|
7 base=${0##*/}
|
|
8 link=${base#*[SK][0-9][0-9]}
|
|
9
|
|
10 # Force execution if not called by a runlevel directory.
|
|
11 #test $link = $base && START_XNTPD=yes
|
|
12 #test "$START_XNTPD" = yes || exit 0
|
|
13
|
|
14 TOMCAT_PID="";
|
|
15
|
|
16 function tomcat_runs() {
|
|
17 # we're looking at java vms executing org.apache.catalina.startup.Bootstrap
|
|
18 ALL_TOMS=$( ps xa|grep org.apache.catalina.startup.Bootstrap|grep -v grep )
|
|
19 ALL_TOM_IDS=$( echo $ALL_TOMS | cut -d " " -f 1 )
|
|
20 TOMCAT_PID=$( echo $ALL_TOM_IDS | head -1 )
|
|
21 test -n "$TOMCAT_PID"
|
|
22 }
|
|
23
|
|
24 #
|
|
25 # docuservers tomcat (ROC 2.11.01)
|
|
26 #
|
|
27 TOMCATLOG=/usr/local/httpd/logs/tomcat-err.log
|
|
28 TOMCATDIR=/opt/tomcat
|
|
29
|
|
30 return="$rc_done"
|
|
31
|
|
32 case "$1" in
|
|
33 start)
|
|
34 echo -n "Starting Tomcat Servlet server "
|
|
35 su - wwwrun -c "$TOMCATDIR/bin/startup.sh" >> $TOMCATLOG 2>&1 || return=$rc_failed
|
|
36 echo -e "$return"
|
|
37 ;;
|
|
38 stop)
|
|
39 echo -n "Stopping Tomcat Servlet server "
|
|
40 if su - wwwrun -c "$TOMCATDIR/bin/shutdown.sh" >> $TOMCATLOG 2>&1
|
|
41 then
|
|
42 for i in 1 2 3 4 5
|
|
43 do
|
|
44 if tomcat_runs
|
|
45 then
|
|
46 return=$rc_failed
|
|
47 echo -n "."
|
|
48 sleep 2
|
|
49 else
|
|
50 return=$rc_done
|
|
51 break
|
|
52 fi
|
|
53 done
|
|
54 if tomcat_runs
|
|
55 then
|
|
56 echo -n " killing."
|
|
57 kill $TOMCAT_PID
|
|
58 sleep 2
|
|
59 fi
|
|
60 if tomcat_runs
|
|
61 then
|
|
62 return=$rc_failed
|
|
63 else
|
|
64 return=$rc_done
|
|
65 fi
|
|
66 else
|
|
67 return=$rc_failed
|
|
68 fi
|
|
69
|
|
70 echo -e "$return"
|
|
71 ;;
|
|
72 reload|restart)
|
|
73 $0 stop && $0 start || return=$rc_failed
|
|
74 ;;
|
|
75 status)
|
|
76 echo -n "Checking for service tomcat: "
|
|
77 tomcat_runs && echo OK || echo No process
|
|
78 ;;
|
|
79 *)
|
|
80 echo "Usage: $0 {start|stop|status|reload|restart}"
|
|
81 exit 1
|
|
82 esac
|
|
83
|
|
84 # Inform the caller not only verbosely and set an exit status.
|
|
85 test "$return" = "$rc_done" || exit 1
|
|
86 exit 0
|