/[baselayout]/branches/baselayout-1_12/sbin/runscript.sh
Gentoo

Contents of /branches/baselayout-1_12/sbin/runscript.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2466 - (show annotations) (download) (as text)
Tue Jan 9 10:30:17 2007 UTC (7 years, 8 months ago) by uberlord
File MIME type: text/x-sh
File size: 18740 byte(s)
    Add conditionalrestart action, which is the same as restart but the service
    is only restarted if it is already started. This means that anything that
    whats this only has to use one command instead of two, making them more
    efficient.
1 #!/bin/bash
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 [[ " $* " == *" --debug "* ]] && set -x
6
7 # Common functions
8 [[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
9
10 # User must be root to run most script stuff (except status)
11 if [[ ${EUID} != "0" ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then
12 eerror "$0: must be root to run init scripts"
13 exit 1
14 fi
15
16 myscript="$1"
17 if [[ -L $1 && ! -L "/etc/init.d/${1##*/}" ]] ; then
18 SVCNAME="$(readlink "$1")"
19 else
20 SVCNAME="$1"
21 fi
22
23 declare -r SVCNAME="${SVCNAME##*/}"
24 export SVCNAME
25 # Support deprecated myservice variable
26 myservice="${SVCNAME}"
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
37 # until after rc sysinit has completed so we punt them to the boot runlevel
38 if [[ -e /dev/.rcsysinit ]] ; then
39 eerror "ERROR: cannot run ${SVCNAME} until sysinit completes"
40 [[ ${RC_COLDPLUG:-yes} != "yes" ]] && exit 1
41 set -f
42 for x in ${RC_PLUG_SERVICES} ; do
43 [[ ${SVCNAME} == ${x} ]] && break
44 [[ "!${SVCNAME}" == ${x} ]] && exit 1
45 done
46 eerror "${SVCNAME} will be started in the ${BOOTLEVEL} runlevel"
47 if [[ ! -L /dev/.rcboot/"${SVCNAME}" ]] ; then
48 [[ ! -d /dev/.rcboot ]] && mkdir /dev/.rcboot
49 ln -snf "$1" /dev/.rcboot/"${SVCNAME}"
50 fi
51 exit 1
52 fi
53
54 # Only hotplug if we're allowed to
55 if [[ ${IN_HOTPLUG} == "1" ]] ; then
56 if [[ ${RC_HOTPLUG:-yes} != "yes" ]] ; then
57 eerror "${SVCNAME} is not allowed to be hotplugged"
58 exit 1
59 fi
60
61 set -f
62 for x in ${RC_PLUG_SERVICES} ; do
63 [[ ${SVCNAME} == ${x} ]] && break
64 if [[ "!${SVCNAME}" == ${x} ]] ; then
65 eerror "${SVCNAME} is not allowed to be hotplugged"
66 exit 1
67 fi
68 done
69 set +f
70 fi
71
72 # State variables
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
118 usage() {
119 local IFS="|"
120 myline="Usage: ${SVCNAME} { $* "
121 echo
122 eerror "${myline}}"
123 eerror " ${SVCNAME} without arguments for full help"
124 }
125
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 ewarn "WARNING: ${SVCNAME} has not yet been started."
191 return 0
192 fi
193 if ! mark_service_stopping "${SVCNAME}" ; then
194 eerror "ERROR: ${SVCNAME} is already stopping."
195 return 1
196 fi
197
198 # Ensure that we clean up if we abort for any reason
199 trap "svc_quit" INT QUIT TSTP
200
201 mark_service_starting "${SVCNAME}"
202 service_message "Service ${SVCNAME} stopping"
203
204 if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" && \
205 [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" && \
206 ${SOFTLEVEL} != "single" ]] ; then
207 ewarn "WARNING: you are stopping a boot service."
208 fi
209
210 if [[ ${svcpause} != "yes" && ${RC_NO_DEPS} != "yes" ]] \
211 && ! service_wasinactive "${SVCNAME}" ; then
212 if net_service "${SVCNAME}" ; then
213 if is_runlevel_stop || ! is_net_up "${SVCNAME}" ; then
214 mydeps="net"
215 fi
216 fi
217 mydeps="${mydeps} ${SVCNAME}"
218 fi
219
220 # Save the IN_BACKGROUND var as we need to clear it for stopping depends
221 local ib_save="${IN_BACKGROUND}"
222 unset IN_BACKGROUND
223
224 for mydep in ${mydeps} ; do
225 for x in $(needsme "${mydep}") ; do
226 if service_started "${x}" || service_inactive "${x}" ; then
227 stop_service "${x}"
228 fi
229 service_list=( "${service_list[@]}" "${x}" )
230 done
231 done
232
233 for x in "${service_list[@]}" ; do
234 service_stopped "${x}" && continue
235 wait_service "${x}"
236 if ! service_stopped "${x}" ; then
237 eerror "ERROR: cannot stop ${SVCNAME} as ${x} is still up."
238 retval=1
239 break
240 fi
241 done
242
243 IN_BACKGROUND="${ib_save}"
244
245 if [[ ${retval} == "0" ]] ; then
246 # Now that deps are stopped, stop our service
247 (
248 exit() {
249 RC_QUIET_STDOUT="no"
250 eerror "DO NOT USE EXIT IN INIT.D SCRIPTS"
251 eerror "This IS a bug, please fix your broken init.d"
252 unset -f exit
253 exit "$@"
254 }
255 # Stop einfo/ebegin/eend from working as parallel messes us up
256 if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then
257 [[ ${RC_VERBOSE} != "yes" \
258 || -e ${svcdir}/exclusive/${SVCNAME} ]] \
259 && RC_QUIET_STDOUT="yes"
260 fi
261 stop
262 )
263 retval="$?"
264
265 # If a service has been marked inactive, exit now as something
266 # may attempt to start it again later
267 if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then
268 svcinactive=0
269 return 0
270 fi
271 fi
272
273 if [[ ${retval} != 0 ]] ; then
274 # Did we fail to stop? create symlink to stop multible attempts at
275 # runlevel change. Note this is only used at runlevel change ...
276 is_runlevel_stop && mark_service_failed "${SVCNAME}"
277
278 # If we are halting the system, do it as cleanly as possible
279 if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
280 mark_service_stopped "${SVCNAME}"
281 else
282 if [[ ${svcinactive} == "0" ]] ; then
283 mark_service_inactive "${SVCNAME}"
284 else
285 mark_service_started "${SVCNAME}"
286 fi
287 fi
288
289 service_message "eerror" "ERROR: ${SVCNAME} failed to stop"
290 else
291 svcstarted=1
292 if service_inactive "${SVCNAME}" ; then
293 svcinactive=0
294 else
295 mark_service_stopped "${SVCNAME}"
296 fi
297 service_message "Service ${SVCNAME} stopped"
298 fi
299
300 # Reset the trap
301 svc_trap
302
303 return "${retval}"
304 }
305
306 svc_start() {
307 local x= y= retval=0 startinactive=
308
309 # Do not try to start if i have done so already on runlevel change
310 if is_runlevel_start && service_failed "${SVCNAME}" ; then
311 return 1
312 elif service_started "${SVCNAME}" ; then
313 ewarn "WARNING: ${SVCNAME} has already been started."
314 return 0
315 elif service_inactive "${SVCNAME}" ; then
316 if [[ ${IN_BACKGROUND} != "true" ]] ; then
317 ewarn "WARNING: ${SVCNAME} has already been started."
318 return 0
319 fi
320 fi
321
322 if ! mark_service_starting "${SVCNAME}" ; then
323 if service_stopping "${SVCNAME}" ; then
324 eerror "ERROR: ${SVCNAME} is already stopping."
325 else
326 eerror "ERROR: ${SVCNAME} is already starting."
327 fi
328 return 1
329 fi
330
331 # Ensure that we clean up if we abort for any reason
332 trap "svc_quit" INT QUIT TSTP
333
334 service_message "Service ${SVCNAME} starting"
335
336 if broken "${SVCNAME}" ; then
337 eerror "ERROR: Some services needed are missing. Run"
338 eerror " './${SVCNAME} broken' for a list of those"
339 eerror " services. ${SVCNAME} was not started."
340 retval=1
341 fi
342
343 # Save the IN_BACKGROUND var as we need to clear it for starting depends
344 local ib_save="${IN_BACKGROUND}"
345 unset IN_BACKGROUND
346
347 if [[ ${retval} == "0" && ${RC_NO_DEPS} != "yes" ]] ; then
348 local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")"
349 local netservices=
350 for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
351 $(dolisting "/etc/runlevels/${mylevel}/net.*") \
352 $(dolisting "/var/lib/init.d/coldplugged/net.*") ; do
353 netservices="${netservices} ${x##*/}"
354 done
355
356 # Start dependencies, if any.
357 if ! is_runlevel_start ; then
358 for x in ${startupservices} ; do
359 if [[ ${x} == "net" ]] && ! net_service "${SVCNAME}" \
360 && ! is_net_up ; then
361 for y in ${netservices} ; do
362 service_stopped "${y}" && start_service "${y}"
363 done
364 elif [[ ${x} != "net" ]] ; then
365 service_stopped "${x}" && start_service "${x}"
366 fi
367 done
368 fi
369
370 # We also wait for any services we're after to finish incase they
371 # have a "before" dep but we don't dep on them.
372 if is_runlevel_start ; then
373 startupservices="${startupservices} $(valid_iafter "${SVCNAME}")"
374 if net_service "${SVCNAME}" ; then
375 startupservices="${startupservices} $(valid_iafter "net")"
376 fi
377 fi
378
379 if [[ " ${startupservices} " == *" net "* ]] ; then
380 startupservices=" ${startupservices} "
381 startupservices="${startupservices/ net / ${netservices} }"
382 startupservices="${startupservices// net /}"
383 fi
384
385 # Wait for dependencies to finish.
386 for x in ${startupservices} ; do
387 service_started "${x}" && continue
388 wait_service "${x}"
389 if ! service_started "${x}" ; then
390 # A 'need' dependency is critical for startup
391 if ineed -t "${SVCNAME}" "${x}" >/dev/null \
392 || ( net_service "${x}" && ineed -t "${SVCNAME}" net \
393 && ! is_net_up ) ; then
394 if service_inactive "${x}" || service_wasinactive "${x}" || \
395 [[ -n $(dolisting "${svcdir}"/scheduled/*/"${x}") ]] ; then
396 svc_schedule_start "${x}" "${SVCNAME}"
397 [[ -n ${startinactive} ]] && startinactive="${startinactive}, "
398 startinactive="${startinactive}${x}"
399 else
400 eerror "ERROR: cannot start ${SVCNAME} as ${x} could not start"
401 retval=1
402 break
403 fi
404 fi
405 fi
406 done
407
408 if [[ -n ${startinactive} && ${retval} == "0" ]] ; then
409 # Change the last , to or for correct grammar.
410 x="${startinactive##*, }"
411 startinactive="${startinactive/%, ${x}/ or ${x}}"
412 ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started."
413 retval=1
414 fi
415 fi
416
417 if [[ ${retval} == "0" ]] ; then
418 IN_BACKGROUND="${ib_save}"
419 (
420 exit() {
421 RC_QUIET_STDOUT="no"
422 eerror "DO NOT USE EXIT IN INIT.D SCRIPTS"
423 eerror "This IS a bug, please fix your broken init.d"
424 unset -f exit
425 exit "$@"
426 }
427
428 # Apply any ulimits if defined
429 [[ -n ${RC_ULIMIT} ]] && ulimit ${RC_ULIMIT}
430
431 # Stop einfo/ebegin/eend from working as parallel messes us up
432 if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then
433 [[ ${RC_VERBOSE} != "yes" \
434 || -e ${svcdir}/exclusive/${SVCNAME} ]] \
435 && RC_QUIET_STDOUT="yes"
436 fi
437
438 start
439 )
440 retval="$?"
441
442 # If a service has been marked inactive, exit now as something
443 # may attempt to start it again later
444 if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then
445 svcinactive=0
446 service_message "ewarn" "WARNING: ${SVCNAME} has started but is inactive"
447 return 1
448 fi
449 fi
450
451 if [[ ${retval} != "0" ]] ; then
452 if [[ ${svcinactive} == "0" ]] ; then
453 mark_service_inactive "${SVCNAME}"
454 else
455 mark_service_stopped "${SVCNAME}"
456 fi
457
458 if [[ -z ${startinactive} ]] ; then
459 is_runlevel_start && mark_service_failed "${SVCNAME}"
460 service_message "eerror" "ERROR: ${SVCNAME} failed to start"
461 fi
462 else
463 svcstarted=0
464 mark_service_started "${SVCNAME}"
465 service_message "Service ${SVCNAME} started"
466 fi
467
468 # Reset the trap
469 svc_trap
470
471 return "${retval}"
472 }
473
474 svc_restart() {
475 # We don't kill child processes if we're restarting
476 # This is especically important for sshd ....
477 RC_KILL_CHILDREN="no"
478
479 # Create a snapshot of started services
480 rm -rf "${svcdir}/snapshot/$$"
481 mkdir -p "${svcdir}/snapshot/$$"
482 cp -pP "${svcdir}"/started/* "${svcdir}"/inactive/* \
483 "${svcdir}/snapshot/$$/" 2>/dev/null
484 rm -f "${svcdir}/snapshot/$$/${SVCNAME}"
485
486 # Simple way to try and detect if the service use svc_{start,stop}
487 # to restart if it have a custom restart() funtion.
488 if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${SVCNAME}") ]] ; then
489 if [[ -z $(egrep 'svc_stop' "/etc/init.d/${SVCNAME}") || \
490 -z $(egrep 'svc_start' "/etc/init.d/${SVCNAME}") ]] ; then
491 echo
492 ewarn "Please use 'svc_stop; svc_start' and not 'stop; start' to"
493 ewarn "restart the service in its custom 'restart()' function."
494 ewarn "Run ${SVCNAME} without arguments for more info."
495 echo
496 if ! service_stopped "${SVCNAME}" ; then
497 svc_stop || return "$?"
498 fi
499 svc_start
500 else
501 restart
502 fi
503 else
504 restart
505 fi
506 retval="$?"
507
508 [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] \
509 && rm -Rf "${svcdir}/scheduled/${SVCNAME}"
510
511 # Restart dependencies as well
512 for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
513 if [[ -x ${x} ]] && service_stopped "${x##*/}" ; then
514 if service_inactive "${SVCNAME}" \
515 || service_wasinactive "${SVCNAME}" ; then
516 svc_schedule_start "${SVCNAME}" "${x##*/}"
517 ewarn "WARNING: ${x##*/} is scheduled to start when ${SVCNAME} has started."
518 elif service_started "${SVCNAME}" ; then
519 start_service "${x##*/}"
520 fi
521 fi
522 done
523 rm -rf "${svcdir}/snapshot/$$"
524
525 service_started "${SVCNAME}" && svc_start_scheduled
526
527 # Wait for services to come up
528 if [[ ${IN_BACKGROUND} != "true" \
529 && ${IN_BACKGROUND} != "1" ]] ; then
530 [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait
531 fi
532
533 return ${retval}
534 }
535
536 svc_status() {
537 # The basic idea here is to have some sort of consistent
538 # output in the status() function which scripts can use
539 # as an generic means to detect status. Any other output
540 # should thus be formatted in the custom status() function
541 # to work with the printed " * status: foo".
542 local efunc="" state=""
543
544 # If we are effectively root, check to see if required daemons are running
545 # and update our status accordingly
546 [[ ${EUID} == 0 ]] && update_service_status "${SVCNAME}"
547
548 if service_stopping "${SVCNAME}" ; then
549 efunc="eerror"
550 state="stopping"
551 elif service_starting "${SVCNAME}" ; then
552 efunc="einfo"
553 state="starting"
554 elif service_inactive "${SVCNAME}" ; then
555 efunc="ewarn"
556 state="inactive"
557 elif service_started "${SVCNAME}" ; then
558 efunc="einfo"
559 state="started"
560 else
561 efunc="eerror"
562 state="stopped"
563 fi
564 [[ ${RC_QUIET_STDOUT} != "yes" ]] \
565 && ${efunc} "status: ${state}"
566
567 status
568 # Return 0 if started, otherwise 1
569 [[ ${state} == "started" ]]
570 }
571
572 rcscript_errors="$(bash -n "${myscript}" 2>&1)" || {
573 [[ -n ${rcscript_errors} ]] && echo "${rcscript_errors}" >&2
574 eerror "ERROR: ${myscript} has syntax errors in it; aborting ..."
575 exit 1
576 }
577
578 # set *after* wrap_rcscript, else we get duplicates.
579 opts="start stop restart"
580
581 source "${myscript}"
582
583 # make sure whe have valid $opts
584 if [[ -z ${opts} ]] ; then
585 opts="start stop restart"
586 fi
587
588 svc_homegrown() {
589 local x arg="$1"
590 shift
591
592 # Walk through the list of available options, looking for the
593 # requested one.
594 for x in ${opts} ; do
595 if [[ ${x} == "${arg}" ]] ; then
596 if typeset -F "${x}" &>/dev/null ; then
597 # Run the homegrown function
598 "${x}"
599
600 return $?
601 fi
602 fi
603 done
604 x=""
605
606 # If we're here, then the function wasn't in $opts.
607 [[ -n $* ]] && x="/ $* "
608 eerror "ERROR: wrong args ( "${arg}" ${x})"
609 # Do not quote this either ...
610 usage ${opts}
611 exit 1
612 }
613
614 shift
615 if [[ $# -lt 1 ]] ; then
616 eerror "ERROR: not enough args."
617 usage ${opts}
618 exit 1
619 fi
620 for arg in "$@" ; do
621 case "${arg}" in
622 --quiet)
623 RC_QUIET="yes"
624 RC_QUIET_STDOUT="yes"
625 ;;
626 # We check this in functions.sh ...
627 # --nocolor)
628 # RC_NOCOLOR="yes"
629 # ;;
630 --nodeps)
631 RC_NO_DEPS="yes"
632 ;;
633 --verbose)
634 RC_VERBOSE="yes"
635 ;;
636 esac
637 done
638
639 retval=0
640 for arg in "$@" ; do
641 case "${arg}" in
642 stop)
643 if [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] ; then
644 rm -Rf "${svcdir}/scheduled/${SVCNAME}"
645 fi
646
647 # Stoped from the background - treat this as a restart so that
648 # stopped services come back up again when started.
649 if [[ ${IN_BACKGROUND} == "true" ]] ; then
650 rm -rf "${svcdir}/snapshot/$$"
651 mkdir -p "${svcdir}/snapshot/$$"
652 cp -pP "${svcdir}"/started/* "${svcdir}"/inactive/* \
653 "${svcdir}/snapshot/$$/" 2>/dev/null
654 rm -f "${svcdir}/snapshot/$$/${SVCNAME}"
655 fi
656
657 svc_stop
658 retval="$?"
659
660 if [[ ${IN_BACKGROUND} == "true" ]] ; then
661 for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
662 if [[ -x ${x} ]] && service_stopped "${x##*/}" ; then
663 svc_schedule_start "${SVCNAME}" "${x##*/}"
664 fi
665 done
666 rm -rf "${svcdir}/snapshot/$$"
667 else
668 rm -f "${svcdir}"/scheduled/*/"${SVCNAME}"
669 fi
670
671 ;;
672 start)
673 svc_start
674 retval="$?"
675 service_started "${SVCNAME}" && svc_start_scheduled
676 ;;
677 needsme|ineed|usesme|iuse|broken)
678 trace_dependencies "-${arg}"
679 ;;
680 status)
681 svc_status
682 retval="$?"
683 ;;
684 zap)
685 einfo "Manually resetting ${SVCNAME} to stopped state."
686 mark_service_stopped "${SVCNAME}"
687 ;;
688 restart)
689 svc_restart
690 retval="$?"
691 ;;
692 condrestart|conditionalrestart)
693 if service_started "${SVCNAME}" ; then
694 svc_restart
695 fi
696 retval="$?"
697 ;;
698 pause)
699 svcpause="yes"
700 svc_stop
701 retval="$?"
702 svcpause="no"
703 ;;
704 --quiet|--nocolor|--nodeps|--verbose|--debug)
705 ;;
706 -V|--version)
707 exec cat "${ROOT}"/etc/gentoo-release
708 exit 1
709 ;;
710 help|-h|--help)
711 exec "${svclib}"/sh/rc-help.sh "${myscript}" help
712 ;;
713 *)
714 # Allow for homegrown functions
715 svc_homegrown ${arg}
716 retval="$?"
717 ;;
718 esac
719 done
720
721 exit "${retval}"
722
723 # vim:ts=4

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20