File java.binfmt_misc of Package jpackage-utils
x
1
#!/bin/sh
2
#
3
# Template SUSE system startup script for example service/daemon java.binfmt_misc
4
# Copyright (C) 1995--2005 Kurt Garloff, SUSE / Novell Inc.
5
#
6
# This library is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU Lesser General Public License as published by
8
# the Free Software Foundation; either version 2.1 of the License, or (at
9
# your option) any later version.
10
#
11
# This library is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public
17
# License along with this library; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
19
# USA.
20
#
21
# /etc/init.d/java.binfmt_misc
22
# and its symbolic link
23
# /(usr/)sbin/rcjava.binfmt_misc
24
#
25
# Template system startup script for some example service/daemon java.binfmt_misc
26
#
27
# LSB compatible service control script; see http://www.linuxbase.org/spec/
28
#
29
#
30
### BEGIN INIT INFO
31
# Provides: java.binfmt_misc
32
# Required-Start:
33
# Should-Start:
34
# Required-Stop:
35
# Should-Stop:
36
# Default-Start: 3 5
37
# Default-Stop: 0 1 2 6
38
# Short-Description: enables the system to automatically execute java *.jar and *.class files
39
# Description: Start java.binfmt_misc to allow the execution of java programs with *.class or *.jar extension
40
### END INIT INFO
41
42
43
# Check for missing binaries (stale symlinks should not happen)
44
# Note: Special treatment of stop for LSB conformance
45
for file in /usr/bin/javawrapper /usr/bin/jarwrapper /usr/bin/javaclassname
46
do
47
test -x $file || { echo "$file not installed";
48
if [ "$1" = "stop" ]; then exit 0;
49
else exit 5; fi; }
50
done
51
52
# Check for existence of needed config file and read it
53
#java.binfmt_misc_CONFIG=/etc/sysconfig/java.binfmt_misc
54
#test -r $java.binfmt_misc_CONFIG || { echo "$java.binfmt_misc_CONFIG not existing";
55
# if [ "$1" = "stop" ]; then exit 0;
56
# else exit 6; fi; }
57
58
# Read config
59
#. $java.binfmt_misc_CONFIG
60
61
# Source LSB init functions
62
# providing start_daemon, killproc, pidofproc,
63
# log_success_msg, log_failure_msg and log_warning_msg.
64
# This is currently not used by UnitedLinux based distributions and
65
# not needed for init scripts for UnitedLinux only. If it is used,
66
# the functions from rc.status should not be sourced or used.
67
#. /lib/lsb/init-functions
68
69
# Shell functions sourced from /etc/rc.status:
70
# rc_check check and set local and overall rc status
71
# rc_status check and set local and overall rc status
72
# rc_status -v be verbose in local rc status and clear it afterwards
73
# rc_status -v -r ditto and clear both the local and overall rc status
74
# rc_status -s display "skipped" and exit with status 3
75
# rc_status -u display "unused" and exit with status 3
76
# rc_failed set local and overall rc status to failed
77
# rc_failed <num> set local and overall rc status to <num>
78
# rc_reset clear both the local and overall rc status
79
# rc_exit exit appropriate to overall rc status
80
# rc_active checks whether a service is activated by symlinks
81
. /etc/rc.status
82
83
# Reset status of this service
84
rc_reset
85
86
# Return values acc. to LSB for all commands but status:
87
# 0 - success
88
# 1 - generic or unspecified error
89
# 2 - invalid or excess argument(s)
90
# 3 - unimplemented feature (e.g. "reload")
91
# 4 - user had insufficient privileges
92
# 5 - program is not installed
93
# 6 - program is not configured
94
# 7 - program is not running
95
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
96
#
97
# Note that starting an already running service, stopping
98
# or restarting a not-running service as well as the restart
99
# with force-reload (in case signaling is not supported) are
100
# considered a success.
101
102
case "$1" in
103
start)
104
echo -n "Starting java.binfmt_misc "
105
106
# Insert BINFMT_MISC module into the kernel
107
if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
108
/sbin/modprobe binfmt_misc
109
# Some distributions, like Fedora Core, perform
110
# the following command automatically when the
111
# binfmt_misc module is loaded into the kernel.
112
# Thus, it is possible that the following line
113
# is not needed at all. Look at /etc/modprobe.conf
114
# to check whether this is applicable or not.
115
if ! mount | grep binfmt
116
then
117
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
118
fi
119
fi
120
121
# Register support for class and jar files
122
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
123
# support for Java applications:
124
if [ -e /proc/sys/fs/binfmt_misc/Java ]
125
then
126
echo 1 > /proc/sys/fs/binfmt_misc/Java
127
else
128
echo ':Java:M::\xca\xfe\xba\xbe::/usr/bin/javawrapper:' > /proc/sys/fs/binfmt_misc/register
129
fi
130
# support for executable Jar files:
131
if [ -e /proc/sys/fs/binfmt_misc/ExecutableJAR ]
132
then
133
echo 1 > /proc/sys/fs/binfmt_misc/ExecutableJAR
134
else
135
echo ':ExecutableJAR:E::jar::/usr/bin/jarwrapper:' > /proc/sys/fs/binfmt_misc/register
136
fi
137
# support for executable javaws
138
if [ -e /proc/sys/fs/binfmt_misc/JavaWebStart ]
139
then
140
echo 1 > /proc/sys/fs/binfmt_misc/JavaWebStart
141
else
142
echo ':JavaWebStart:E::jnlp::/usr/bin/javawswrapper:' > /proc/sys/fs/binfmt_misc/register
143
fi
144
echo 1 > /proc/sys/fs/binfmt_misc/status
145
## support for Java Applets:
146
# ':Applet:E::html::/usr/bin/appletviewer:'
147
##or the following, if you want to be more selective:
148
# ':Applet:M::<!--applet::/usr/bin/appletviewer:'
149
else
150
echo "No binfmt_misc support"
151
exit 1
152
fi
153
154
155
# Remember status and be verbose
156
rc_status -v
157
;;
158
stop)
159
echo -n "Shutting down java.binfmt_misc "
160
# Register support for class and jar files
161
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
162
# support for Java applications:
163
echo -1 > /proc/sys/fs/binfmt_misc/Java
164
# support for executable Jar files:
165
echo -1 > /proc/sys/fs/binfmt_misc/ExecutableJAR
166
# support for javaws
167
echo -1 > /proc/sys/fs/binfmt_misc/JavaWebStart
168
## support for Java Applets:
169
# ':Applet:E::html::/usr/bin/appletviewer:'
170
##or the following, if you want to be more selective:
171
# ':Applet:M::<!--applet::/usr/bin/appletviewer:'
172
else
173
echo "No binfmt_misc support"
174
exit 1
175
fi
176
177
178
# Remember status and be verbose
179
rc_status -v
180
;;
181
try-restart|condrestart)
182
## Do a restart only if the service was active before.
183
## Note: try-restart is now part of LSB (as of 1.9).
184
## RH has a similar command named condrestart.
185
if test "$1" = "condrestart"; then
186
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
187
fi
188
$0 status
189
if test $? = 0; then
190
$0 restart
191
else
192
rc_reset # Not running is not a failure.
193
fi
194
# Remember status and be quiet
195
rc_status
196
;;
197
restart)
198
## Stop the service and regardless of whether it was
199
## running or not, start it again.
200
$0 stop
201
$0 start
202
203
# Remember status and be quiet
204
rc_status
205
;;
206
force-reload)
207
## Signal the daemon to reload its config. Most daemons
208
## do this on signal 1 (SIGHUP).
209
## If it does not support it, restart the service if it
210
## is running.
211
212
echo -n "Reload service java.binfmt_misc "
213
## if it supports it:
214
/sbin/killproc -HUP $java.binfmt_misc_BIN
215
#touch /var/run/java.binfmt_misc.pid
216
rc_status -v
217
218
## Otherwise:
219
#$0 try-restart
220
#rc_status
221
;;
222
reload)
223
## Like force-reload, but if daemon does not support
224
## signaling, do nothing (!)
225
226
# If it supports signaling:
227
echo -n "Reload service java.binfmt_misc "
228
/sbin/killproc -HUP $java.binfmt_misc_BIN
229
#touch /var/run/java.binfmt_misc.pid
230
rc_status -v
231
232
## Otherwise if it does not support reload:
233
#rc_failed 3
234
#rc_status -v
235
;;
236
status)
237
echo -n "Checking for service java.binfmt_misc "
238
## Check status with checkproc(8), if process is running
239
## checkproc will return with exit status 0.
240
241
# Return value is slightly different for the status command:
242
# 0 - service up and running
243
# 1 - service dead, but /var/run/ pid file exists
244
# 2 - service dead, but /var/lock/ lock file exists
245
# 3 - service not running (unused)
246
# 4 - service status unknown :-(
247
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
248
249
# NOTE: checkproc returns LSB compliant status values.
250
/sbin/checkproc $java.binfmt_misc_BIN
251
# NOTE: rc_status knows that we called this init script with
252
# "status" option and adapts its messages accordingly.
253
rc_status -v
254
;;
255
probe)
256
## Optional: Probe for the necessity of a reload, print out the
257
## argument to this init script which is required for a reload.
258
## Note: probe is not (yet) part of LSB (as of 1.9)
259
260
test /etc/java.binfmt_misc/java.binfmt_misc.conf -nt /var/run/java.binfmt_misc.pid && echo reload
261
;;
262
*)
263
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
264
exit 1
265
;;
266
esac
267
rc_exit
268