forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root-system-xrootd.init.in
224 lines (210 loc) · 5.63 KB
/
root-system-xrootd.init.in
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#! /bin/sh
#
# skeleton Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
### BEGIN INIT INFO
# Provides: root-system-xrootd
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Should-Start: $network, $remote_fs, $named
# Should-Stop: $network, $remote_fs, $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Extended ROOT file server
# Description: Extended Server of ROOT files via special ROOT
# protocol, and Open Load Balancer server.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
XDAEMON=@prefix@/bin/xrootd
ODAEMON=@prefix@/bin/olbd
CDAEMON=@prefix@/bin/cmsd
XNAME=xrootd
ONAME=olbd
CNAME=cmsd
DESC="Extended ROOT file server"
XDESC="Extended ROOT file server"
ODESC="Open Load Balancer server"
CDESC="Cluster Management System server"
USER=root
test -x $DAEMON || exit 0
# Include root defaults if available
if [ -f @sysconfdir@/default/root-system-xrootd ] ; then
. @sysconfdir@/default/root-system-xrootd
fi
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
# Define LSB log_* functions.
. /lib/lsb/init-functions
# Check enables
enable_xrootd=`echo $ENABLE_XROOTD | tr '[:upper:]' '[:lower:]'`
enable_olbd=`echo $ENABLE_OLBD| tr '[:upper:]' '[:lower:]'`
enable_cmsd=`echo $ENABLE_CMSD| tr '[:upper:]' '[:lower:]'`
# xrood options
# Configuration file
if test "x$XROOTD_CONFIG_FILE" != "x" ; then
XDAEMON_OPTS="$XDAEMON_OPTS -c $XROOTD_CONFIG_FILE"
fi
# Log file
if test "x$XROOTD_LOG_FILE" != "x" ; then
XDAEMON_OPTS="$XDAEMON_OPTS -l $XROOTD_LOG_FILE"
fi
# port to listen to
if test "x$XROOTD_PORT" != "x" ; then
XDAEMON_OPTS="$XDAEMON_OPTS -p $XROOTD_PORT"
fi
# Redirection
if test "x$XROOTD_REDIRECTOR" != "xyes" ; then
XDAEMON_OPTS="$XDAEMON_OPTS -r"
fi
# Base directory
if test "x$XROOTD_BASEDIR" != "xyes" ; then
XDAEMON_OPTS="$XDAEMON_OPTS $XROOTD_BASEDIR"
fi
# olbd options
# Confguration file
if test "x$OLBD_CONFIG_FILE" != "x" ; then
ODAEMON_OPTS="$ODAEMON_OPTS -c $OLBD_CONFIG_FILE"
fi
# Log file
if test "x$OLBD_LOG_FILE" != "x" ; then
ODAEMON_OPTS="$ODAEMON_OPTS -l $OLBD_LOG_FILE"
fi
# Port to listen to
if test "x$OLBD_PORT" != "x" ; then
ODAEMON_OPTS="$ODAEMON_OPTS -p $OLBD_PORT"
fi
# Redirection.
if test "x$OLBD_REDIRECTOR" != "xyes" ; then
ODAEMON_OPTS="$ODAEMON_OPTS -r"
fi
# cmsd options
# Confguration file
if test "x$CMSD_CONFIG_FILE" != "x" ; then
CDAEMON_OPTS="$CDAEMON_OPTS -c $CMSD_CONFIG_FILE"
fi
# Log file
if test "x$CMSD_LOG_FILE" != "x" ; then
CDAEMON_OPTS="$CDAEMON_OPTS -l $CMSD_LOG_FILE"
fi
# Port to listen to
if test "x$CMSD_PORT" != "x" ; then
CDAEMON_OPTS="$CDAEMON_OPTS -p $CMSD_PORT"
fi
# User
if test "x$XROOTD_USER" = "xroot" ; then
:
elif test "x$XROOTD_USER" != "x" ; then
USER=$XROOTD_USER
fi
# Check if we're enabled
case $enable_rootd:$enable_olbd:$enable_cmsd in
yes:*:*) ;;
*:yes:*) ;;
*:*:yes) ;;
*) exit 0;;
esac
# function to start the main server
startitx ()
{
[ "$VERBOSE" != no ] && log_progress_msg "$XNAME"
start-stop-daemon --make-pidfile --chuid $USER --start --quiet \
--pidfile /var/run/$XNAME.pid --exec $XDAEMON \
--background -- $XDAEMON_OPTS
}
startito ()
{
[ "$VERBOSE" != no ] && log_progress_msg "$ONAME"
start-stop-daemon --make-pidfile --chuid $USER --start --quiet \
--pidfile /var/run/$ONAME.pid --exec $ODAEMON \
--background -- $ODAEMON_OPTS
}
startitc ()
{
[ "$VERBOSE" != no ] && log_progress_msg "$CNAME"
start-stop-daemon --make-pidfile --chuid $USER --start --quiet \
--pidfile /var/run/$CNAME.pid --exec $CDAEMON \
--background -- $CDAEMON_OPTS
}
stopitx()
{
start-stop-daemon --user $USER --stop --oknodo --quiet --pidfile \
/var/run/$XNAME.pid --exec $XDAEMON
}
stopito()
{
start-stop-daemon --user $USER --stop --oknodo --quiet --pidfile \
/var/run/$ONAME.pid --exec $ODAEMON
}
stopitc()
{
start-stop-daemon --user $USER --stop --oknodo --quiet --pidfile \
/var/run/$CNAME.pid --exec $CDAEMON
}
# executable code
case "$1" in
start)
ret=0
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC"
if test "x$enable_xrootd" = "xyes" ; then
startitx
ret=$?
fi
if test $ret -eq 0 && test "x$enable_olbd" = "xyes" ; then
startito
ret=$?
fi
[ "$VERBOSE" != no ] && log_end_msg $ret
[ $ret -ne 0 ] && exit $ret
;;
stop)
ret=0
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC"
if test "x$enable_xrootd" = "xyes" ; then
[ "$VERBOSE" != no ] && log_progress_msg "$XNAME"
stopitx
ret=$?
fi
if test "x$enable_olbd" = "xyes" ; then
[ "$VERBOSE" != no ] && log_progress_msg "$ONAME"
stopito
ret=$?
fi
[ "$VERBOSE" != no ] && log_end_msg $ret
[ $ret -ne 0 ] && exit $ret
;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
ret=0
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC"
if test "x$enable_xrootd" = "xyes" ; then
stopitx
startitx
ret=$?
fi
if test $ret -eq 0 && test "x$enable_olbd" = "xyes" ; then
stopito
startito
ret=$?
fi
[ "$VERBOSE" != no ] && log_end_msg $ret
[ $ret -ne 0 ] && exit $ret
;;
*)
N=@sysconfdir@/init.d/root-system-$XNAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
#
# EOF
#