rc.subr (175662) | rc.subr (175676) |
---|---|
1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ | 1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ |
2# $FreeBSD: head/etc/rc.subr 175662 2008-01-25 16:44:34Z mtm $ | 2# $FreeBSD: head/etc/rc.subr 175676 2008-01-26 11:22:12Z mtm $ |
3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 361 unchanged lines hidden (view full) --- 372# Search for argument in the list of supported commands, which is: 373# "start stop restart rcvar status poll ${extra_commands}" 374# If there's a match, run ${argument}_cmd or the default method 375# (see below). 376# 377# If argument has a given prefix, then change the operation as follows: 378# Prefix Operation 379# ------ --------- | 3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 361 unchanged lines hidden (view full) --- 372# Search for argument in the list of supported commands, which is: 373# "start stop restart rcvar status poll ${extra_commands}" 374# If there's a match, run ${argument}_cmd or the default method 375# (see below). 376# 377# If argument has a given prefix, then change the operation as follows: 378# Prefix Operation 379# ------ --------- |
380# fast Skip the pid check, and set rc_fast=yes | 380# fast Skip the pid check, and set rc_fast=yes, rc_quiet=yes |
381# force Set ${rcvar} to YES, and set rc_force=yes 382# one Set ${rcvar} to YES | 381# force Set ${rcvar} to YES, and set rc_force=yes 382# one Set ${rcvar} to YES |
383# quiet Don't output some diagnostics, and set rc_quiet=yes |
|
383# 384# The following globals are used: 385# 386# Name Needed Purpose 387# ---- ------ ------- 388# name y Name of script. 389# 390# command n Full path to command. --- 126 unchanged lines hidden (view full) --- 517# This variable may be changed by the precmd method. 518# 519# rc_pid PID of command (if appropriate) 520# 521# rc_fast Not empty if "fast" was provided (q.v.) 522# 523# rc_force Not empty if "force" was provided (q.v.) 524# | 384# 385# The following globals are used: 386# 387# Name Needed Purpose 388# ---- ------ ------- 389# name y Name of script. 390# 391# command n Full path to command. --- 126 unchanged lines hidden (view full) --- 518# This variable may be changed by the precmd method. 519# 520# rc_pid PID of command (if appropriate) 521# 522# rc_fast Not empty if "fast" was provided (q.v.) 523# 524# rc_force Not empty if "force" was provided (q.v.) 525# |
526# rc_quiet Not empty if "quiet" was provided |
|
525# | 527# |
528# |
|
526run_rc_command() 527{ 528 _return=0 529 rc_arg=$1 530 if [ -z "$name" ]; then 531 err 3 'run_rc_command: $name is not set.' 532 fi 533 534 # Don't repeat the first argument when passing additional command- 535 # line arguments to the command subroutines. 536 # 537 shift 1 538 rc_extra_args="$*" 539 540 _rc_prefix= 541 case "$rc_arg" in 542 fast*) # "fast" prefix; don't check pid 543 rc_arg=${rc_arg#fast} 544 rc_fast=yes | 529run_rc_command() 530{ 531 _return=0 532 rc_arg=$1 533 if [ -z "$name" ]; then 534 err 3 'run_rc_command: $name is not set.' 535 fi 536 537 # Don't repeat the first argument when passing additional command- 538 # line arguments to the command subroutines. 539 # 540 shift 1 541 rc_extra_args="$*" 542 543 _rc_prefix= 544 case "$rc_arg" in 545 fast*) # "fast" prefix; don't check pid 546 rc_arg=${rc_arg#fast} 547 rc_fast=yes |
548 rc_quiet=yes |
|
545 ;; 546 force*) # "force prefix; always run 547 rc_force=yes 548 _rc_prefix=force 549 rc_arg=${rc_arg#${_rc_prefix}} 550 if [ -n "${rcvar}" ]; then 551 eval ${rcvar}=YES 552 fi 553 ;; 554 one*) # "one" prefix; set ${rcvar}=yes 555 _rc_prefix=one 556 rc_arg=${rc_arg#${_rc_prefix}} 557 if [ -n "${rcvar}" ]; then 558 eval ${rcvar}=YES 559 fi 560 ;; | 549 ;; 550 force*) # "force prefix; always run 551 rc_force=yes 552 _rc_prefix=force 553 rc_arg=${rc_arg#${_rc_prefix}} 554 if [ -n "${rcvar}" ]; then 555 eval ${rcvar}=YES 556 fi 557 ;; 558 one*) # "one" prefix; set ${rcvar}=yes 559 _rc_prefix=one 560 rc_arg=${rc_arg#${_rc_prefix}} 561 if [ -n "${rcvar}" ]; then 562 eval ${rcvar}=YES 563 fi 564 ;; |
565 quiet*) # "quiet" prefix; omit some messages 566 _rc_prefix=quiet 567 rc_arg=${rc_arg#${_rc_prefix}} 568 rc_quiet=yes 569 ;; |
|
561 esac 562 563 eval _override_command=\$${name}_program 564 command=${command:+${_override_command:-$command}} 565 566 _keywords="start stop restart rcvar $extra_commands" 567 rc_pid= 568 _pidcmd= --- 32 unchanged lines hidden (view full) --- 601 602 # if ${rcvar} is set, and $1 is not 603 # "rcvar", then run 604 # checkyesno ${rcvar} 605 # and return if that failed 606 # 607 if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then 608 if ! checkyesno ${rcvar}; then | 570 esac 571 572 eval _override_command=\$${name}_program 573 command=${command:+${_override_command:-$command}} 574 575 _keywords="start stop restart rcvar $extra_commands" 576 rc_pid= 577 _pidcmd= --- 32 unchanged lines hidden (view full) --- 610 611 # if ${rcvar} is set, and $1 is not 612 # "rcvar", then run 613 # checkyesno ${rcvar} 614 # and return if that failed 615 # 616 if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then 617 if ! checkyesno ${rcvar}; then |
618 if [ -n "${rc_quiet}" ]; then 619 return 0 620 fi 621 echo -n "Cannot '${rc_arg}' $name. Set ${rcvar} to " 622 echo -n "YES in /etc/rc.conf or use 'one${rc_arg}' " 623 echo "instead of '${rc_arg}'." |
|
609 return 0 610 fi 611 fi 612 613 eval $_pidcmd # determine the pid if necessary 614 615 for _elem in $_keywords; do 616 if [ "$_elem" != "$rc_arg" ]; then --- 952 unchanged lines hidden --- | 624 return 0 625 fi 626 fi 627 628 eval $_pidcmd # determine the pid if necessary 629 630 for _elem in $_keywords; do 631 if [ "$_elem" != "$rc_arg" ]; then --- 952 unchanged lines hidden --- |