3
# Init file for the ARC gridftp server
5
# chkconfig: 2345 75 25
6
# description: ARC gridftpd
8
# config: /etc/sysconfig/nordugrid
9
# config: /etc/sysconfig/gridftpd
10
# config: /usr/etc/arc.conf
11
# config: /etc/arc.conf
15
# Required-Start: $local_fs $remote_fs
16
# Required-Stop: $local_fs $remote_fs
17
# Default-Start: 2 3 4 5
19
# Short-Description: ARC gridftpd
20
# Description: ARC gridftp server
23
# source function library
24
if [ -f /etc/init.d/functions ]; then
25
. /etc/init.d/functions
41
elif [ -f /lib/lsb/init-functions ]; then
42
. /lib/lsb/init-functions
44
echo "Error: Cannot source neither init.d nor lsb functions"
50
if [ ! "x$location" = "x" ] ; then
51
if [ ! "$location" = "/usr" ] ; then
52
libdir="$location/lib"
53
libdir64="$location/lib64"
54
if [ -d "$libdir64" ] ; then
55
if [ "x$LD_LIBRARY_PATH" = "x" ]; then
56
LD_LIBRARY_PATH="$libdir64"
58
LD_LIBRARY_PATH="$libdir64:$LD_LIBRARY_PATH"
61
if [ -d "$libdir" ] ; then
62
if [ "x$LD_LIBRARY_PATH" = "x" ]; then
63
LD_LIBRARY_PATH="$libdir"
65
LD_LIBRARY_PATH="$libdir:$LD_LIBRARY_PATH"
76
if [ -r /etc/sysconfig/nordugrid ]; then
77
. /etc/sysconfig/nordugrid
78
elif [ -r /etc/default/nordugrid ]; then
79
. /etc/default/nordugrid
81
if [ -r /etc/sysconfig/${prog} ]; then
82
. /etc/sysconfig/${prog}
83
elif [ -r /etc/default/${prog} ]; then
84
. /etc/default/${prog}
87
if [ "$RUN" != "yes" ] ; then
88
log_warning_msg "$prog disabled, please adjust the configuration to your"
89
log_warning_msg "needs and then set RUN to 'yes' in /etc/default/$prog to enable it."
94
GLOBUS_LOCATION=${GLOBUS_LOCATION:-/usr}
95
if [ ! -d "$GLOBUS_LOCATION" ]; then
96
log_failure_msg "GLOBUS_LOCATION ($GLOBUS_LOCATION) not found"
99
export GLOBUS_LOCATION
102
ARC_LOCATION=${ARC_LOCATION:-/usr}
103
if [ ! -d "$ARC_LOCATION" ]; then
104
log_failure_msg "ARC_LOCATION ($ARC_LOCATION) not found"
111
if [ ! -r "$fname" ]; then
117
cat "$fname" | grep -e '^\[' -e "^${vname}=" | {
120
if [ ! $? = 0 ] ; then
123
if [ "$line" = "$bname" ] ; then
126
if [ ! $? = 0 ] ; then
129
lstart=`echo "$line" | head -c 1`
130
if [ "$lstart" = '[' ] ; then
133
vlname=`echo "$line" | sed 's/=.*//;t;s/.*//'`
134
if [ "$vlname" = "$vname" ] ; then
135
val=`echo "$line" | sed 's/[^=]*=//'`
146
X509_USER_CERT=`readconfigvar "$ARC_CONFIG" gridftpd x509_user_cert`
147
X509_USER_KEY=`readconfigvar "$ARC_CONFIG" gridftpd x509_user_key`
148
if [ -z "$X509_USER_CERT" ] ; then
149
X509_USER_CERT=`readconfigvar "$ARC_CONFIG" common x509_user_cert`
151
if [ -z "$X509_USER_KEY" ] ; then
152
X509_USER_KEY=`readconfigvar "$ARC_CONFIG" common x509_user_key`
154
if [ -z "$X509_USER_CERT" ] ; then
155
X509_USER_CERT=/etc/grid-security/hostcert.pem
157
if [ -z "$X509_USER_KEY" ] ; then
158
X509_USER_KEY=/etc/grid-security/hostkey.pem
160
if [ ! -f "$X509_USER_CERT" ] ; then
161
log_failure_msg "Host certificate not found"
164
if [ ! -f "$X509_USER_KEY" ] ; then
165
log_failure_msg "Host key not found"
168
# check permissions on key
169
perms=`stat -L -c %a "$X509_USER_KEY"`
170
if [ "$perms" != "600" ] && [ "$perms" != "400" ] ; then
171
log_failure_msg "Host key must be readable only by user"
176
CMD="$ARC_LOCATION/sbin/$prog"
177
if [ ! -x "$CMD" ]; then
178
log_failure_msg "Missing executable"
183
if [ "x$ARC_CONFIG" = "x" ]; then
184
if [ -r $ARC_LOCATION/etc/arc.conf ]; then
185
ARC_CONFIG=$ARC_LOCATION/etc/arc.conf
186
elif [ -r /etc/arc.conf ]; then
187
ARC_CONFIG=/etc/arc.conf
191
if [ ! -r "$ARC_CONFIG" ]; then
192
log_failure_msg "ARC configuration not found (usually /etc/arc.conf)"
196
CMD="$CMD -c '$ARC_CONFIG'"
199
VOMS_LOCATION=${VOMS_LOCATION:-@DEFAULT_VOMS_LOCATION@}
202
GRIDSITE_LOCATION=${GRIDSITE_LOCATION:-@DEFAULT_GRIDSITE_LOCATION@}
204
add_library_path "$LFC_LOCATION"
205
add_library_path "$GRIDSITE_LOCATION"
206
add_library_path "$VOMS_LOCATION"
207
add_library_path "$GLOBUS_LOCATION"
208
if [ "x$LD_LIBRARY_PATH" = "x" ]; then
209
LD_LIBRARY_PATH=$ARC_LOCATION/lib
211
LD_LIBRARY_PATH=$ARC_LOCATION/lib:$LD_LIBRARY_PATH
213
export LD_LIBRARY_PATH
215
PID_FILE=`readconfigvar "$ARC_CONFIG" gridftpd pidfile`
217
if [ `id -u` = 0 ] ; then
218
# Debian does not have /var/lock/subsys
219
if [ -d /var/lock/subsys ]; then
220
LOCKFILE=/var/lock/subsys/$prog
222
LOCKFILE=/var/lock/$prog
224
if [ "x$PID_FILE" = "x" ]; then
225
PID_FILE=/var/run/$prog.pid
228
LOCKFILE=$HOME/$prog.lock
229
if [ "x$PID_FILE" = "x" ]; then
230
PID_FILE=$HOME/$prog.pid
234
logfile=`readconfigvar "$ARC_CONFIG" gridftpd logfile`
235
if [ "x$logfile" = "x" ]; then
236
logfile=/var/log/arc/gridftpd.log
238
if [ ! -d `dirname $logfile` ]; then
239
mkdir -p `dirname $logfile`
242
CMD="$CMD -P '$PID_FILE'"
247
echo -n "Starting $prog: "
249
# Check if we are already running
250
if [ -f $PID_FILE ]; then
252
if [ "x$pid" != "x" ]; then
253
ps -p "$pid" -o comm 2>/dev/null | grep "^$prog$" 1>/dev/null 2>/dev/null
254
if [ $? -eq 0 ] ; then
255
log_success_msg "already running (pid $pid)"
259
rm -f "$PID_FILE" "$LOCKFILE"
265
if [ $RETVAL -eq 0 ]; then
275
echo -n "Stopping $prog: "
277
if [ -f "$PID_FILE" ]; then
278
read pid < "$PID_FILE"
279
if [ ! -z "$pid" ] ; then
282
if [ $RETVAL -eq 0 ]; then
289
kill -9 "$pid" 1>/dev/null 2>&1
290
rm -f "$PID_FILE" "$LOCKFILE"
293
log_failure_msg "$prog shutdown - pidfile is empty"
297
log_success_msg "$prog shutdown - already stopped"
303
if [ -f "$PID_FILE" ]; then
304
read pid < "$PID_FILE"
305
if [ "$pid" != "" ]; then
306
if ps -p "$pid" > /dev/null; then
307
echo "$1 (pid $pid) is running..."
310
echo "$1 stopped but pid file exists"
314
if [ -f $LOCKFILE ]; then
315
echo "$1 stopped but lockfile exists"
337
restart | force-reload)
342
condrestart | try-restart)
343
[ -f $LOCKFILE ] && restart || :
346
echo "Usage: $0 {start|stop|status|restart|force-reload|reload|condrestart|try-restart}"