File: jserv.init

package info (click to toggle)
jserv 1.1.2-2
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 4,584 kB
  • ctags: 3,019
  • sloc: sh: 7,715; java: 6,635; ansic: 5,013; makefile: 814; perl: 39; xml: 32
file content (108 lines) | stat: -rw-r--r-- 2,887 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/sh -e
#
# /etc/init.d/jserv
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux	by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for JServ by Stefan Gybas <sgybas@debian.org>.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=jserv
DESC="JServ servlet engine"
PIDFILE="/var/run/$NAME.pid"
DEFAULT_USER=www-data
CLASS=org.apache.jserv.JServ
CONFIG=/etc/jserv/jserv.conf
PROPERTIES=/etc/jserv/jserv.properties
APACHECONF=/etc/apache/httpd.conf

test -f $CONFIG || exit 0
test -f $PROPERTIES || exit 0

# Start only if jserv.conf contains "ApJServManual on"
if ! grep -q "^ApJServManual[[:space:]]\+on" $CONFIG; then
	exit 0
fi

# Get java interpreter from jserv.properties (or use default value)
DAEMON=`grep "^wrapper.bin=" $PROPERTIES | cut -f2 -d=`
[ -z "$DAEMON" ] && DAEMON=/usr/bin/java

test -f $DAEMON || exit 0

# Get java parameters from jserv.properties
PARAM=`grep "^wrapper.bin.parameters=" $PROPERTIES | cut -f2- -d=`

# Get the log file from jserv.properties (or use default value)
LOGFILE=`grep "^log.file=" $PROPERTIES | cut -f2- -d=`
[ -z "$LOGFILE" ] && LOGFILE=/var/log/jserv.log

# Get classpath from jserv.properties
for path in `grep "^wrapper.classpath=" $PROPERTIES | cut -f2 -d=`; do
	if [ "$CLASSPATH" ]; then
		CLASSPATH=$CLASSPATH:$path
	else
		CLASSPATH=$path
	fi
done
export CLASSPATH

# Get the user under which Apache is running from /etc/apache/httpd.conf
if [ -f $APACHECONF ]; then
	WWWUSER=`grep "^User " $APACHECONF | cut -f2 -d\ `
fi
[ -z "$WWWUSER" ] && WWWUSER=$DEFAULT_USER

case "$1" in
  start)
	echo -n "Starting $DESC: "
	touch $PIDFILE $LOGFILE
	chown $WWWUSER $PIDFILE $LOGFILE
	chmod 664 $LOGFILE
	if start-stop-daemon --test --start --pidfile $PIDFILE \
		--user $WWWUSER --startas $DAEMON > /dev/null; then
		/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE \
			--make-pidfile --chuid $WWWUSER --exec $DAEMON -- \
			$PARAM $CLASS $PROPERTIES >>$LOGFILE 2>&1 &
		echo "$NAME."
	else
		echo "(already running)."
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE \
		--user $WWWUSER
	rm -f $PIDFILE
	echo "$NAME."
	;;
  reload)
	echo -n "Reloading $DESC configuration files... "
	if ! start-stop-daemon --test --start --pidfile $PIDFILE \
		--user $WWWUSER --startas $DAEMON > /dev/null; then
	
#
# Upstream bug: this is currently not working  :-((
#
#		/sbin/start-stop-daemon --start --quiet \
#			--pidfile $PIDFILE \
#			--exec $DAEMON -- $CLASS $PROPERTIES -r > /dev/null
#		echo "done."
		echo "currently not working"
	else
		echo "(not running)"
	fi
  	;;
  restart|force-reload)
	$0 stop
	sleep 1
	$0 start
	;;
  *)
	#echo "Usage: /etc/init.d/jserv {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: /etc/init.d/jserv {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0