Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / rpmbuild / ace-tao-init-suse / init.d / tao-costrading
blobe1fc7f1ebdef73f52d701372ab54209f3ae1a149
1 #!/bin/bash
3 # /etc/init.d/tao-cosnotification
4 # and its symbolic link
5 # /(usr/)sbin/rctao-cosnotification
7 # system startup script for service/daemon TAO-cosnotification
9 # LSB compatible service control script; see http://www.linuxbase.org/spec/
11 ### BEGIN INIT INFO
12 # Provides: tao-costrading
13 # Required-Start: $syslog $remote_fs $network tao-cosnaming
14 # Should-Start: $time ypbind smtp
15 # Required-Stop: $syslog $remote_fs tao-cosnaming
16 # Should-Stop: $time ypbind smtp
17 # Default-Start: 3 5
18 # Default-Stop: 0 1 2 6
19 # Short-Description: Starts and stops the TAO Trading Service.
20 # Description: Start tao-costrading, the TAO Trading Service.
21 ### END INIT INFO
23 # Check for missing binaries (stale symlinks should not happen)
24 # Note: Special treatment of stop for LSB conformance
25 TAO_COSTRADING_BIN=/usr/sbin/tao-costrading
27 test -x $TAO_COSTRADING_BIN || { echo "$TAO_COSTRADING_BIN not installed";
28 if [ "$1" = "stop" ]; then exit 0;
29 else exit 5; fi; }
31 # Check for existence of needed config file and read it
32 TAO_COSTRADING_CONFIG=/etc/tao/tao-costrading
34 test -r $TAO_COSTRADING_CONFIG || { echo "$TAO_COSTRADING_CONFIG not existing";
35 if [ "$1" = "stop" ]; then exit 0;
36 else exit 6; fi; }
38 # Read config
39 . $TAO_COSTRADING_CONFIG
41 # Source LSB init functions
42 # providing start_daemon, killproc, pidofproc,
43 # log_success_msg, log_failure_msg and log_warning_msg.
44 # This is currently not used by UnitedLinux based distributions and
45 # not needed for init scripts for UnitedLinux only. If it is used,
46 # the functions from rc.status should not be sourced or used.
47 #. /lib/lsb/init-functions
49 # Shell functions sourced from /etc/rc.status:
50 # rc_check check and set local and overall rc status
51 # rc_status check and set local and overall rc status
52 # rc_status -v be verbose in local rc status and clear it afterwards
53 # rc_status -v -r ditto and clear both the local and overall rc status
54 # rc_status -s display "skipped" and exit with status 3
55 # rc_status -u display "unused" and exit with status 3
56 # rc_failed set local and overall rc status to failed
57 # rc_failed <num> set local and overall rc status to <num>
58 # rc_reset clear both the local and overall rc status
59 # rc_exit exit appropriate to overall rc status
60 # rc_active checks whether a service is activated by symlinks
61 . /etc/rc.status
63 # Reset status of this service
64 rc_reset
66 # Return values acc. to LSB for all commands but status:
67 # 0 - success
68 # 1 - generic or unspecified error
69 # 2 - invalid or excess argument(s)
70 # 3 - unimplemented feature (e.g. "reload")
71 # 4 - user had insufficient privileges
72 # 5 - program is not installed
73 # 6 - program is not configured
74 # 7 - program is not running
75 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
77 # Note that starting an already running service, stopping
78 # or restarting a not-running service as well as the restart
79 # with force-reload (in case signaling is not supported) are
80 # considered a success.
81 prog=tao-costrading
82 svcname="TAO trading service"
83 svcconf="/etc/tao/${prog}.conf"
84 OPTIONS="$TAO_COSTRADING_INITREF $TAO_COSTRADING_DEBUGLEVEL $TAO_COSTRADING_LOGFILE"
86 case "$1" in
87 start)
88 echo -n "Starting $svcname: "
89 ## Start daemon with startproc(8). If this fails
90 ## the return value is set appropriately by startproc.
91 /sbin/startproc $TAO_COSTRADING_BIN $OPTIONS -ORBSvcConf $svcconf -ORBDaemon
93 # Remember status and be verbose
94 rc_status -v
96 stop)
97 echo -n "Shutting down $svcname: "
98 ## Stop daemon with killproc(8) and if this fails
99 ## killproc sets the return value according to LSB.
101 /sbin/killproc -TERM $TAO_COSTRADING_BIN
103 # Remember status and be verbose
104 rc_status -v
106 try-restart|condrestart)
107 ## Do a restart only if the service was active before.
108 ## Note: try-restart is now part of LSB (as of 1.9).
109 ## RH has a similar command named condrestart.
110 if test "$1" = "condrestart"; then
111 echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
113 $0 status
114 if test $? = 0; then
115 $0 restart
116 else
117 rc_reset # Not running is not a failure.
119 # Remember status and be quiet
120 rc_status
122 restart)
123 ## Stop the service and regardless of whether it was
124 ## running or not, start it again.
125 $0 stop
126 $0 start
128 # Remember status and be quiet
129 rc_status
131 force-reload)
132 ## Signal the daemon to reload its config. Most daemons
133 ## do this on signal 1 (SIGHUP).
134 ## If it does not support it, restart the service if it
135 ## is running.
137 echo -n "Reloading $svcname "
138 ## if it supports it:
139 /sbin/killproc -HUP $TAO_COSTRADING_BIN
140 #touch /var/run/FOO.pid
141 rc_status -v
143 ## Otherwise:
144 #$0 try-restart
145 #rc_status
147 reload)
148 ## Like force-reload, but if daemon does not support
149 ## signaling, do nothing (!)
151 # If it supports signaling:
152 echo -n "Reloading $svcname "
153 /sbin/killproc -HUP $TAO_COSTRADING_BIN
154 #touch /var/run/FOO.pid
155 rc_status -v
157 ## Otherwise if it does not support reload:
158 #rc_failed 3
159 #rc_status -v
161 status)
162 echo -n "Checking for $svcname "
163 ## Check status with checkproc(8), if process is running
164 ## checkproc will return with exit status 0.
166 # Return value is slightly different for the status command:
167 # 0 - service up and running
168 # 1 - service dead, but /var/run/ pid file exists
169 # 2 - service dead, but /var/lock/ lock file exists
170 # 3 - service not running (unused)
171 # 4 - service status unknown :-(
172 # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
174 # NOTE: checkproc returns LSB compliant status values.
175 /sbin/checkproc $TAO_COSTRADING_BIN
176 # NOTE: rc_status knows that we called this init script with
177 # "status" option and adapts its messages accordingly.
178 rc_status -v
180 probe)
181 ## Optional: Probe for the necessity of a reload, print out the
182 ## argument to this init script which is required for a reload.
183 ## Note: probe is not (yet) part of LSB (as of 1.9)
185 test $svcconf -nt /var/run/tao-costrading.pid && echo reload
188 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
189 exit 1
191 esac
192 rc_exit