rc.subr (157048) | rc.subr (157473) |
---|---|
1# $NetBSD: rc.subr,v 1.60 2003/07/26 05:13:47 lukem Exp $ 2# $FreeBSD: head/etc/rc.subr 157048 2006-03-23 16:48:32Z flz $ | 1# $NetBSD: rc.subr,v 1.65 2004/10/12 14:45:29 lukem Exp $ 2# $FreeBSD: head/etc/rc.subr 157473 2006-04-04 10:52:15Z flz $ |
3# | 3# |
4# Copyright (c) 1997-2002 The NetBSD Foundation, Inc. | 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 11# modification, are permitted provided that the following conditions 12# are met: --- 21 unchanged lines hidden (view full) --- 34# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36# POSSIBILITY OF SUCH DAMAGE. 37# 38# rc.subr 39# functions used by various rc scripts 40# 41 | 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 11# modification, are permitted provided that the following conditions 12# are met: --- 21 unchanged lines hidden (view full) --- 34# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36# POSSIBILITY OF SUCH DAMAGE. 37# 38# rc.subr 39# functions used by various rc scripts 40# 41 |
42: ${rcvar_manpage:='rc.conf(5)'} 43 |
|
42# 43# Operating System dependent/independent variables 44# 45 46if [ -z "${_rc_subr_loaded}" ]; then 47 48_rc_subr_loaded="YES" 49 --- 83 unchanged lines hidden (view full) --- 133 return 0 134 ;; 135 136 # "no", "false", "off", or "0" 137 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 138 return 1 139 ;; 140 *) | 44# 45# Operating System dependent/independent variables 46# 47 48if [ -z "${_rc_subr_loaded}" ]; then 49 50_rc_subr_loaded="YES" 51 --- 83 unchanged lines hidden (view full) --- 135 return 0 136 ;; 137 138 # "no", "false", "off", or "0" 139 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 140 return 1 141 ;; 142 *) |
141 warn "\$${1} is not set properly - see rc.conf(5)." | 143 warn "\$${1} is not set properly - see ${rcvar_manpage}." |
142 return 1 143 ;; 144 esac 145} 146 | 144 return 1 145 ;; 146 esac 147} 148 |
149# |
|
147# reverse_list list 148# print the list in reverse order 149# 150reverse_list() 151{ 152 _revlist= 153 for _revfile; do 154 _revlist="$_revfile $_revlist" --- 438 unchanged lines hidden (view full) --- 593 else 594 echo "${name} is not running." 595 return 1 596 fi 597 ;; 598 599 start) 600 if [ -z "$rc_fast" -a -n "$rc_pid" ]; then | 150# reverse_list list 151# print the list in reverse order 152# 153reverse_list() 154{ 155 _revlist= 156 for _revfile; do 157 _revlist="$_revfile $_revlist" --- 438 unchanged lines hidden (view full) --- 596 else 597 echo "${name} is not running." 598 return 1 599 fi 600 ;; 601 602 start) 603 if [ -z "$rc_fast" -a -n "$rc_pid" ]; then |
601 echo "${name} already running? (pid=$rc_pid)." | 604 echo 1>&2 "${name} already running? (pid=$rc_pid)." |
602 return 1 603 fi 604 605 if [ ! -x ${_chroot}${command} ]; then 606 info "run_rc_command: cannot run ($command)." 607 return 1 608 fi 609 610 # check for required variables, 611 # directories, and files 612 # 613 for _f in $required_vars; do 614 if ! checkyesno $_f; then | 605 return 1 606 fi 607 608 if [ ! -x ${_chroot}${command} ]; then 609 info "run_rc_command: cannot run ($command)." 610 return 1 611 fi 612 613 # check for required variables, 614 # directories, and files 615 # 616 for _f in $required_vars; do 617 if ! checkyesno $_f; then |
615 warn "\$${_f} is not set." | 618 warn "\$${_f} is not enabled." |
616 if [ -z "$rc_force" ]; then 617 return 1 618 fi 619 fi 620 done 621 for _f in $required_dirs; do 622 if [ ! -d "${_f}/." ]; then 623 warn "${_f} is not a directory." --- 55 unchanged lines hidden (view full) --- 679 eval $_postcmd 680 fi 681 ;; 682 683 stop) 684 if [ -z "$rc_pid" ]; then 685 [ -n "$rc_fast" ] && return 0 686 if [ -n "$pidfile" ]; then | 619 if [ -z "$rc_force" ]; then 620 return 1 621 fi 622 fi 623 done 624 for _f in $required_dirs; do 625 if [ ! -d "${_f}/." ]; then 626 warn "${_f} is not a directory." --- 55 unchanged lines hidden (view full) --- 682 eval $_postcmd 683 fi 684 ;; 685 686 stop) 687 if [ -z "$rc_pid" ]; then 688 [ -n "$rc_fast" ] && return 0 689 if [ -n "$pidfile" ]; then |
687 echo \ | 690 echo 1>&2 \ |
688 "${name} not running? (check $pidfile)." 689 else | 691 "${name} not running? (check $pidfile)." 692 else |
690 echo "${name} not running?" | 693 echo 1>&2 "${name} not running?" |
691 fi 692 return 1 693 fi 694 695 # if the precmd failed and force 696 # isn't set, exit 697 # 698 if [ -n "$_precmd" ]; then --- 25 unchanged lines hidden (view full) --- 724 eval $_postcmd 725 _return=$? 726 fi 727 ;; 728 729 reload) 730 if [ -z "$rc_pid" ]; then 731 if [ -n "$pidfile" ]; then | 694 fi 695 return 1 696 fi 697 698 # if the precmd failed and force 699 # isn't set, exit 700 # 701 if [ -n "$_precmd" ]; then --- 25 unchanged lines hidden (view full) --- 727 eval $_postcmd 728 _return=$? 729 fi 730 ;; 731 732 reload) 733 if [ -z "$rc_pid" ]; then 734 if [ -n "$pidfile" ]; then |
732 echo \ | 735 echo 1>&2 \ |
733 "${name} not running? (check $pidfile)." 734 else | 736 "${name} not running? (check $pidfile)." 737 else |
735 echo "${name} not running?" | 738 echo 1>&2 "${name} not running?" |
736 fi 737 return 1 738 fi 739 echo "Reloading ${name} config files." 740 if [ -n "$_precmd" ]; then 741 eval $_precmd 742 _return=$? 743 [ $_return -ne 0 ] && [ -z "$rc_force" ] && --- 105 unchanged lines hidden (view full) --- 849 set $_arg; . $_file ) 850 fi 851 fi 852 ;; 853 esac 854} 855 856# | 739 fi 740 return 1 741 fi 742 echo "Reloading ${name} config files." 743 if [ -n "$_precmd" ]; then 744 eval $_precmd 745 _return=$? 746 [ $_return -ne 0 ] && [ -z "$rc_force" ] && --- 105 unchanged lines hidden (view full) --- 852 set $_arg; . $_file ) 853 fi 854 fi 855 ;; 856 esac 857} 858 859# |
857# load_rc_config | 860# load_rc_config command |
858# Source in the configuration file for a given command. 859# 860load_rc_config() 861{ 862 _command=$1 863 if [ -z "$_command" ]; then 864 err 3 'USAGE: load_rc_config command' 865 fi --- 27 unchanged lines hidden (view full) --- 893 [ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable" 894 [ -n "$xntpd_program" ] && ntpd_program="$xntpd_program" 895 [ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags" 896 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program" 897 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags" 898 ;; 899 esac 900} | 861# Source in the configuration file for a given command. 862# 863load_rc_config() 864{ 865 _command=$1 866 if [ -z "$_command" ]; then 867 err 3 'USAGE: load_rc_config command' 868 fi --- 27 unchanged lines hidden (view full) --- 896 [ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable" 897 [ -n "$xntpd_program" ] && ntpd_program="$xntpd_program" 898 [ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags" 899 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program" 900 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags" 901 ;; 902 esac 903} |
904 905# 906# load_rc_config_var cmd var 907# Read the rc.conf(5) var for cmd and set in the 908# current shell, using load_rc_config in a subshell to prevent 909# unwanted side effects from other variable assignments. 910# 911load_rc_config_var() 912{ 913 if [ $# -ne 2 ]; then 914 err 3 'USAGE: load_rc_config_var cmd var' 915 fi 916 eval $(eval '( 917 load_rc_config '$1' >/dev/null; 918 if [ -n "${'$2'}" -o "${'$2'-UNSET}" != "UNSET" ]; then 919 echo '$2'=\'\''${'$2'}\'\''; 920 fi 921 )' ) 922} |
|
901 902# 903# rc_usage commands 904# Print a usage string for $0, with `commands' being a list of 905# valid commands. 906# 907rc_usage() 908{ --- 151 unchanged lines hidden (view full) --- 1060 ;; 1061 remove) 1062 mv -f $_cur $_back 1063 ;; 1064 esac 1065 fi 1066} 1067 | 923 924# 925# rc_usage commands 926# Print a usage string for $0, with `commands' being a list of 927# valid commands. 928# 929rc_usage() 930{ --- 151 unchanged lines hidden (view full) --- 1082 ;; 1083 remove) 1084 mv -f $_cur $_back 1085 ;; 1086 esac 1087 fi 1088} 1089 |
1090_rc_subr_loaded=: 1091 |
|
1068# make_symlink src link 1069# Make a symbolic link 'link' to src from basedir. If the 1070# directory in which link is to be created does not exist 1071# a warning will be displayed and an error will be returned. 1072# Returns 0 on sucess, 1 otherwise. 1073# 1074make_symlink() 1075{ --- 331 unchanged lines hidden --- | 1092# make_symlink src link 1093# Make a symbolic link 'link' to src from basedir. If the 1094# directory in which link is to be created does not exist 1095# a warning will be displayed and an error will be returned. 1096# Returns 0 on sucess, 1 otherwise. 1097# 1098make_symlink() 1099{ --- 331 unchanged lines hidden --- |