rc.subr (126288) | rc.subr (126303) |
---|---|
1# $NetBSD: rc.subr,v 1.60 2003/07/26 05:13:47 lukem Exp $ | 1# $NetBSD: rc.subr,v 1.60 2003/07/26 05:13:47 lukem Exp $ |
2# $FreeBSD: head/etc/rc.subr 126288 2004-02-26 12:43:43Z mtm $ | 2# $FreeBSD: head/etc/rc.subr 126303 2004-02-27 09:58:50Z mtm $ |
3# 4# Copyright (c) 1997-2002 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 --- 310 unchanged lines hidden (view full) --- 321# If there's a match, run ${argument}_cmd or the default method 322# (see below). 323# 324# If argument has a given prefix, then change the operation as follows: 325# Prefix Operation 326# ------ --------- 327# fast Skip the pid check, and set rc_fast=yes 328# force Set ${rcvar} to YES, and set rc_force=yes | 3# 4# Copyright (c) 1997-2002 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 --- 310 unchanged lines hidden (view full) --- 321# If there's a match, run ${argument}_cmd or the default method 322# (see below). 323# 324# If argument has a given prefix, then change the operation as follows: 325# Prefix Operation 326# ------ --------- 327# fast Skip the pid check, and set rc_fast=yes 328# force Set ${rcvar} to YES, and set rc_force=yes |
329# one Set ${rcvar} to YES |
|
329# 330# The following globals are used: 331# 332# Name Needed Purpose 333# ---- ------ ------- 334# name y Name of script. 335# 336# command n Full path to command. --- 93 unchanged lines hidden (view full) --- 430# 431# rcvar Display what rc.conf variable is used (if any). 432# 433# Variables available to methods, and after run_rc_command() has 434# completed: 435# 436# Variable Purpose 437# -------- ------- | 330# 331# The following globals are used: 332# 333# Name Needed Purpose 334# ---- ------ ------- 335# name y Name of script. 336# 337# command n Full path to command. --- 93 unchanged lines hidden (view full) --- 431# 432# rcvar Display what rc.conf variable is used (if any). 433# 434# Variables available to methods, and after run_rc_command() has 435# completed: 436# 437# Variable Purpose 438# -------- ------- |
438# rc_arg Argument to command, after fast/force processing | 439# rc_arg Argument to command, after fast/force/one processing |
439# performed 440# 441# rc_flags Flags to start the default command with. 442# Defaults to ${name}_flags, unless overridden 443# by $flags from the environment. 444# This variable may be changed by the precmd method. 445# 446# rc_pid PID of command (if appropriate) --- 6 unchanged lines hidden (view full) --- 453run_rc_command() 454{ 455 _return=0 456 rc_arg=$1 457 if [ -z "$name" ]; then 458 err 3 'run_rc_command: $name is not set.' 459 fi 460 | 440# performed 441# 442# rc_flags Flags to start the default command with. 443# Defaults to ${name}_flags, unless overridden 444# by $flags from the environment. 445# This variable may be changed by the precmd method. 446# 447# rc_pid PID of command (if appropriate) --- 6 unchanged lines hidden (view full) --- 454run_rc_command() 455{ 456 _return=0 457 rc_arg=$1 458 if [ -z "$name" ]; then 459 err 3 'run_rc_command: $name is not set.' 460 fi 461 |
462 _rc_prefix= |
|
461 case "$rc_arg" in 462 fast*) # "fast" prefix; don't check pid 463 rc_arg=${rc_arg#fast} 464 rc_fast=yes 465 ;; | 463 case "$rc_arg" in 464 fast*) # "fast" prefix; don't check pid 465 rc_arg=${rc_arg#fast} 466 rc_fast=yes 467 ;; |
466 force*) # "force prefix; always start 467 rc_arg=${rc_arg#force} | 468 force*) # "force prefix; always run |
468 rc_force=yes | 469 rc_force=yes |
470 _rc_prefix=force 471 rc_arg=${rc_arg#${_rc_prefix}} |
|
469 if [ -n "${rcvar}" ]; then 470 eval ${rcvar}=YES 471 fi 472 ;; | 472 if [ -n "${rcvar}" ]; then 473 eval ${rcvar}=YES 474 fi 475 ;; |
476 one*) # "one" prefix; set ${rcvar}=yes 477 _rc_prefix=one 478 rc_arg=${rc_arg#${_rc_prefix}} 479 if [ -n "${rcvar}" ]; then 480 eval ${rcvar}=YES 481 fi 482 ;; |
|
473 esac 474 475 eval _overide_command=\$${name}_program 476 if [ -n "$_overide_command" ]; then 477 command=$_overide_command 478 fi 479 480 _keywords="start stop restart rcvar $extra_commands" --- 263 unchanged lines hidden (view full) --- 744 # prevent restart being called more 745 # than once by any given script 746 # 747 if ${_rc_restart_done:-false}; then 748 return 0 749 fi 750 _rc_restart_done=true 751 | 483 esac 484 485 eval _overide_command=\$${name}_program 486 if [ -n "$_overide_command" ]; then 487 command=$_overide_command 488 fi 489 490 _keywords="start stop restart rcvar $extra_commands" --- 263 unchanged lines hidden (view full) --- 754 # prevent restart being called more 755 # than once by any given script 756 # 757 if ${_rc_restart_done:-false}; then 758 return 0 759 fi 760 _rc_restart_done=true 761 |
752 ( $0 ${rc_force:+force}stop ) 753 $0 ${rc_force:+force}start | 762 ( $0 ${_rc_prefix}stop ) 763 $0 ${_rc_prefix}start |
754 755 if [ -n "$_postcmd" ]; then 756 eval $_postcmd 757 _return=$? 758 fi 759 ;; 760 761 poll) --- 118 unchanged lines hidden (view full) --- 880 881# 882# rc_usage commands 883# Print a usage string for $0, with `commands' being a list of 884# valid commands. 885# 886rc_usage() 887{ | 764 765 if [ -n "$_postcmd" ]; then 766 eval $_postcmd 767 _return=$? 768 fi 769 ;; 770 771 poll) --- 118 unchanged lines hidden (view full) --- 890 891# 892# rc_usage commands 893# Print a usage string for $0, with `commands' being a list of 894# valid commands. 895# 896rc_usage() 897{ |
888 echo -n 1>&2 "Usage: $0 [fast|force](" | 898 echo -n 1>&2 "Usage: $0 [fast|force|one](" |
889 890 _sep= 891 for _elem; do 892 echo -n 1>&2 "$_sep$_elem" 893 _sep="|" 894 done 895 echo 1>&2 ")" 896 exit 1 --- 369 unchanged lines hidden --- | 899 900 _sep= 901 for _elem; do 902 echo -n 1>&2 "$_sep$_elem" 903 _sep="|" 904 done 905 echo 1>&2 ")" 906 exit 1 --- 369 unchanged lines hidden --- |