Eliminate global symbols starting with an underscore from rc.d

scripts, except for mdconfig* and jail.  Such symbols are reserved
for the rc.subr internals.  Most scripts can be fixed by just
declaring _foo symbols as local: few scripts actually need them to
be global.

Discussed with:	dougb in freebsd-rc
This commit is contained in:
Yaroslav Tykhiy 2006-12-30 22:53:20 +00:00
parent 574c45c445
commit 45da9952e5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=165664
20 changed files with 74 additions and 41 deletions

View File

@ -23,6 +23,8 @@ sysv_start()
linux_start()
{
local _tmpdir
echo -n ' linux'
load_kld -e 'linux(aout|elf)' linux
if [ -x /compat/linux/sbin/ldconfigDisabled ]; then

View File

@ -20,6 +20,8 @@ stop_cmd="accounting_stop"
accounting_start()
{
local _dir
_dir=`dirname "$accounting_file"`
if [ ! -d `dirname "$_dir"` ]; then
if ! mkdir -p "$_dir"; then

View File

@ -34,6 +34,8 @@ ibcs2_compat()
archdep_start()
{
local _arch
_arch=`${SYSCTL_N} hw.machine_arch`
echo -n "Initial $_arch initialization:"
case $_arch in

View File

@ -43,6 +43,8 @@ stop_cmd="bluetooth_stop"
bluetooth_read_conf()
{
local _err _file _line _namespace
_file=$1
_namespace=$2
_err=0
@ -225,6 +227,8 @@ bluetooth_shutdown_stack()
bluetooth_start()
{
local _file
dev=$1
# Automatically load modules

View File

@ -45,8 +45,8 @@ bootconf_start()
done
echo
master=$$
_DUMMY=/etc/passwd
conf=${_DUMMY}
DUMMY=/etc/passwd
conf=${DUMMY}
while [ ! -d /etc/etc.$conf/. ]; do
trap "conf=$default; echo; echo Using default of $conf" ALRM
echo -n "Which configuration [$default] ? "
@ -57,7 +57,7 @@ bootconf_start()
conf=$default
fi
if [ ! -d /etc/etc.$conf/. ]; then
conf=${_DUMMY}
conf=${DUMMY}
fi
done

View File

@ -35,7 +35,7 @@
name="bridge"
start_cmd="bridge_start"
stop_cmd="bridge_stop"
_cmd=""
cmd=""
glob_int () {
case "$1" in
@ -52,7 +52,7 @@ bridge_test () {
if [ -n "${interfaces}" ]; then
for i in ${interfaces}; do
if glob_int $iface $i ; then
ifconfig $bridge $_cmd $iface > /dev/null 2>&1
ifconfig $bridge $cmd $iface > /dev/null 2>&1
return
fi
done
@ -62,13 +62,13 @@ bridge_test () {
autobridge()
{
if [ -n "${autobridge_interfaces}" ]; then
if [ -z "$_iflist" ]; then
if [ -z "$iflist" ]; then
# We're operating as a general network start routine.
_iflist="`list_net_interfaces`"
iflist="`list_net_interfaces`"
fi
for br in ${autobridge_interfaces}; do
for i in $_iflist; do
for i in $iflist; do
bridge_test $br $i
done
done
@ -77,17 +77,17 @@ autobridge()
bridge_start()
{
_cmd="addm"
cmd="addm"
autobridge
}
bridge_stop()
{
_cmd="deletem"
cmd="deletem"
autobridge
}
_iflist=$2
iflist=$2
load_rc_config $name
run_rc_command "$1"

View File

@ -17,7 +17,7 @@ stop_cmd=":"
ldconfig_start()
{
local _files
local _files _ins
_ins=
ldconfig=${ldconfig_command}

View File

@ -14,9 +14,9 @@ name="lpd"
rcvar=`set_rcvar`
command="/usr/sbin/${name}"
required_files="/etc/printcap"
start_precmd="_chkprintcap"
start_precmd="chkprintcap"
_chkprintcap()
chkprintcap()
{
if checkyesno chkprintcap_enable ; then
/usr/sbin/chkprintcap ${chkprintcap_flags}

View File

@ -14,9 +14,9 @@ name=moused
rcvar=`set_rcvar`
command="/usr/sbin/${name}"
start_cmd="moused_start"
_pidprefix="/var/run/moused"
pidfile="${_pidprefix}.pid"
_pidarg=
pidprefix="/var/run/moused"
pidfile="${pidprefix}.pid"
pidarg=
load_rc_config $name
# Set the pid file and variable name. The second argument, if it exists, is
@ -25,8 +25,8 @@ load_rc_config $name
if [ -n "$2" ]; then
eval moused_$2_enable=\${moused_$2_enable-${moused_nondefault_enable}}
rcvar=`set_rcvar moused_$2`
pidfile="${_pidprefix}.$2.pid"
_pidarg="-I $pidfile"
pidfile="${pidprefix}.$2.pid"
pidarg="-I $pidfile"
fi
moused_start()
@ -53,20 +53,20 @@ moused_start()
fi
echo -n "Starting ${ms} moused:"
/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${_pidarg}
/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
_mousechar_arg=
mousechar_arg=
case ${mousechar_start} in
[Nn][Oo] | '')
;;
*)
echo -n ' mousechar_start'
_mousechar_arg="-M ${mousechar_start}"
mousechar_arg="-M ${mousechar_start}"
;;
esac
for ttyv in /dev/ttyv* ; do
vidcontrol < ${ttyv} ${_mousechar_arg} -m on
vidcontrol < ${ttyv} ${mousechar_arg} -m on
done
echo '.'
}

View File

@ -38,15 +38,15 @@ stop_cmd="network_stop"
cloneup_cmd="clone_up"
clonedown_cmd="clone_down"
extra_commands="cloneup clonedown"
_cmdifn=
cmdifn=
network_start()
{
# Set the list of interfaces to work on.
#
_cmdifn=$*
cmdifn=$*
if [ -z "$_cmdifn" ]; then
if [ -z "$cmdifn" ]; then
#
# We're operating as a general network start routine.
#
@ -71,8 +71,8 @@ network_start()
# Resync ipfilter
/etc/rc.d/ipfilter resync
fi
if [ -f /etc/rc.d/bridge -a -n "$_cmdifn" ] ; then
/etc/rc.d/bridge start $_cmdifn
if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
/etc/rc.d/bridge start $cmdifn
fi
}
@ -80,7 +80,7 @@ network_stop()
{
# Set the list of interfaces to work on.
#
_cmdifn=$*
cmdifn=$*
echo -n "Stopping network:"
@ -98,6 +98,8 @@ network_stop()
# configured interface(s).
network_common()
{
local _cooked_list _fail _func _verbose
_func=
_verbose=
@ -111,15 +113,16 @@ network_common()
# Set the scope of the command (all interfaces or just one).
#
_cooked_list=
if [ -n "$_cmdifn" ]; then
if [ -n "$cmdifn" ]; then
# Don't check that the interfaces exist. We need to run
# the down code even when the interface doesn't exist to
# kill off wpa_supplicant.
_cooked_list="$_cmdifn"
_cooked_list="$cmdifn"
else
_cooked_list="`list_net_interfaces`"
fi
_fail=
for ifn in ${_cooked_list}; do
if ${_func} ${ifn} ; then
eval showstat_$ifn=1

View File

@ -38,6 +38,8 @@ stop_cmd=":"
generate_host_conf()
{
local _cont _sources
nsswitch_conf=$1; shift;
host_conf=$1; shift;

View File

@ -18,6 +18,8 @@ stop_cmd=":"
pppoed_start()
{
local _opts
if [ -n "${pppoed_provider}" ]; then
pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
fi

View File

@ -18,12 +18,14 @@ required_files="/etc/syslog.conf"
start_precmd="syslogd_precmd"
extra_commands="reload"
_sockfile="/var/run/syslogd.sockets"
sockfile="/var/run/syslogd.sockets"
evalargs="rc_flags=\"\`set_socketlist\` \$rc_flags\""
altlog_proglist="named"
syslogd_precmd()
{
local _l _ldir
# Transitional symlink for old binaries
#
if [ ! -L /dev/log ]; then
@ -33,7 +35,7 @@ syslogd_precmd()
# Create default list of syslog sockets to watch
#
( umask 022 ; > $_sockfile )
( umask 022 ; > $sockfile )
# If running named(8) or ntpd(8) chrooted, added appropriate
# syslog socket to list of sockets to watch.
@ -41,7 +43,7 @@ syslogd_precmd()
for _l in $altlog_proglist; do
eval _ldir=\$${_l}_chrootdir
if checkyesno `set_rcvar $_l` && [ -n "$_ldir" ]; then
echo "${_ldir}/var/run/log" >> $_sockfile
echo "${_ldir}/var/run/log" >> $sockfile
fi
done
@ -49,8 +51,8 @@ syslogd_precmd()
# internal copy of $syslogd_flags to force use of specific
# syslogd sockets.
#
if [ -s $_sockfile ]; then
echo "/var/run/log" >> $_sockfile
if [ -s $sockfile ]; then
echo "/var/run/log" >> $sockfile
eval $evalargs
fi
@ -59,8 +61,10 @@ syslogd_precmd()
set_socketlist()
{
local _s _socketargs
_socketargs=
for _s in `cat $_sockfile | tr '\n' ' '` ; do
for _s in `cat $sockfile | tr '\n' ' '` ; do
_socketargs="-l $_s $_socketargs"
done
echo $_socketargs

View File

@ -36,7 +36,7 @@ name="var"
load_rc_config $name
_populate_var()
populate_var()
{
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
case ${sendmail_enable} in
@ -73,7 +73,7 @@ esac
# in realistic diskless setups, we're probably ok.
case "${populate_var}" in
[Yy][Ee][Ss])
_populate_var
populate_var
;;
[Nn][Oo])
exit 0
@ -82,7 +82,7 @@ case "${populate_var}" in
if [ -d /var/run -a -d /var/db -a -d /var/empty ] ; then
true
elif [ -x /usr/sbin/mtree ] ; then
_populate_var
populate_var
else
# We need mtree to populate /var so try mounting /usr.
# If this does not work, we can not boot so it is OK to
@ -91,7 +91,7 @@ case "${populate_var}" in
if [ ! -x /usr/sbin/mtree ] ; then
exit 1
else
_populate_var
populate_var
fi
fi
;;

View File

@ -20,6 +20,8 @@ command_args="${nis_client_flags}"
ypbind_precmd()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then

View File

@ -20,6 +20,8 @@ command_args="${nis_yppasswdd_flags}"
yppasswdd_precmd()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then

View File

@ -19,6 +19,8 @@ command_args="${nis_server_flags}"
ypserv_prestart()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then

View File

@ -17,6 +17,8 @@ command_args="${nis_ypset_flags}"
ypset_precmd()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then

View File

@ -15,6 +15,8 @@ start_precmd="rpc_ypupdated_precmd"
rpc_ypupdated_precmd()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then

View File

@ -17,6 +17,8 @@ command_args="${nis_ypxfrd_flags}"
ypxfrd_precmd()
{
local _domain
if ! checkyesno rpcbind_enable && \
! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then