Lines 20-38
else
Link Here
|
20 |
SVCNAME="$1" |
20 |
SVCNAME="$1" |
21 |
fi |
21 |
fi |
22 |
|
22 |
|
23 |
declare -r SVCNAME="${SVCNAME##*/}" |
23 |
SVCNAME="${SVCNAME##*/}" |
24 |
export SVCNAME |
24 |
export SVCNAME |
25 |
# Support deprecated myservice variable |
25 |
# Support deprecated myservice variable |
26 |
myservice="${SVCNAME}" |
26 |
myservice="${SVCNAME}" |
27 |
|
27 |
|
28 |
svc_trap() { |
|
|
29 |
trap 'eerror "ERROR: ${SVCNAME} caught an interrupt"; exit 1' \ |
30 |
INT QUIT TSTP |
31 |
} |
32 |
|
33 |
# Setup a default trap |
34 |
svc_trap |
35 |
|
36 |
# coldplug events can trigger init scripts, but we don't want to run them |
28 |
# coldplug events can trigger init scripts, but we don't want to run them |
37 |
# until after rc sysinit has completed so we punt them to the boot runlevel |
29 |
# until after rc sysinit has completed so we punt them to the boot runlevel |
38 |
if [[ -e /dev/.rcsysinit ]] ; then |
30 |
if [[ -e /dev/.rcsysinit ]] ; then |
Lines 69-119
if [[ ${IN_HOTPLUG} == "1" ]] ; then
Link Here
|
69 |
set +f |
61 |
set +f |
70 |
fi |
62 |
fi |
71 |
|
63 |
|
72 |
# State variables |
64 |
source "${svclib}/sh/runscript-shared.sh" |
73 |
svcpause="no" |
|
|
74 |
|
75 |
# Functions to handle dependencies and services |
76 |
[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh" |
77 |
# Functions to control daemons |
78 |
[[ ${RC_GOT_DAEMON} != "yes" ]] && source "${svclib}/sh/rc-daemon.sh" |
79 |
|
80 |
# Source configuration files. |
81 |
# (1) Source /etc/conf.d/net if it is a net.* service |
82 |
# (2) Source /etc/conf.d/${SVCNAME} to get initscript-specific |
83 |
# configuration (if it exists). |
84 |
# (3) Source /etc/rc.conf to pick up potentially overriding |
85 |
# configuration, if the system administrator chose to put it |
86 |
# there (if it exists). |
87 |
if net_service "${SVCNAME}" ; then |
88 |
conf="$(add_suffix /etc/conf.d/net)" |
89 |
[[ -e ${conf} ]] && source "${conf}" |
90 |
fi |
91 |
conf="$(add_suffix "/etc/conf.d/${SVCNAME}")" |
92 |
[[ -e ${conf} ]] && source "${conf}" |
93 |
conf="$(add_suffix /etc/rc.conf)" |
94 |
[[ -e ${conf} ]] && source "${conf}" |
95 |
|
96 |
mylevel="${SOFTLEVEL}" |
97 |
[[ ${SOFTLEVEL} == "${BOOTLEVEL}" \ |
98 |
|| ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] \ |
99 |
&& mylevel="${DEFAULTLEVEL}" |
100 |
|
101 |
# Call svc_quit if we abort AND we have obtained a lock |
102 |
service_started "${SVCNAME}" |
103 |
svcstarted="$?" |
104 |
service_inactive "${SVCNAME}" |
105 |
svcinactive="$?" |
106 |
svc_quit() { |
107 |
eerror "ERROR: ${SVCNAME} caught an interrupt" |
108 |
if service_inactive "${SVCNAME}" || [[ ${svcinactive} == "0" ]] ; then |
109 |
mark_service_inactive "${SVCNAME}" |
110 |
elif [[ ${svcstarted} == "0" ]] ; then |
111 |
mark_service_started "${SVCNAME}" |
112 |
else |
113 |
mark_service_stopped "${SVCNAME}" |
114 |
fi |
115 |
exit 1 |
116 |
} |
117 |
|
65 |
|
118 |
usage() { |
66 |
usage() { |
119 |
local IFS="|" |
67 |
local IFS="|" |
Lines 123-583
usage() {
Link Here
|
123 |
eerror " ${SVCNAME} without arguments for full help" |
71 |
eerror " ${SVCNAME} without arguments for full help" |
124 |
} |
72 |
} |
125 |
|
73 |
|
126 |
stop() { |
|
|
127 |
# Return success so the symlink gets removed |
128 |
return 0 |
129 |
} |
130 |
|
131 |
start() { |
132 |
eerror "ERROR: ${SVCNAME} does not have a start function." |
133 |
# Return failure so the symlink doesn't get created |
134 |
return 1 |
135 |
} |
136 |
|
137 |
restart() { |
138 |
if ! service_stopped "${SVCNAME}" ; then |
139 |
svc_stop || return "$?" |
140 |
fi |
141 |
svc_start |
142 |
} |
143 |
|
144 |
status() { |
145 |
# Dummy function |
146 |
return 0 |
147 |
} |
148 |
|
149 |
svc_schedule_start() { |
150 |
local service="$1" start="$2" |
151 |
[[ ! -d "${svcdir}/scheduled/${service}" ]] \ |
152 |
&& mkdir -p "${svcdir}/scheduled/${service}" |
153 |
ln -snf "/etc/init.d/${service}" \ |
154 |
"${svcdir}/scheduled/${service}/${start}" |
155 |
} |
156 |
|
157 |
svc_start_scheduled() { |
158 |
[[ ! -d "${svcdir}/scheduled/${SVCNAME}" ]] && return |
159 |
local x= services= |
160 |
|
161 |
# If we're being started in the background, then don't |
162 |
# tie up the daemon that called us starting our scheduled services |
163 |
if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]] ; then |
164 |
unset IN_BACKGROUND |
165 |
svc_start_scheduled & |
166 |
export IN_BACKGROUND=true |
167 |
return |
168 |
fi |
169 |
|
170 |
for x in $(dolisting "${svcdir}/scheduled/${SVCNAME}/") ; do |
171 |
services="${services} ${x##*/}" |
172 |
done |
173 |
|
174 |
for x in $(trace_dependencies ${services}) ; do |
175 |
service_stopped "${x}" && start_service "${x}" |
176 |
rm -f "${svcdir}/scheduled/${SVCNAME}/${x}" |
177 |
done |
178 |
|
179 |
rmdir "${svcdir}/scheduled/${SVCNAME}" |
180 |
} |
181 |
|
182 |
svc_stop() { |
183 |
local x= mydep= mydeps= retval=0 |
184 |
local -a servicelist=() |
185 |
|
186 |
# Do not try to stop if it had already failed to do so |
187 |
if is_runlevel_stop && service_failed "${SVCNAME}" ; then |
188 |
return 1 |
189 |
elif service_stopped "${SVCNAME}" ; then |
190 |
if [[ ${IN_HOTPLUG} != "1" ]] ; then |
191 |
ewarn "WARNING: ${SVCNAME} has not yet been started." |
192 |
fi |
193 |
return 0 |
194 |
fi |
195 |
if ! mark_service_stopping "${SVCNAME}" ; then |
196 |
if [[ ${IN_HOTPLUG} != "1" ]] ; then |
197 |
eerror "ERROR: ${SVCNAME} is already stopping." |
198 |
fi |
199 |
return 1 |
200 |
fi |
201 |
|
202 |
# Ensure that we clean up if we abort for any reason |
203 |
trap "svc_quit" INT QUIT TSTP |
204 |
|
205 |
mark_service_starting "${SVCNAME}" |
206 |
service_message "Service ${SVCNAME} stopping" |
207 |
|
208 |
if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" && \ |
209 |
[[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" && \ |
210 |
${SOFTLEVEL} != "single" ]] ; then |
211 |
ewarn "WARNING: you are stopping a boot service." |
212 |
fi |
213 |
|
214 |
if [[ ${svcpause} != "yes" && ${RC_NO_DEPS} != "yes" ]] \ |
215 |
&& ! service_wasinactive "${SVCNAME}" ; then |
216 |
if net_service "${SVCNAME}" ; then |
217 |
if is_runlevel_stop || ! is_net_up "${SVCNAME}" ; then |
218 |
mydeps="net" |
219 |
fi |
220 |
fi |
221 |
mydeps="${mydeps} ${SVCNAME}" |
222 |
fi |
223 |
|
224 |
# Save the IN_BACKGROUND var as we need to clear it for stopping depends |
225 |
local ib_save="${IN_BACKGROUND}" |
226 |
unset IN_BACKGROUND |
227 |
|
228 |
for mydep in ${mydeps} ; do |
229 |
for x in $(needsme "${mydep}") ; do |
230 |
if service_started "${x}" || service_inactive "${x}" ; then |
231 |
stop_service "${x}" |
232 |
fi |
233 |
service_list=( "${service_list[@]}" "${x}" ) |
234 |
done |
235 |
done |
236 |
|
237 |
for x in "${service_list[@]}" ; do |
238 |
service_stopped "${x}" && continue |
239 |
wait_service "${x}" |
240 |
if ! service_stopped "${x}" ; then |
241 |
eerror "ERROR: cannot stop ${SVCNAME} as ${x} is still up." |
242 |
retval=1 |
243 |
break |
244 |
fi |
245 |
done |
246 |
|
247 |
IN_BACKGROUND="${ib_save}" |
248 |
|
249 |
if [[ ${retval} == "0" ]] ; then |
250 |
# Now that deps are stopped, stop our service |
251 |
( |
252 |
exit() { |
253 |
RC_QUIET_STDOUT="no" |
254 |
eerror "DO NOT USE EXIT IN INIT.D SCRIPTS" |
255 |
eerror "This IS a bug, please fix your broken init.d" |
256 |
unset -f exit |
257 |
exit "$@" |
258 |
} |
259 |
# Stop einfo/ebegin/eend from working as parallel messes us up |
260 |
if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then |
261 |
[[ ${RC_VERBOSE} != "yes" \ |
262 |
|| -e ${svcdir}/exclusive/${SVCNAME} ]] \ |
263 |
&& RC_QUIET_STDOUT="yes" |
264 |
fi |
265 |
stop |
266 |
) |
267 |
retval="$?" |
268 |
|
269 |
# If a service has been marked inactive, exit now as something |
270 |
# may attempt to start it again later |
271 |
if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then |
272 |
svcinactive=0 |
273 |
return 0 |
274 |
fi |
275 |
fi |
276 |
|
277 |
if [[ ${retval} != 0 ]] ; then |
278 |
# Did we fail to stop? create symlink to stop multible attempts at |
279 |
# runlevel change. Note this is only used at runlevel change ... |
280 |
is_runlevel_stop && mark_service_failed "${SVCNAME}" |
281 |
|
282 |
# If we are halting the system, do it as cleanly as possible |
283 |
if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then |
284 |
mark_service_stopped "${SVCNAME}" |
285 |
else |
286 |
if [[ ${svcinactive} == "0" ]] ; then |
287 |
mark_service_inactive "${SVCNAME}" |
288 |
else |
289 |
mark_service_started "${SVCNAME}" |
290 |
fi |
291 |
fi |
292 |
|
293 |
service_message "eerror" "ERROR: ${SVCNAME} failed to stop" |
294 |
else |
295 |
svcstarted=1 |
296 |
if service_inactive "${SVCNAME}" ; then |
297 |
svcinactive=0 |
298 |
else |
299 |
mark_service_stopped "${SVCNAME}" |
300 |
fi |
301 |
service_message "Service ${SVCNAME} stopped" |
302 |
fi |
303 |
|
304 |
# Reset the trap |
305 |
svc_trap |
306 |
|
307 |
return "${retval}" |
308 |
} |
309 |
|
310 |
svc_start() { |
311 |
local x= y= retval=0 startinactive= |
312 |
|
313 |
# Do not try to start if i have done so already on runlevel change |
314 |
if is_runlevel_start && service_failed "${SVCNAME}" ; then |
315 |
return 1 |
316 |
elif service_started "${SVCNAME}" ; then |
317 |
if [[ ${IN_HOTPLUG} != "1" ]] ; then |
318 |
ewarn "WARNING: ${SVCNAME} has already been started." |
319 |
fi |
320 |
return 0 |
321 |
elif service_inactive "${SVCNAME}" ; then |
322 |
if [[ ${IN_BACKGROUND} != "true" ]] ; then |
323 |
if [[ ${IN_HOTPLUG} != "1" ]] ; then |
324 |
ewarn "WARNING: ${SVCNAME} has already been started." |
325 |
fi |
326 |
return 0 |
327 |
fi |
328 |
fi |
329 |
|
330 |
if ! mark_service_starting "${SVCNAME}" ; then |
331 |
if service_stopping "${SVCNAME}" ; then |
332 |
eerror "ERROR: ${SVCNAME} is already stopping." |
333 |
else |
334 |
eerror "ERROR: ${SVCNAME} is already starting." |
335 |
fi |
336 |
return 1 |
337 |
fi |
338 |
|
339 |
# Ensure that we clean up if we abort for any reason |
340 |
trap "svc_quit" INT QUIT TSTP |
341 |
|
342 |
service_message "Service ${SVCNAME} starting" |
343 |
|
344 |
if broken "${SVCNAME}" ; then |
345 |
eerror "ERROR: Some services needed are missing. Run" |
346 |
eerror " './${SVCNAME} broken' for a list of those" |
347 |
eerror " services. ${SVCNAME} was not started." |
348 |
retval=1 |
349 |
fi |
350 |
|
351 |
# Save the IN_BACKGROUND var as we need to clear it for starting depends |
352 |
local ib_save="${IN_BACKGROUND}" |
353 |
unset IN_BACKGROUND |
354 |
|
355 |
if [[ ${retval} == "0" && ${RC_NO_DEPS} != "yes" ]] ; then |
356 |
local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")" |
357 |
local netservices= |
358 |
for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ |
359 |
$(dolisting "/etc/runlevels/${mylevel}/net.*") \ |
360 |
$(dolisting "/var/lib/init.d/coldplugged/net.*") ; do |
361 |
netservices="${netservices} ${x##*/}" |
362 |
done |
363 |
|
364 |
# Start dependencies, if any. |
365 |
if ! is_runlevel_start ; then |
366 |
for x in ${startupservices} ; do |
367 |
if [[ ${x} == "net" ]] && ! net_service "${SVCNAME}" \ |
368 |
&& ! is_net_up ; then |
369 |
for y in ${netservices} ; do |
370 |
service_stopped "${y}" && start_service "${y}" |
371 |
done |
372 |
elif [[ ${x} != "net" ]] ; then |
373 |
service_stopped "${x}" && start_service "${x}" |
374 |
fi |
375 |
done |
376 |
fi |
377 |
|
378 |
# We also wait for any services we're after to finish incase they |
379 |
# have a "before" dep but we don't dep on them. |
380 |
if is_runlevel_start ; then |
381 |
startupservices="${startupservices} $(valid_iafter "${SVCNAME}")" |
382 |
if net_service "${SVCNAME}" ; then |
383 |
startupservices="${startupservices} $(valid_iafter "net")" |
384 |
fi |
385 |
fi |
386 |
|
387 |
if [[ " ${startupservices} " == *" net "* ]] ; then |
388 |
startupservices=" ${startupservices} " |
389 |
startupservices="${startupservices/ net / ${netservices} }" |
390 |
startupservices="${startupservices// net /}" |
391 |
fi |
392 |
|
393 |
# Wait for dependencies to finish. |
394 |
for x in ${startupservices} ; do |
395 |
service_started "${x}" && continue |
396 |
wait_service "${x}" |
397 |
if ! service_started "${x}" ; then |
398 |
# A 'need' dependency is critical for startup |
399 |
if ineed -t "${SVCNAME}" "${x}" >/dev/null \ |
400 |
|| ( net_service "${x}" && ineed -t "${SVCNAME}" net \ |
401 |
&& ! is_net_up ) ; then |
402 |
if service_inactive "${x}" || service_wasinactive "${x}" || \ |
403 |
[[ -n $(dolisting "${svcdir}"/scheduled/*/"${x}") ]] ; then |
404 |
svc_schedule_start "${x}" "${SVCNAME}" |
405 |
[[ -n ${startinactive} ]] && startinactive="${startinactive}, " |
406 |
startinactive="${startinactive}${x}" |
407 |
else |
408 |
eerror "ERROR: cannot start ${SVCNAME} as ${x} could not start" |
409 |
retval=1 |
410 |
break |
411 |
fi |
412 |
fi |
413 |
fi |
414 |
done |
415 |
|
416 |
if [[ -n ${startinactive} && ${retval} == "0" ]] ; then |
417 |
# Change the last , to or for correct grammar. |
418 |
x="${startinactive##*, }" |
419 |
startinactive="${startinactive/%, ${x}/ or ${x}}" |
420 |
ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started." |
421 |
retval=1 |
422 |
fi |
423 |
fi |
424 |
|
425 |
if [[ ${retval} == "0" ]] ; then |
426 |
IN_BACKGROUND="${ib_save}" |
427 |
( |
428 |
exit() { |
429 |
RC_QUIET_STDOUT="no" |
430 |
eerror "DO NOT USE EXIT IN INIT.D SCRIPTS" |
431 |
eerror "This IS a bug, please fix your broken init.d" |
432 |
unset -f exit |
433 |
exit "$@" |
434 |
} |
435 |
|
436 |
# Apply any ulimits if defined |
437 |
[[ -n ${RC_ULIMIT} ]] && ulimit ${RC_ULIMIT} |
438 |
|
439 |
# Stop einfo/ebegin/eend from working as parallel messes us up |
440 |
if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then |
441 |
[[ ${RC_VERBOSE} != "yes" \ |
442 |
|| -e ${svcdir}/exclusive/${SVCNAME} ]] \ |
443 |
&& RC_QUIET_STDOUT="yes" |
444 |
fi |
445 |
|
446 |
start |
447 |
) |
448 |
retval="$?" |
449 |
|
450 |
# If a service has been marked inactive, exit now as something |
451 |
# may attempt to start it again later |
452 |
if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then |
453 |
svcinactive=0 |
454 |
service_message "ewarn" "WARNING: ${SVCNAME} has started but is inactive" |
455 |
return 1 |
456 |
fi |
457 |
fi |
458 |
|
459 |
if [[ ${retval} != "0" ]] ; then |
460 |
if [[ ${svcinactive} == "0" ]] ; then |
461 |
mark_service_inactive "${SVCNAME}" |
462 |
else |
463 |
mark_service_stopped "${SVCNAME}" |
464 |
fi |
465 |
|
466 |
if [[ -z ${startinactive} ]] ; then |
467 |
is_runlevel_start && mark_service_failed "${SVCNAME}" |
468 |
service_message "eerror" "ERROR: ${SVCNAME} failed to start" |
469 |
fi |
470 |
else |
471 |
svcstarted=0 |
472 |
mark_service_started "${SVCNAME}" |
473 |
service_message "Service ${SVCNAME} started" |
474 |
fi |
475 |
|
476 |
# Reset the trap |
477 |
svc_trap |
478 |
|
479 |
return "${retval}" |
480 |
} |
481 |
|
482 |
svc_restart() { |
483 |
# We don't kill child processes if we're restarting |
484 |
# This is especically important for sshd .... |
485 |
RC_KILL_CHILDREN="no" |
486 |
|
487 |
# Create a snapshot of started services |
488 |
rm -rf "${svcdir}/snapshot/$$" |
489 |
mkdir -p "${svcdir}/snapshot/$$" |
490 |
cp -pPR "${svcdir}"/started/* "${svcdir}"/inactive/* \ |
491 |
"${svcdir}/snapshot/$$/" 2>/dev/null |
492 |
rm -f "${svcdir}/snapshot/$$/${SVCNAME}" |
493 |
|
494 |
# Simple way to try and detect if the service use svc_{start,stop} |
495 |
# to restart if it have a custom restart() funtion. |
496 |
if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${SVCNAME}") ]] ; then |
497 |
if [[ -z $(egrep 'svc_stop' "/etc/init.d/${SVCNAME}") || \ |
498 |
-z $(egrep 'svc_start' "/etc/init.d/${SVCNAME}") ]] ; then |
499 |
echo |
500 |
ewarn "Please use 'svc_stop; svc_start' and not 'stop; start' to" |
501 |
ewarn "restart the service in its custom 'restart()' function." |
502 |
ewarn "Run ${SVCNAME} without arguments for more info." |
503 |
echo |
504 |
if ! service_stopped "${SVCNAME}" ; then |
505 |
svc_stop || return "$?" |
506 |
fi |
507 |
svc_start |
508 |
else |
509 |
restart |
510 |
fi |
511 |
else |
512 |
restart |
513 |
fi |
514 |
retval="$?" |
515 |
|
516 |
[[ -e "${svcdir}/scheduled/${SVCNAME}" ]] \ |
517 |
&& rm -Rf "${svcdir}/scheduled/${SVCNAME}" |
518 |
|
519 |
# Restart dependencies as well |
520 |
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do |
521 |
x="${x##*/}" |
522 |
if [[ -x /etc/init.d/"${x}" ]] && service_stopped "${x}" ; then |
523 |
if service_inactive "${SVCNAME}" \ |
524 |
|| service_wasinactive "${SVCNAME}" ; then |
525 |
svc_schedule_start "${SVCNAME}" "${x}" |
526 |
ewarn "WARNING: ${x} is scheduled to start when ${SVCNAME} has started." |
527 |
elif service_started "${SVCNAME}" ; then |
528 |
start_service "${x}" |
529 |
fi |
530 |
fi |
531 |
done |
532 |
rm -rf "${svcdir}/snapshot/$$" |
533 |
|
534 |
service_started "${SVCNAME}" && svc_start_scheduled |
535 |
|
536 |
# Wait for services to come up |
537 |
if [[ ${IN_BACKGROUND} != "true" \ |
538 |
&& ${IN_BACKGROUND} != "1" ]] ; then |
539 |
[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait |
540 |
fi |
541 |
|
542 |
return ${retval} |
543 |
} |
544 |
|
545 |
svc_status() { |
546 |
# The basic idea here is to have some sort of consistent |
547 |
# output in the status() function which scripts can use |
548 |
# as an generic means to detect status. Any other output |
549 |
# should thus be formatted in the custom status() function |
550 |
# to work with the printed " * status: foo". |
551 |
local efunc="" state="" |
552 |
|
553 |
# If we are effectively root, check to see if required daemons are running |
554 |
# and update our status accordingly |
555 |
[[ ${EUID} == 0 ]] && update_service_status "${SVCNAME}" |
556 |
|
557 |
if service_stopping "${SVCNAME}" ; then |
558 |
efunc="eerror" |
559 |
state="stopping" |
560 |
elif service_starting "${SVCNAME}" ; then |
561 |
efunc="einfo" |
562 |
state="starting" |
563 |
elif service_inactive "${SVCNAME}" ; then |
564 |
efunc="ewarn" |
565 |
state="inactive" |
566 |
elif service_started "${SVCNAME}" ; then |
567 |
efunc="einfo" |
568 |
state="started" |
569 |
else |
570 |
efunc="eerror" |
571 |
state="stopped" |
572 |
fi |
573 |
[[ ${RC_QUIET_STDOUT} != "yes" ]] \ |
574 |
&& ${efunc} "status: ${state}" |
575 |
|
576 |
status |
577 |
# Return 0 if started, otherwise 1 |
578 |
[[ ${state} == "started" ]] |
579 |
} |
580 |
|
581 |
rcscript_errors="$(bash -n "${myscript}" 2>&1)" || { |
74 |
rcscript_errors="$(bash -n "${myscript}" 2>&1)" || { |
582 |
[[ -n ${rcscript_errors} ]] && echo "${rcscript_errors}" >&2 |
75 |
[[ -n ${rcscript_errors} ]] && echo "${rcscript_errors}" >&2 |
583 |
eerror "ERROR: ${myscript} has syntax errors in it; aborting ..." |
76 |
eerror "ERROR: ${myscript} has syntax errors in it; aborting ..." |
Lines 649-654
retval=0
Link Here
|
649 |
for arg in "$@" ; do |
142 |
for arg in "$@" ; do |
650 |
case "${arg}" in |
143 |
case "${arg}" in |
651 |
stop) |
144 |
stop) |
|
|
145 |
lock "${SVCNAME}" |
652 |
if [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] ; then |
146 |
if [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] ; then |
653 |
rm -Rf "${svcdir}/scheduled/${SVCNAME}" |
147 |
rm -Rf "${svcdir}/scheduled/${SVCNAME}" |
654 |
fi |
148 |
fi |
Lines 669-714
for arg in "$@" ; do
Link Here
|
669 |
if [[ ${IN_BACKGROUND} == "true" ]] ; then |
163 |
if [[ ${IN_BACKGROUND} == "true" ]] ; then |
670 |
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do |
164 |
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do |
671 |
x="${x##*/}" |
165 |
x="${x##*/}" |
|
|
166 |
lock "${x}" |
672 |
if [[ -x /etc/init.d/"${x}" ]] && service_stopped "${x}" ; then |
167 |
if [[ -x /etc/init.d/"${x}" ]] && service_stopped "${x}" ; then |
673 |
svc_schedule_start "${SVCNAME}" "${x}" |
168 |
svc_schedule_start "${SVCNAME}" "${x}" |
674 |
fi |
169 |
fi |
|
|
170 |
unlock "${x}" |
675 |
done |
171 |
done |
676 |
rm -rf "${svcdir}/snapshot/$$" |
172 |
rm -rf "${svcdir}/snapshot/$$" |
677 |
else |
173 |
else |
678 |
rm -f "${svcdir}"/scheduled/*/"${SVCNAME}" |
174 |
rm -f "${svcdir}"/scheduled/*/"${SVCNAME}" |
679 |
fi |
175 |
fi |
680 |
|
176 |
|
|
|
177 |
unlock "${SVCNAME}" |
681 |
;; |
178 |
;; |
682 |
start) |
179 |
start) |
|
|
180 |
lock "${SVCNAME}" |
683 |
svc_start |
181 |
svc_start |
684 |
retval="$?" |
182 |
retval="$?" |
685 |
service_started "${SVCNAME}" && svc_start_scheduled |
183 |
service_started "${SVCNAME}" |
|
|
184 |
started="$?" |
185 |
unlock "${SVCNAME}" |
186 |
[[ ${started} == 0 ]] && svc_start_scheduled |
686 |
;; |
187 |
;; |
687 |
needsme|ineed|usesme|iuse|broken) |
188 |
needsme|ineed|usesme|iuse|broken) |
688 |
trace_dependencies "-${arg}" |
189 |
trace_dependencies "-${arg}" |
689 |
;; |
190 |
;; |
690 |
status) |
191 |
status) |
|
|
192 |
lock "${SVCNAME}" |
691 |
svc_status |
193 |
svc_status |
692 |
retval="$?" |
194 |
retval="$?" |
|
|
195 |
unlock "${SVCNAME}" |
693 |
;; |
196 |
;; |
694 |
zap) |
197 |
zap) |
695 |
einfo "Manually resetting ${SVCNAME} to stopped state." |
198 |
einfo "Manually resetting ${SVCNAME} to stopped state." |
|
|
199 |
lock "${SVCNAME}" |
696 |
mark_service_stopped "${SVCNAME}" |
200 |
mark_service_stopped "${SVCNAME}" |
|
|
201 |
unlock "${SVCNAME}" |
697 |
;; |
202 |
;; |
698 |
restart) |
203 |
restart) |
|
|
204 |
lock "${SVCNAME}" |
699 |
svc_restart |
205 |
svc_restart |
700 |
retval="$?" |
206 |
retval="$?" |
|
|
207 |
unlock "${SVCNAME}" |
701 |
;; |
208 |
;; |
702 |
condrestart|conditionalrestart) |
209 |
condrestart|conditionalrestart) |
|
|
210 |
lock "${SVCNAME}" |
703 |
if service_started "${SVCNAME}" ; then |
211 |
if service_started "${SVCNAME}" ; then |
704 |
svc_restart |
212 |
svc_restart |
705 |
fi |
213 |
fi |
706 |
retval="$?" |
214 |
retval="$?" |
|
|
215 |
unlock "${SVCNAME}" |
707 |
;; |
216 |
;; |
708 |
pause) |
217 |
pause) |
709 |
svcpause="yes" |
218 |
svcpause="yes" |
|
|
219 |
lock "${SVCNAME}" |
710 |
svc_stop |
220 |
svc_stop |
711 |
retval="$?" |
221 |
retval="$?" |
|
|
222 |
unlock "${SVCNAME}" |
712 |
svcpause="no" |
223 |
svcpause="no" |
713 |
;; |
224 |
;; |
714 |
--quiet|--nocolor|--nodeps|--verbose|--debug) |
225 |
--quiet|--nocolor|--nodeps|--verbose|--debug) |