This file is indexed.

/etc/init.d/nordugrid-arc-slapd is in nordugrid-arc-ldap-infosys 5.4.2-1build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/bin/bash
#
# Init file for the NorduGrid/ARC LDAP based Information System
#
# chkconfig: 2345 75 25
# description: NorduGrid/ARC Information system
#
# config: /etc/sysconfig/nordugrid
# config: /etc/sysconfig/nordugrid-arc-slapd
# config: /etc/arc.conf
#
######################################################################

### BEGIN INIT INFO
# Provides:          nordugrid-arc-slapd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: NorduGrid/ARC Information system
# Description:       NorduGrid/ARC LDAP based Information System
### END INIT INFO

# Helper functions
if [ -r /etc/init.d/functions ]; then
    . /etc/init.d/functions
    log_success_msg() {
	echo -n "$@"
	success "$@"
	echo
    }
    log_warning_msg() {
	echo -n "$@"
	warning "$@"
	echo
    }
    log_failure_msg() {
	echo -n "$@"
	failure "$@"
	echo
    }
elif [ -r /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions
else
    echo "Error: Cannot source neither init.d nor lsb functions"
    exit 1
fi

RETVAL=0
prog=nordugrid-arc-slapd
RUN=yes

# sysconfig files
if [ -r /etc/sysconfig/nordugrid ]; then
    . /etc/sysconfig/nordugrid
elif [ -r /etc/default/nordugrid ]; then
    . /etc/default/nordugrid
fi
if [ -r /etc/sysconfig/$prog ]; then
    . /etc/sysconfig/$prog
elif [ -r /etc/default/$prog ]; then
    . /etc/default/$prog
fi

if [ "x$RUN" != "xyes" ]; then
    log_warning_msg "$prog disabled, please adjust the configuration to your"
    log_warning_msg "needs and then set RUN to 'yes' in /etc/default/$prog to enable it."
    exit 0
fi

[ -n "$ARC_LOCATION" ] && export ARC_LOCATION
[ -n "$ARC_CONFIG" ]   && export ARC_CONFIG

ARC_LOCATION=${ARC_LOCATION:-/usr}
if [ ! -d "$ARC_LOCATION" ]; then
    log_failure_msg "ARC_LOCATION ($ARC_LOCATION) not found"
    exit 1
fi

# Source the config parsing routines
if [ -r "$ARC_LOCATION/share/arc/config_parser_compat.sh" ]; then
    . $ARC_LOCATION/share/arc/config_parser_compat.sh || exit $?
else
    log_failure_msg "Could not find $ARC_LOCATION/share/arc/config_parser_compat.sh"
    exit 1
fi

ARC_CONFIG=${ARC_CONFIG:-/etc/arc.conf}
if [ ! -r "$ARC_CONFIG" ]; then
    log_failure_msg "ARC configuration file ($ARC_CONFIG) not found"
    log_failure_msg "If this file is in a non-standard place it can be set"
    log_failure_msg "  with the ARC_CONFIG environment variable"
    exit 1
fi

# Read arc.conf
config_parse_file $ARC_CONFIG || exit $?

# Check for infosys-block
if ! config_match_section infosys; then
    log_failure_msg "Missing infosys configuration block"
    exit 1
fi

config_hide_all
config_import_section common
config_import_section infosys

bdii_location=${CONFIG_bdii_location:-/usr}
bdii_update_cmd=${CONFIG_bdii_update_cmd:-${bdii_location}/sbin/bdii-update}
if [ ! -x $bdii_update_cmd ] || grep -q BDII_PID_FILE $bdii_update_cmd; then
    bdii_var_dir=${CONFIG_bdii_var_dir:-/var/lib/arc/bdii}
    bdii_run_dir=${CONFIG_bdii_run_dir:-/var/run/arc/bdii}
else
    bdii_var_dir=${CONFIG_bdii_var_dir:-/var/run/arc/bdii}
    bdii_run_dir=${bdii_var_dir}
fi
slapd_pid_file=${bdii_run_dir}/db/slapd.pid

infosys_ldap_run_dir=${CONFIG_infosys_ldap_run_dir:-/var/run/arc/infosys}

if [ `id -u` = 0 ]; then
    # Debian does not have /var/lock/subsys
    if [ -d /var/lock/subsys ]; then
	slapd_lock_file=${slapd_lock_file:-/var/lock/subsys/$prog}
    else
	slapd_lock_file=${slapd_lock_file:-/var/lock/$prog}
    fi
else
    slapd_lock_file=$HOME/$prog
fi

start () {
    if [ -r "${slapd_lock_file}" ]; then
	log_success_msg "$prog already started"
	RETVAL=0
	return ${RETVAL}
    fi

    ${ARC_LOCATION}/share/arc/create-slapd-config
    if [ ! $? = 0 ]; then
	log_failure_msg "Failed to create configuration for $prog"
	exit 1
    fi
    /bin/sh ${infosys_ldap_run_dir}/bdii-slapd.cmd

    touch ${slapd_lock_file}

    iterlimit=30
    while [ $iterlimit -ge 0 ] && ! [ -r ${slapd_pid_file} ]; do
	sleep 1
	iterlimit=$(expr $iterlimit - 1)
    done

    if ! [ -r "${slapd_pid_file}" ]; then
	log_failure_msg "$prog failed to start"
	rm -f ${slapd_lock_file}
	RETVAL=1
	return ${RETVAL}
    fi

    log_success_msg "$prog started"

    prefix=${ARC_LOCATION:-/usr}
    if [ -x /etc/init.d/nordugrid-arc-bdii ] ; then
	/etc/init.d/nordugrid-arc-bdii condrestart
    fi
}

stop () {
    if [ ! -r "${slapd_lock_file}" ]; then
	log_success_msg "$prog already stopped"
	RETVAL=0
	return ${RETVAL}
    fi

    if [ -r "${slapd_pid_file}" ]; then
	slapd_pid=$(cat ${slapd_pid_file})
	ps ${slapd_pid} >/dev/null 2>&1
	if [ ! $? = 0 ]; then
	    log_failure_msg "$prog pid file exists but the process died"
	    RETVAL=1
	    return ${RETVAL}
	fi
    else
	log_failure_msg "$prog process has no pid file"
	RETVAL=1
	return ${RETVAL}
    fi

    if [ -n "${slapd_pid}" ]; then
	kill -15 ${slapd_pid} 2>/dev/null
	ps ${slapd_pid} >/dev/null 2>&1
	if [ $? = 0 ]; then
	    sleep 2
	    ps ${slapd_pid} >/dev/null 2>&1
	    if [ $? = 0 ]; then
		kill -9 ${slapd_pid} 2>/dev/null
		sleep 2
		ps ${slapd_pid} >/dev/null 2>&1
		if [ $? = 0 ]; then
		    RETVAL=1
		fi
	    fi
	fi
    fi

    if [ ${RETVAL} = 0 ];  then
	rm -f ${slapd_pid_file}
	rm -f ${slapd_lock_file}
	log_success_msg "$prog stopped"
    else
	log_failure_msg "Could not stop $prog with pid: $slapd_pid"
    fi

    return ${RETVAL}
}

status ()  {
    if [ ! -r "${slapd_lock_file}" ]; then
	log_success_msg "$prog is stopped"
	RETVAL=3
	return ${RETVAL}
    fi

    if [ -r ${slapd_pid_file} ]; then
	ps $(cat ${slapd_pid_file}) >/dev/null 2>&1
	if [ ! $? = 0 ]; then
	    log_failure_msg "$prog pid file exists but the process died"
	    RETVAL=1
	    return ${RETVAL}
	fi
    else
	log_failure_msg "$prog process has no pid file"
	RETVAL=2
	return ${RETVAL}
    fi

    log_success_msg "$prog is running"

    RETVAL=0
    return ${RETVAL}
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart | force-reload)
	stop
	# avoid race
	sleep 3
	start
	;;
    reload)
	;;
    status)
	status
	;;
    condrestart | try-restart)
	if [ -r ${slapd_lock_file} ]; then
	    stop
	    # avoid race
	    sleep 3
	    start
	fi
	;;
    *)
	echo "Usage: $0 {start|stop|restart|force-reload|reload|condrestart|try-restart|status}"
	exit 1
	;;
esac

exit $RETVAL