Deleted Added
full compact
rc.subr (157473) rc.subr (157653)
1# $NetBSD: rc.subr,v 1.65 2004/10/12 14:45:29 lukem Exp $
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 $
2# $FreeBSD: head/etc/rc.subr 157653 2006-04-11 08:55:27Z flz $
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

--- 346 unchanged lines hidden (view full) ---

357# otherwise use check_process $command.
358# In either case, only check if $command is set.
359#
360# procname n Process name to check for instead of $command.
361#
362# rcvar n This is checked with checkyesno to determine
363# if the action should be run.
364#
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

--- 346 unchanged lines hidden (view full) ---

357# otherwise use check_process $command.
358# In either case, only check if $command is set.
359#
360# procname n Process name to check for instead of $command.
361#
362# rcvar n This is checked with checkyesno to determine
363# if the action should be run.
364#
365# ${name}_program n Full path to command.
366# Meant to be used in /etc/rc.conf to override
367# ${command}.
368#
365# ${name}_chroot n Directory to chroot to before running ${command}
366# Requires /usr to be mounted.
367#
368# ${name}_chdir n Directory to cd to before running ${command}
369# (if not using ${name}_chroot).
370#
371# ${name}_flags n Arguments to call ${command} with.
372# NOTE: $flags from the parent environment

--- 120 unchanged lines hidden (view full) ---

493 _rc_prefix=one
494 rc_arg=${rc_arg#${_rc_prefix}}
495 if [ -n "${rcvar}" ]; then
496 eval ${rcvar}=YES
497 fi
498 ;;
499 esac
500
369# ${name}_chroot n Directory to chroot to before running ${command}
370# Requires /usr to be mounted.
371#
372# ${name}_chdir n Directory to cd to before running ${command}
373# (if not using ${name}_chroot).
374#
375# ${name}_flags n Arguments to call ${command} with.
376# NOTE: $flags from the parent environment

--- 120 unchanged lines hidden (view full) ---

497 _rc_prefix=one
498 rc_arg=${rc_arg#${_rc_prefix}}
499 if [ -n "${rcvar}" ]; then
500 eval ${rcvar}=YES
501 fi
502 ;;
503 esac
504
501 eval _override_command=\$${name}_program
502 command=${command:+${_override_command:-$command}}
503
504 _keywords="start stop restart rcvar $extra_commands"
505 rc_pid=
506 _pidcmd=
507 _procname=${procname:-${command}}
508
509 # setup pid check command
510 if [ -n "$_procname" ]; then
511 if [ -n "$pidfile" ]; then

--- 340 unchanged lines hidden (view full) ---

852 set $_arg; . $_file )
853 fi
854 fi
855 ;;
856 esac
857}
858
859#
505 _keywords="start stop restart rcvar $extra_commands"
506 rc_pid=
507 _pidcmd=
508 _procname=${procname:-${command}}
509
510 # setup pid check command
511 if [ -n "$_procname" ]; then
512 if [ -n "$pidfile" ]; then

--- 340 unchanged lines hidden (view full) ---

853 set $_arg; . $_file )
854 fi
855 fi
856 ;;
857 esac
858}
859
860#
860# load_rc_config command
861# Source in the configuration file for a given command.
861# load_rc_config name
862# Source in the configuration file for a given name.
862#
863load_rc_config()
864{
863#
864load_rc_config()
865{
865 _command=$1
866 if [ -z "$_command" ]; then
867 err 3 'USAGE: load_rc_config command'
866 local _tmp
867
868 _name=$1
869 if [ -z "$_name" ]; then
870 err 3 'USAGE: load_rc_config name'
868 fi
869
870 if ${_rc_conf_loaded:-false}; then
871 :
872 else
873 if [ -r /etc/defaults/rc.conf ]; then
874 debug "Sourcing /etc/defaults/rc.conf"
875 . /etc/defaults/rc.conf
876 source_rc_confs
877 elif [ -r /etc/rc.conf ]; then
878 debug "Sourcing /etc/rc.conf (/etc/defaults/rc.conf doesn't exist)."
879 . /etc/rc.conf
880 fi
881 _rc_conf_loaded=true
882 fi
871 fi
872
873 if ${_rc_conf_loaded:-false}; then
874 :
875 else
876 if [ -r /etc/defaults/rc.conf ]; then
877 debug "Sourcing /etc/defaults/rc.conf"
878 . /etc/defaults/rc.conf
879 source_rc_confs
880 elif [ -r /etc/rc.conf ]; then
881 debug "Sourcing /etc/rc.conf (/etc/defaults/rc.conf doesn't exist)."
882 . /etc/rc.conf
883 fi
884 _rc_conf_loaded=true
885 fi
883 if [ -f /etc/rc.conf.d/"$_command" ]; then
884 debug "Sourcing /etc/rc.conf.d/${_command}"
885 . /etc/rc.conf.d/"$_command"
886
887 eval _override_command=\$${name}_program
888 command=${command:+${_override_command:-$command}}
889
890 if [ -z "${command}" ]; then
891 _tmp=`/bin/realpath $0`
892 prefix=${_tmp%/etc/rc.d/*}/
893 else
894 prefix=${command%/*bin/*}/
886 fi
895 fi
896 if [ "${prefix}" = "/" -o "${prefix}" = "/usr/" ] ; then
897 etcdir="/etc"
898 else
899 etcdir="${prefix}etc"
900 fi
887
901
902 # XXX - Deprecated
903 if [ -f /etc/rc.conf.d/${_name} -a ${etcdir} != "/etc" ]; then
904 debug "Sourcing /etc/rc.conf.d/${_name}"
905 warn "Warning: /etc/rc.conf.d/${_name} is deprecated, please use ${etcdir}/rc.conf.d/${_name} instead."
906 if [ -f ${etcdir}/rc.conf.d/${_name} ]
907 warn "Warning: Both /etc/rc.conf.d/${_name} and ${etcdir}/rc.conf.d/${_name} exist."
908 fi
909 . /etc/rc.conf.d/${_name}
910 fi
911
912 if [ -f ${etcdir}/rc.conf.d/${_name} ]; then
913 debug "Sourcing ${etcdir}/rc.conf.d/${_name}"
914 . ${etcdir}/rc.conf.d/${_name}
915 fi
916
888 # XXX - Deprecated variable name support
889 #
890 case ${OSTYPE} in
891 FreeBSD)
892 [ -n "$portmap_enable" ] && rpcbind_enable="$portmap_enable"
893 [ -n "$portmap_program" ] && rpcbind_program="$portmap_program"
894 [ -n "$portmap_flags" ] && rpcbind_flags="$portmap_flags"
895 [ -n "$single_mountd_enable" ] && mountd_enable="$single_mountd_enable"
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#
917 # XXX - Deprecated variable name support
918 #
919 case ${OSTYPE} in
920 FreeBSD)
921 [ -n "$portmap_enable" ] && rpcbind_enable="$portmap_enable"
922 [ -n "$portmap_program" ] && rpcbind_program="$portmap_program"
923 [ -n "$portmap_flags" ] && rpcbind_flags="$portmap_flags"
924 [ -n "$single_mountd_enable" ] && mountd_enable="$single_mountd_enable"
925 [ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable"
926 [ -n "$xntpd_program" ] && ntpd_program="$xntpd_program"
927 [ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags"
928 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
929 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
930 ;;
931 esac
932}
933
934#
906# load_rc_config_var cmd var
907# Read the rc.conf(5) var for cmd and set in the
935# load_rc_config_var name var
936# Read the rc.conf(5) var for name 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
937# current shell, using load_rc_config in a subshell to prevent
938# unwanted side effects from other variable assignments.
939#
940load_rc_config_var()
941{
942 if [ $# -ne 2 ]; then
914 err 3 'USAGE: load_rc_config_var cmd var'
943 err 3 'USAGE: load_rc_config_var name 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}

--- 508 unchanged lines hidden ---
944 fi
945 eval $(eval '(
946 load_rc_config '$1' >/dev/null;
947 if [ -n "${'$2'}" -o "${'$2'-UNSET}" != "UNSET" ]; then
948 echo '$2'=\'\''${'$2'}\'\'';
949 fi
950 )' )
951}

--- 508 unchanged lines hidden ---