Massive whitespace cleanup

This commit is contained in:
Roy Marples 2007-11-28 15:45:03 +00:00
parent 444f23e2d1
commit ac9279cc0d
68 changed files with 613 additions and 608 deletions

View File

@ -974,7 +974,7 @@
#
# # Test to see if we're docked or not and configure like so
# # config_docked="dhcp"
# if grep -q "1" /sys/devices/platform/dock.0/docked ; then
# if grep -q "1" /sys/devices/platform/dock.0/docked; then
# einfo "${IFACE} is docked - configuring"
# _configure_variables "docked"
# fi
@ -1009,15 +1009,15 @@
# # 'from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100' \
# #"
# eval set -- $\rules_${IFVAR}
# if [ $# != 0 ] ; then
# if [ $# != 0 ]; then
# einfo "Adding IP policy routing rules"
# eindent
# # Ensure that the kernel supports policy routing
# if ! ip rule list | grep -q "^" ; then
# if ! ip rule list | grep -q "^"; then
# eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
# eerror "in your kernel to use ip rules"
# else
# for x in "$@" ; do
# for x in "$@"; do
# ebegin "${x}"
# ip rule add ${x} dev "${IFACE}"
# eend $?
@ -1037,11 +1037,11 @@
# [ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g
# Automatically erase any ip rules created in the example postup above
# if interface_exists "${IFACE}" ; then
# if interface_exists "${IFACE}"; then
# # Remove any rules for this interface
# local rule
# ip rule list | grep " iif ${IFACE}[ ]*" | {
# while read rule ; do
# while read rule; do
# rule="${rule#*:}"
# ip rule del ${rule}
# done

View File

@ -41,9 +41,9 @@ install::
$(_SUBDIR)
install:: $(BIN) $(CONF) $(CONF_APPEND)
if test -n "$(DIR)" ; then $(INSTALL) -d $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(BIN)" ; then $(INSTALL) $(BIN) $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(INC)" ; then $(INSTALL) -m 0644 $(INC) $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(DIR)"; then $(INSTALL) -d $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(BIN)"; then $(INSTALL) $(BIN) $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(INC)"; then $(INSTALL) -m 0644 $(INC) $(DESTDIR)$(DIR) || exit $$?; fi
for x in $(CONF); do \
if ! test -e $(DESTDIR)$(DIR)/$$x; then \
$(INSTALL) -m 0644 $$x $(DESTDIR)$(DIR) || exit $$?; \

View File

@ -69,7 +69,7 @@ stop() {
fi
ebegin "Stopping the System Clock Adjuster"
if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz ; then
if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz; then
start-stop-daemon --stop --exec /sbin/adjkerntz
eend $?
else

View File

@ -33,7 +33,7 @@ depend() {
start() {
# Setup any user requested dump device
if [ -n "${dump_device}" ] ; then
if [ -n "${dump_device}" ]; then
ebegin "Activating kernel core dump device (${dump_device})"
dumpon ${dump_device}
eend $?

View File

@ -42,8 +42,8 @@ ipfw() {
init() {
# Load the kernel module
if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>/dev/null; then
if ! kldload ipfw ; then
if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then
if ! kldload ipfw; then
eend 1 "Unable to load firewall module"
return 1
fi
@ -68,7 +68,7 @@ init() {
start() {
local i= p= log=
ebegin "Starting firewall rules"
if ! init ; then
if ! init; then
eend 1 "Failed to flush firewall ruleset"
return 1
fi
@ -157,7 +157,7 @@ stop() {
panic() {
ebegin "Stopping firewall rules - hard"
if ! init ; then
if ! init; then
eend 1 "Failed to flush firewall ruleset"
return 1
fi

View File

@ -24,7 +24,7 @@
# SUCH DAMAGE.
mouse=${SVCNAME##*.}
if [ -n "${name}" -a "${mouse}" != "moused" ] ; then
if [ -n "${name}" -a "${mouse}" != "moused" ]; then
moused_device=/dev/"${mouse}"
pidfile=/var/run/moused-"${mouse}".pid
else
@ -41,9 +41,9 @@ depend() {
start() {
ebegin "Starting ${name}"
if [ -z "${moused_device}" ] ; then
if [ -z "${moused_device}" ]; then
local dev=
for dev in /dev/psm[0-9]* /dev/ums[0-9]* ; do
for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do
[ -c "${dev}" ] || continue
[ -e /var/run/moused-"${dev##*/}".pid ] && continue
moused_device=${dev}
@ -54,7 +54,7 @@ start() {
done
fi
if [ -z "${moused_device}" ] ; then
if [ -z "${moused_device}" ]; then
eend 1 "No mouse device found"
return 1
fi

View File

@ -38,7 +38,7 @@ start() {
chmod 700 "${dump_dir}"
fi
if [ "${RC_UNAME}" = "FreeBSD" ] ; then
if [ "${RC_UNAME}" = "FreeBSD" ]; then
# Don't quote ${dump_device}, so that if it's unset,
# savecore will check on the partitions listed in fstab
# without errors in the output

View File

@ -52,7 +52,7 @@ start() {
ebegin "Changing function keys"
eval set -- "${keychange}"
eindent
while [ $# -gt 0 ] ; do
while [ $# -gt 0 ]; do
veinfo "F$1 -> \`$2'"
kbdcontrol -f "$1" "$2" </dev/console
veend $?

View File

@ -34,7 +34,7 @@ start() {
ebegin "Configuring kernel parameters"
local retval=0 var= comments=
while read var comments ; do
while read var comments; do
case "${var}" in
""|"#"*) continue;;
esac

View File

@ -54,9 +54,9 @@ setupopts() {
TBLURB="s390"
;;
*)
if [ -e /proc/devices ] && grep -q " cobd$" /proc/devices ; then
if [ -e /proc/devices ] && grep -q " cobd$" /proc/devices; then
TBLURB="coLinux"
elif [ "${CLOCK}" = "UTC" ] ; then
elif [ "${CLOCK}" = "UTC" ]; then
utc="--utc"
TBLURB="UTC"
else
@ -77,7 +77,7 @@ start() {
ebegin "Setting system clock using the hardware clock [${TBLURB}]"
if [ -n "${utc}" ]; then
if [ -e /proc/modules -a ! -e /dev/rtc ] ; then
if [ -e /proc/modules -a ! -e /dev/rtc ]; then
modprobe -q rtc || modprobe -q genrtc
fi
@ -120,7 +120,7 @@ stop() {
fi
errstr="$(LC_ALL=C hwclock --systohc ${utc} ${clock_args} 2>&1 >/dev/null)"
fi
if [ -n "${errstr}" ] ; then
if [ -n "${errstr}" ]; then
ewarn "${errstr}"
retval=1
fi

View File

@ -70,7 +70,7 @@ start() {
# Set the console font
local errmsg=
ebegin "Setting user font"
if [ -x /bin/setfont ] ; then
if [ -x /bin/setfont ]; then
# We patched setfont to have --tty support ...
if [ -n "$(setfont --help 2>&1 | grep -e '--tty')" ] || \
[ -n "$(setfont --help 2>&1 | grep -e '-C')" ]
@ -110,7 +110,7 @@ start() {
for font in /usr/share/consolefonts/"${consolefont}".*; do :; done
cp "${font}" "${RC_LIBDIR}"/console
echo "$(basename "${font}")" > "${RC_LIBDIR}"/console/font
if yesno ${unicode:-${UNICODE}} ; then
if yesno ${unicode:-${UNICODE}}; then
printf "" > "${RC_LIBDIR}"/console/unicode
else
rm -f "${RC_LIBDIR}"/console/unicode

View File

@ -47,7 +47,7 @@ start() {
;;
esac
if [ -z "${keymap}" ] ; then
if [ -z "${keymap}" ]; then
eerror "You need to setup keymap in /etc/conf.d/keymaps first"
return 1
fi
@ -59,7 +59,7 @@ start() {
|| ttydev=/dev/tty
# Force linux keycodes for PPC.
if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ] ; then
if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then
echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
fi
@ -74,7 +74,7 @@ start() {
fi
ebegin "Loading key mappings"
if [ -x /bin/loadkeys ] ; then
if [ -x /bin/loadkeys ]; then
yesno ${windowskeys} && wkeys="windowkeys"
loadkeys -q ${loadkeys_uni} ${wkeys} ${keymap} ${extended_keymaps}
eend $? "Error loading key mappings"

View File

@ -45,7 +45,7 @@ load_modules() {
eindent
local x= cnt=0
for x in "$@" ; do
for x in "$@"; do
set -- ${x}
ebegin "Loading module $1"
eval modprobe -q "$@"
@ -92,16 +92,16 @@ start() {
auto=/etc/modules.autoload
else
local x= f="/etc/modules.autoload.d/kernel"
for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do
if [ -f "${f}-${x}.${RC_SOFTLEVEL}" ] ; then
for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR}; do
if [ -f "${f}-${x}.${RC_SOFTLEVEL}" ]; then
auto="${f}-${x}.${RC_SOFTLEVEL}"
break
fi
if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" -a -f "${f}-${x}.${RC_DEFAULTLEVEL}" ] ; then
if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" -a -f "${f}-${x}.${RC_DEFAULTLEVEL}" ]; then
auto="${f}-${x}.${RC_DEFAULTLEVEL}"
break
fi
if [ -f "${f}-${x}" ] ; then
if [ -f "${f}-${x}" ]; then
auto="${f}-${x}"
break
fi

View File

@ -38,7 +38,7 @@ _setleds() {
local dev=/dev/tty t= i=1 retval=0
[ -d /dev/vc ] && dev=/dev/vc/
while [ ${i} -le ${ttyn} ] ; do
while [ ${i} -le ${ttyn} ]; do
setleds -D "$1"num < ${dev}${i} || retval=1
i=$((${i} + 1))
done

View File

@ -44,7 +44,7 @@ start() {
if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ]; then
local usbfs=$(grep -Fow usbfs /proc/filesystems ||
grep -Fow usbdevfs /proc/filesystems)
if [ -n "${usbfs}" ] ; then
if [ -n "${usbfs}" ]; then
ebegin "Mounting USB device filesystem (${usbfs})"
local usbgid="$(getent group usb | \
sed -e 's/.*:.*:\(.*\):.*/\1/')"
@ -56,8 +56,8 @@ start() {
fi
# Setup Kernel Support for the NFS daemon status
if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd ; then
if grep -qs nfsd /proc/filesystems ; then
if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then
if grep -qs nfsd /proc/filesystems; then
ebegin "Mounting nfsd filesystem"
mount -t nfsd -o nodev,noexec,nosuid \
nfsd /proc/fs/nfsd
@ -66,8 +66,8 @@ start() {
fi
# Setup Kernel Support for miscellaneous Binary Formats
if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo -q /proc/sys/fs/binfmt_misc ; then
if grep -qs binfmt_misc /proc/filesystems ; then
if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo -q /proc/sys/fs/binfmt_misc; then
if grep -qs binfmt_misc /proc/filesystems; then
ebegin "Mounting misc binary format filesystem"
mount -t binfmt_misc -o nodev,noexec,nosuid \
binfmt_misc /proc/sys/fs/binfmt_misc
@ -76,8 +76,8 @@ start() {
fi
# Setup Kernel Support for securityfs
if [ -d /sys/kernel/security ] && ! mountinfo -q /sys/kernel/security ; then
if grep -qs securityfs /proc/filesystems ; then
if [ -d /sys/kernel/security ] && ! mountinfo -q /sys/kernel/security; then
if grep -qs securityfs /proc/filesystems; then
ebegin "Mounting security filesystem"
mount -t securityfs securityfs /sys/kernel/security \
-o nodev,noexec,nosuid
@ -86,8 +86,8 @@ start() {
fi
# Setup Kernel Support for debugfs
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug ; then
if grep -qs debugfs /proc/filesystems ; then
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
if grep -qs debugfs /proc/filesystems; then
ebegin "Mounting debug filesystem"
mount -t debugfs debugfs /sys/kernel/debug \
-o nodev,noexec,nosuid
@ -96,8 +96,8 @@ start() {
fi
# Setup Kernel Support for SELinux
if [ -d /selinux ] && ! mountinfo -q /selinux ; then
if grep -qs selinuxfs /proc/filesystems ; then
if [ -d /selinux ] && ! mountinfo -q /selinux; then
if grep -qs selinuxfs /proc/filesystems; then
ebegin "Mounting SELinux filesystem"
mount -t selinuxfs selinuxfs /selinux
eend $?

View File

@ -96,8 +96,8 @@ start_pre() {
local getuser="stat -f%Su"
[ "${RC_UNAME}" = "Linux" ] && getuser="stat -c%U"
case $(${getuser} "${named_chroot}${namedb}"/rndc.key) in
root|"${named_uid}") ;;
*) ${confgen} ;;
root|"${named_uid}");;
*) ${confgen};;
esac
else
${confgen}

View File

@ -34,7 +34,7 @@ name="Network Time Protocol Daemon"
depend() {
use dns
need localmount
after bootmisc ntpdate ntp-client
after bootmisc ntp-client
}
start_pre() {

View File

@ -27,7 +27,7 @@
command=/usr/sbin/sshd
command_args=${sshd_args}
pidfile=/var/run/sshd.pid
required_files=/etc/sshd/sshd_config
required_files=/etc/ssh/sshd_config
required_dirs=/var/empty
depend() {

View File

@ -37,12 +37,12 @@ do_checkfs() {
ebegin "Checking all filesystems"
if [ -e /forcefsck ] || get_bootparam "forcefsck" ; then
if [ -e /forcefsck ] || get_bootparam "forcefsck"; then
ewarn "A full fsck has been forced"
mode="-f -n"
fi
if [ "${RC_UNAME}" = "Linux" ] ; then
if [ "${RC_UNAME}" = "Linux" ]; then
opts="-A -C0 -R -T"
else
parts="$(fstabinfo --passno ">1")"
@ -52,14 +52,14 @@ do_checkfs() {
fsck ${opts} ${mode} ${parts}
retval=$?
if [ ${retval} -eq 0 ] ; then
if [ ${retval} -eq 0 ]; then
eend 0
elif [ ${retval} -eq 1 ] ; then
elif [ ${retval} -eq 1 ]; then
ewend 1 "Filesystem errors corrected."
retval=0
elif [ ${retval} -eq 2 ] ; then
elif [ ${retval} -eq 2 ]; then
ewend 1 "System should be rebooted"
elif [ ${retval} -eq 8 ] ; then
elif [ ${retval} -eq 8 ]; then
ewend 1 "Operational error, continuing"
retval=0
else
@ -70,7 +70,7 @@ do_checkfs() {
eend ${retval}
fi
if [ ${retval} -gt 3 ] ; then
if [ ${retval} -gt 3 ]; then
eend 2 "Fsck could not correct all errors, manual repair needed"
exec rc-abort || exit 1
fi

View File

@ -29,7 +29,7 @@ and optionally repair them."
do_mtab() {
# Don't create mtab if /etc is readonly
if ! printf "" 2>/dev/null >/etc/mtab ; then
if ! printf "" 2>/dev/null >/etc/mtab; then
ewarn "Skipping /etc/mtab initialization (ro root?)"
return 0
fi
@ -59,7 +59,7 @@ do_fsck() {
esac
# Don't bother doing a fsck on these
if [ -n "${CDBOOT}" ] || is_net_fs / || is_union_fs / ; then
if [ -n "${CDBOOT}" ] || is_net_fs / || is_union_fs /; then
return 0
fi
@ -71,7 +71,7 @@ do_fsck() {
root=$(fstabinfo --blockdevice /)
[ ! -e "${root}" -a -e /dev/root ] && root=/dev/root
if [ -e /forcefsck ] || get_bootparam "forcefsck" ; then
if [ -e /forcefsck ] || get_bootparam "forcefsck"; then
ebegin "Checking root filesystem (full fsck forced)"
fsck ${opts} -f -n "${root}"
# /forcefsck isn't deleted because checkfs needs it.
@ -80,7 +80,7 @@ do_fsck() {
else
# Obey the fs_passno setting for / (see fstab(5))
local pass=$(fstabinfo --passno /)
if [ ${pass:-0} != "0" ] ; then
if [ ${pass:-0} != "0" ]; then
ebegin "Checking root filesystem"
fsck ${opts} -p "${root}"
retval=$?
@ -90,15 +90,15 @@ do_fsck() {
fi
fi
if [ ${retval} -eq 0 ] ; then
if [ ${retval} -eq 0 ]; then
eend 0
elif [ ${retval} -eq 1 ] ; then
elif [ ${retval} -eq 1 ]; then
ewend 1 "Filesystem repaired"
retval=0
elif [ ${retval} -eq 8 ] ; then
elif [ ${retval} -eq 8 ]; then
ewend 1 $"Operational error, continuing"
retval=0
elif [ ${retval} -eq 2 -o ${retval} -eq 3 ] ; then
elif [ ${retval} -eq 2 -o ${retval} -eq 3 ]; then
ewend 1 "Filesystem repaired, but reboot needed!"
if ! yesno ${rc_force_auto:-${RC_FORCE_AUTO}}; then
printf "\a"; sleep 1; printf "\a"; sleep 1
@ -117,9 +117,9 @@ do_fsck() {
eend 2 "Filesystem couldn't be fixed :("
exec rc-abort || exit 1
fi
if [ ${retval} != "0" ] ; then
if [ ${retval} != "0" ]; then
einfo "Unmounting filesystems"
if [ "${RC_UNAME}" = "Linux" ] ; then
if [ "${RC_UNAME}" = "Linux" ]; then
mount -a -o remount,ro /
else
mount -u -o ro /
@ -135,7 +135,7 @@ start() {
if ! root_rw; then
ebegin "Remounting root filesystem read/write"
if [ "${RC_UNAME}" = "Linux" ] ; then
if [ "${RC_UNAME}" = "Linux" ]; then
mount -n -o remount,rw /
else
mount -u -o rw /

View File

@ -29,7 +29,7 @@
[ -r /etc/rc.conf ] && . /etc/rc.conf
# Support LiveCD foo
if [ -r /sbin/livecd-functions.sh ] ; then
if [ -r /sbin/livecd-functions.sh ]; then
. /sbin/livecd-functions.sh
livecd_read_commandline
fi
@ -38,7 +38,7 @@ stop_addon devfs
stop_addon udev
# Really kill things off before unmounting
if [ -x /sbin/killall5 ] ; then
if [ -x /sbin/killall5 ]; then
killall5 -15
killall5 -9
fi
@ -50,7 +50,7 @@ sync; sync
# 1) we don't need (and by default can't) umount anything (VServer) or
# 2) the host utils take care of all umounting stuff (OpenVZ)
if [ "${RC_SYS}" = "VPS" ]; then
if [ -e /etc/init.d/"$1".sh ] ; then
if [ -e /etc/init.d/"$1".sh ]; then
. /etc/init.d/"$1".sh
else
exit 0
@ -60,11 +60,11 @@ fi
# If $svcdir is still mounted, preserve it if we can
mnt=$(mountinfo --node "${RC_SVCDIR}")
if [ -n "${mnt}" -a -w "${RC_LIBDIR}" ] ; then
if [ -n "${mnt}" -a -w "${RC_LIBDIR}" ]; then
f_opts="-m -c"
[ "${RC_UNAME}" = "Linux" ] && f_opts="-c"
if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ] ; then
fuser -k ${f_opts} "${svcdir}" 1>/dev/null 2>/dev/null
if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ]; then
fuser -k ${f_opts} "${svcdir}" >/dev/null 2>&1
sleep 2
fi
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
@ -83,20 +83,20 @@ if [ -n "${mnt}" -a -w "${RC_LIBDIR}" ] ; then
"${RC_LIBDIR}"/rc.log
# Release the memory disk if we used it
case "${mnt}" in
"/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;;
"/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}";;
esac
fi
unmounted=0
# Remount the remaining filesystems read-only
# Most BSD's don't need this as the kernel handles it nicely
if [ "${RC_UNAME}" = "Linux" ] ; then
if [ "${RC_UNAME}" = "Linux" ]; then
ebegin "Remounting remaining filesystems read-only"
# We need the do_unmount function
. "${RC_LIBDIR}"/sh/rc-mount.sh
eindent
fs=
for x in ${net_fs_list} ; do
for x in ${net_fs_list}; do
fs="${fs}${fs:+|}${x}"
done
[ -n "${fs}" ] && fs="^(${fs})$"
@ -109,14 +109,14 @@ if [ "${RC_UNAME}" = "Linux" ] ; then
fi
# This UPS code should be moved to out of here and to an addon
if [ -f /etc/killpower ] ; then
if [ -f /etc/killpower ]; then
UPS_CTL=/sbin/upsdrvctl
UPS_POWERDOWN="${UPS_CTL} shutdown"
elif [ -f /etc/apcupsd/powerfail ] ; then
elif [ -f /etc/apcupsd/powerfail ]; then
UPS_CTL=/etc/apcupsd/apccontrol
UPS_POWERDOWN="${UPS_CTL} killpower"
fi
if [ -x "${UPS_CTL}" ] ; then
if [ -x "${UPS_CTL}" ]; then
ewarn "Signalling ups driver(s) to kill the load!"
${UPS_POWERDOWN}
ewarn "Halt system and wait for the UPS to kill our power"
@ -124,7 +124,7 @@ if [ -x "${UPS_CTL}" ] ; then
sleep 60
fi
if [ ${unmounted} -ne 0 ] ; then
if [ ${unmounted} -ne 0 ]; then
[ -x /sbin/sulogin ] && sulogin -t 10 /dev/console
exit 1
fi

View File

@ -36,7 +36,7 @@ start() {
# Add any misc programs that should be started
# to /etc/conf.d/local.start
if [ -e /etc/conf.d/local.start ] ; then
if [ -e /etc/conf.d/local.start ]; then
. /etc/conf.d/local.start
fi
@ -48,7 +48,7 @@ stop() {
# Add any misc programs that should be stopped
# to /etc/conf.d/local.stop
if [ -e /etc/conf.d/local.stop ] ; then
if [ -e /etc/conf.d/local.stop ]; then
. /etc/conf.d/local.stop
fi

View File

@ -58,7 +58,7 @@ stop() {
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
no_umounts="${no_umounts}|${x}"
done
if [ "${SIFS}" = "y" ] ; then
if [ "${SIFS}" = "y" ]; then
IFS=$OIFS
else
unset IFS

View File

@ -30,9 +30,9 @@ need_portmap() {
local mnt opts ret IFS="
"
set -- $(fstabinfo --fstype nfs,nfs4)
for mnt in "$@" ; do
for mnt in "$@"; do
case ,$(fstabinfo --options "${mnt}"), in
*,noauto,*|*,nolock,*) ;;
*,noauto,*|*,nolock,*);;
*) return 0;;
esac
done
@ -89,7 +89,7 @@ stop() {
ebegin "Unmounting network filesystems"
. "${RC_LIBDIR}/sh/rc-mount.sh"
for x in ${net_fs_list} ; do
for x in ${net_fs_list}; do
fs="${fs}${fs:+,}${x}"
done
if [ -n "${fs}" ]; then

View File

@ -32,7 +32,7 @@ depend() {
}
start() {
if [ -f /etc/nologin.boot ] ; then
if [ -f /etc/nologin.boot ]; then
rm -f /etc/nologin /etc/nologin.boot
fi
}

View File

@ -35,7 +35,7 @@ depend() {
save_seed() {
local poolsize=1
if [ -e /proc/sys/kernel/random/poolsize ] ; then
if [ -e /proc/sys/kernel/random/poolsize ]; then
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
fi
@ -47,7 +47,7 @@ save_seed() {
start() {
[ -c /dev/urandom ] || return
if [ -f "${urandom_seed}" ] ; then
if [ -f "${urandom_seed}" ]; then
ebegin "Initializing random number generator"
cat "${urandom_seed}" > /dev/urandom
eend $? "Error initializing random number generator"

View File

@ -31,7 +31,7 @@ ifconfig_depend() {
_exists() {
# Only FreeBSD sees to have /dev/net .... is there something
# other than ifconfig we can use for the others?
if [ -d /dev/net ] ; then
if [ -d /dev/net ]; then
[ -e /dev/net/"${IFACE}" ]
else
ifconfig "${IFACE}" >/dev/null 2>&1
@ -43,10 +43,10 @@ _get_mac_address() {
sed -n -e 's/^[[:space:]]*ether \(..:..:..:..:..:..\).*/\1/p')
case "${mac}" in
00:00:00:00:00:00) ;;
44:44:44:44:44:44) ;;
FF:FF:FF:FF:FF:FF) ;;
*) echo "${mac}"; return 0 ;;
00:00:00:00:00:00);;
44:44:44:44:44:44);;
FF:FF:FF:FF:FF:FF);;
*) echo "${mac}"; return 0;;
esac
return 1
@ -64,8 +64,8 @@ _ifindex() {
local x= i=1
case "${RC_UNAME}" in
FreeBSD|DragonFly)
for x in /dev/net[0-9]* ; do
if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then
for x in /dev/net[0-9]*; do
if [ "${x}" -ef /dev/net/"${IFACE}" ]; then
echo "${x#/dev/net}"
return 0
fi
@ -73,8 +73,8 @@ _ifindex() {
done
;;
default)
for x in $(ifconfig -a | sed -n -e 's/^\([^[:space:]]*\):.*/\1/p') ; do
if [ "${x}" = "${IFACE}" ] ; then
for x in $(ifconfig -a | sed -n -e 's/^\([^[:space:]]*\):.*/\1/p'); do
if [ "${x}" = "${IFACE}" ]; then
echo "${i}"
return 0
fi
@ -107,10 +107,10 @@ _add_address() {
local inet6=
case "$@" in
*:*) inet6=inet6 ;;
*:*) inet6=inet6;;
esac
if [ "${metric:-0}" != "0" ] ; then
if [ "${metric:-0}" != "0" ]; then
set -- "$@" metric ${metric}
fi
@ -130,32 +130,32 @@ _add_address() {
}
_add_route() {
if [ $# -gt 3 ] ; then
if [ "$3" = "gw" -o "$3" = "via" ] ; then
if [ $# -gt 3 ]; then
if [ "$3" = "gw" -o "$3" = "via" ]; then
local one=$1 two=$2
shift ; shift; shift
shift; shift; shift
set -- "${one}" "${two}" "$@"
fi
fi
case "$@" in
*:*) route add -inet6 "$@" ;;
*) route add "$@" ;;
*:*) route add -inet6 "$@";;
*) route add "$@";;
esac
}
_delete_addresses() {
# We don't remove addresses from aliases
case "${IFACE}" in
*:*) return 0 ;;
*:*) return 0;;
esac
einfo "Removing addresses"
eindent
local addr=
for addr in $(LC_ALL=C ifconfig "${IFACE}" |
sed -n -e 's/^[[:space:]]*inet \([^ ]*\).*/\1/p') ; do
if [ "${addr}" = "127.0.0.1" ] ; then
sed -n -e 's/^[[:space:]]*inet \([^ ]*\).*/\1/p'); do
if [ "${addr}" = "127.0.0.1" ]; then
# Don't delete the loopback address
[ "$1" = "lo" -o "$1" = "lo0" ] && continue
fi
@ -166,10 +166,10 @@ _delete_addresses() {
# Remove IPv6 addresses
for addr in $(LC_ALL=C ifconfig "${IFACE}" | \
sed -n -e 's/^[[:space:]]*inet6 \([^ ]*\).*/\1/p') ; do
sed -n -e 's/^[[:space:]]*inet6 \([^ ]*\).*/\1/p'); do
case "${addr}" in
*"%${IFACE}") continue ;;
::1) continue ;;
*"%${IFACE}") continue;;
::1) continue;;
esac
einfo "${addr}"
ifconfig "${IFACE}" inet6 delete "${addr}"
@ -203,11 +203,11 @@ ifconfig_pre_start() {
args=
for arg in ${conf}; do
case ${arg} in
[Dd][Hh][Cc][Pp]) ;;
[Nn][Oo][Aa][Uu][Tt][Oo]) ;;
[Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
[Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
[Ww][Pp][Aa]) ;;
[Dd][Hh][Cc][Pp]);;
[Nn][Oo][Aa][Uu][Tt][Oo]);;
[Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]);;
[Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]);;
[Ww][Pp][Aa]);;
*) args="${args} ${arg}";;
esac
done

View File

@ -45,7 +45,7 @@ iwconfig_get_wep_status() {
_iwconfig_get() {
LC_ALL=C ifconfig "${IFACE}" | \
sed -n -e "s/^[[:space:]]*ssid \(.*\) channel \([0-9]*\) bssid \(..:..:..:..:..:..\)\$/\\$1/p"
sed -n -e "s/^[[:space:]]*ssid \(.*\) channel \([0-9]*\).* bssid \(..:..:..:..:..:..\)\$/\\$1/p"
}
_get_ssid() {

View File

@ -28,8 +28,9 @@ apipa_depend() {
}
_random() {
if [ -n "${BASH}" ] ; then
echo "${RANDOM}"
local r=${RANDOM}
if [ -n "${r}" ]; then
echo "${r}"
else
uuidgen | sed -n -e 's/[^[:digit:]]//g' -e 's/\(^.\{1,7\}\).*/\1/p'
fi
@ -49,7 +50,7 @@ apipa_start() {
addr="169.254.${i1}.${i2}"
vebegin "${addr}/16"
if ! arping_address "${addr}" ; then
if ! arping_address "${addr}"; then
eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
config_index=$((${config_index} - 1))
veend 0

View File

@ -33,9 +33,9 @@ arping_address() {
# We only handle IPv4 addresses
case "${ip}" in
0.0.0.0|0) return 1 ;;
*.*.*.*) ;;
*) return 1 ;;
0.0.0.0|0) return 1;;
*.*.*.*);;
*) return 1;;
esac
# We need to bring the interface up to test
@ -64,8 +64,8 @@ arping_address() {
fi
[ -z "${foundmac}" ] && return 1
if [ -n "${mac}" ] ; then
if [ "${mac}" != "${foundmac}" ] ; then
if [ -n "${mac}" ]; then
if [ "${mac}" != "${foundmac}" ]; then
vewarn "Found ${ip} but MAC ${foundmac} does not match"
return 1
fi
@ -86,7 +86,7 @@ arping_start() {
einfo "Pinging gateways on ${IFACE} for configuration"
eval gateways=\$gateways_${IFVAR}
if [ -z "${gateways}" ] ; then
if [ -z "${gateways}" ]; then
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
return 1
fi
@ -99,18 +99,18 @@ arping_start() {
local ip=$1 mac=$2 spoof=$3 extra=
unset IFS
if [ -n "${mac}" ] ; then
if [ -n "${mac}" ]; then
mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')"
extra="(MAC ${mac})"
fi
vebegin "${ip} ${extra}"
if arping_address "${ip}" "${mac}" "${spoof}" ; then
if arping_address "${ip}" "${mac}" "${spoof}"; then
local IFS=.
for i in ${ip} ; do
if [ "${#i}" = "2" ] ; then
for i in ${ip}; do
if [ "${#i}" = "2" ]; then
conf="${conf}0${i}"
elif [ "${#i}" = "1" ] ; then
elif [ "${#i}" = "1" ]; then
conf="${conf}00${i}"
else
conf="${conf}${i}"

View File

@ -40,8 +40,8 @@ bonding_pre_start() {
[ -z "${slaves}" ] && return 0
# Load the kernel module if required
if [ ! -d /proc/net/bonding ] ; then
if ! modprobe bonding ; then
if [ ! -d /proc/net/bonding ]; then
if ! modprobe bonding; then
eerror "Cannot load the bonding module"
return 1
fi
@ -49,12 +49,12 @@ bonding_pre_start() {
# We can create the interface name we like now, but this
# requires sysfs
if ! _exists && [ -d /sys/class/net ] ; then
if ! _exists && [ -d /sys/class/net ]; then
echo "+${IFACE}" > /sys/class/net/bonding_masters
fi
_exists true || return 1
if ! _is_bond ; then
if ! _is_bond; then
eerror "${IFACE} is not capable of bonding"
return 1
fi
@ -107,7 +107,7 @@ bonding_stop() {
# reset all slaves
(
for IFACE in ${slaves}; do
if _exists ; then
if _exists; then
_delete_addresses
_down
fi

View File

@ -35,7 +35,7 @@ br2684ctl_pre_start() {
eval opts=\$br2684ctl_${IFVAR}
[ -z "${opts}" ] && return 0
if [ "${IFACE#nas[0-9]*}" = "${IFACE}" ] ; then
if [ "${IFACE#nas[0-9]*}" = "${IFACE}" ]; then
eerror "Interface must be called nas[0-9] for RFC 2684 Bridging"
return 1
fi
@ -45,7 +45,7 @@ br2684ctl_pre_start() {
eerror "The -b and -c options are not allowed for br2684ctl_${IVAR}"
return 1
;;
*" -a "*) ;;
*" -a "*);;
*)
eerror "-a option (VPI and VCI) is required in br2684ctl_${IFVAR}"
return 1

View File

@ -45,7 +45,7 @@ bridge_pre_start() {
[ -n "${ports}" ] && bridge_post_stop
(
if [ -z "${ports}" -a -n "${brif}" ] ; then
if [ -z "${ports}" -a -n "${brif}" ]; then
ports="${IFACE}"
IFACE="${brif}"
else
@ -100,7 +100,7 @@ bridge_pre_start() {
bridge_post_stop() {
local port= ports= delete=false extra=
if _is_bridge ; then
if _is_bridge; then
ebegin "Destroying bridge ${IFACE}"
_down
ports="$(brctl show 2>/dev/null | \

View File

@ -33,9 +33,9 @@ ccwgroup_pre_start() {
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ -z "${ccwgroup}" ] && return 0
if [ ! -d /sys/bus/ccwgroup ] ; then
if [ ! -d /sys/bus/ccwgroup ]; then
modprobe qeth
if [ ! -d /sys/bus/ccwgroup ] ; then
if [ ! -d /sys/bus/ccwgroup ]; then
eerror "ccwgroup support missing in kernel"
return 1
fi
@ -47,7 +47,7 @@ ccwgroup_pre_start() {
[ -z "${first}" ] && first=${x}
ccw="${ccw}${ccw:+,}${x}"
done
if [ -e /sys/devices/qeth/"${first}" ] ; then
if [ -e /sys/devices/qeth/"${first}" ]; then
echo "0" > /sys/devices/qeth/"${first}"/online
else
echo "${ccw}" > /sys/bus/ccwgroup/drivers/qeth/group
@ -65,8 +65,8 @@ ccwgroup_pre_stop() {
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
case "${diver}" in
*/bus/ccwgroup/*) ;;
*) return 0 ;;
*/bus/ccwgroup/*);;
*) return 0;;
esac
local device="$(readlink /sys/class/net/"${IFACE}"/device)"

View File

@ -83,24 +83,24 @@ clip_pre_start() {
eval clip=\$clip_${IFVAR}
[ -z "${clip}" ] && return 0
if [ ! -r /proc/net/atm/arp ] ; then
if [ ! -r /proc/net/atm/arp ]; then
modprobe clip && sleep 2
if [ ! -r /proc/net/atm/arp ] ; then
if [ ! -r /proc/net/atm/arp ]; then
eerror "You need first to enable kernel support for ATM CLIP"
return 1
fi
fi
local started_here=
if ! are_atmclip_svcs_running ; then
if ! are_atmclip_svcs_running; then
atmclip_svcs_start || return 1
started_here=1
fi
if ! _exists ; then
if ! _exists; then
ebegin "Creating CLIP interface ${IFACE}"
atmarp -c "${IFACE}"
if ! eend $? ; then
if ! eend $?; then
[ -z "${started_here}" ] && atmclip_svcs_stop
return 1
fi
@ -130,7 +130,7 @@ clip_post_start() {
# reporting problems. Also, when no defined VC can be established,
# we stop the ATM daemons.
local has_failures= i=
for i in ${clip} ; do
for i in ${clip}; do
local IFS=","
set -- ${i}
unset IFS
@ -139,14 +139,14 @@ clip_post_start() {
ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"
local nleftretries=10 emsg= ecode=
while [ ${nleftretries} -gt 0 ] ; do
while [ ${nleftretries} -gt 0 ]; do
nleftretries=$((${nleftretries} - 1))
emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)"
ecode=$? && break
sleep 2
done
if ! eend ${ecode} ; then
if ! eend ${ecode}; then
eerror "Creation failed for PVC ${ifvpivci}: ${emsg}"
has_failures=1
fi
@ -175,7 +175,7 @@ clip_pre_stop() {
eindent
{
read left && \
while read itf t encp idle ipaddr left ; do
while read itf t encp idle ipaddr left; do
if [ "${itf}" = "${IFACE}" ]; then
ebegin "Removing PVC to ${ipaddr}"
atmarp -d "${ipaddr}"
@ -197,15 +197,15 @@ clip_post_stop() {
local itf= left= hasothers=
{
read left && \
while read itf left ; do
if [ "${itf}" != "${IFACE}" ] ; then
while read itf left; do
if [ "${itf}" != "${IFACE}" ]; then
hasothers=1
break
fi
done
} < /proc/net/atm/arp
if [ -z "${hasothers}" ] ; then
if [ -z "${hasothers}" ]; then
atmclip_svcs_stop || return 1
fi
}

View File

@ -42,7 +42,7 @@ _exists() {
_ifindex() {
local line= i=-2
while read line ; do
while read line; do
i=$((${i} + 1))
[ ${i} -lt 1 ] && continue
case "${line}" in
@ -74,11 +74,11 @@ _get_mac_address() {
case "${mac}" in
00:00:00:00:00:00) ;;
44:44:44:44:44:44) ;;
FF:FF:FF:FF:FF:FF) ;;
"") ;;
*) echo "${mac}"; return 0 ;;
00:00:00:00:00:00);;
44:44:44:44:44:44);;
FF:FF:FF:FF:FF:FF);;
"");;
*) echo "${mac}"; return 0;;
esac
return 1
@ -102,7 +102,7 @@ _get_inet_addresses() {
local iface=${IFACE} i=0
local addrs="$(_get_inet_address)"
while true ; do
while true; do
local IFACE="${iface}:${i}"
_exists || break
local addr="$(_get_inet_address)"
@ -118,14 +118,14 @@ _cidr2netmask() {
local octets=$((${cidr} / 8))
local frac=$((${cidr} % 8))
while [ ${octets} -gt 0 ] ; do
while [ ${octets} -gt 0 ]; do
netmask="${netmask}.255"
octets=$((${octets} - 1))
done=$((${done} + 1))
done
if [ ${done} -lt 4 ] ; then
while [ ${i} -lt ${frac} ] ; do
if [ ${done} -lt 4 ]; then
while [ ${i} -lt ${frac} ]; do
sum=$((${sum} + ${cur}))
cur=$((${cur} / 2))
i=$((${i} + 1))
@ -133,7 +133,7 @@ _cidr2netmask() {
netmask="${netmask}.${sum}"
done=$((${done} + 1))
while [ ${done} -lt 4 ] ; do
while [ ${done} -lt 4 ]; do
netmask="${netmask}.0"
done=$((${done} + 1))
done
@ -143,7 +143,7 @@ _cidr2netmask() {
}
_add_address() {
if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ] ; then
if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
ifconfig "${IFACE}" "$@" 2>/dev/null
return 0
fi
@ -155,7 +155,7 @@ _add_address() {
# IPv4 is tricky - ifconfig requires an aliased device
# for multiple addresses
local iface="${IFACE}"
if LC_ALL=C ifconfig "${iface}" | grep -Eq "\<inet addr:.*" ; then
if LC_ALL=C ifconfig "${iface}" | grep -Eq "\<inet addr:.*"; then
# Get the last alias made for the interface and add 1 to it
i=$(ifconfig | sed '1!G;h;$!d' | grep -m 1 -o "^${iface}:[0-9]*" \
| sed -n -e 's/'"${iface}"'://p')
@ -172,17 +172,17 @@ _add_address() {
fi
local arg= cmd=
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
brd)
if [ "$2" = "+" ] ; then
if [ "$2" = "+" ]; then
shift
else
cmd="${cmd} broadcast"
fi
;;
peer) cmd="${cmd} pointtopoint";;
*) cmd="${cmd} $1" ;;
*) cmd="${cmd} $1";;
esac
shift
done
@ -193,15 +193,15 @@ _add_address() {
_add_route() {
local inet6=
if [ -n "${metric}" ] ; then
if [ -n "${metric}" ]; then
set -- "$@" metric ${metric}
fi
if [ $# -eq 3 ] ; then
if [ $# -eq 3 ]; then
set -- "$1" "$2" gw "$3"
elif [ "$3" = "via" ] ; then
elif [ "$3" = "via" ]; then
local one=$1 two=$2
shift ; shift; shift
shift; shift; shift
set -- "${one}" "${two}" gw "$@"
fi
@ -218,7 +218,7 @@ _add_route() {
_delete_addresses() {
# We don't remove addresses from aliases
case "${IFACE}" in
*:*) return 0 ;;
*:*) return 0;;
esac
einfo "Removing addresses"
@ -227,11 +227,11 @@ _delete_addresses() {
# iproute2 added addresses cause problems for ifconfig
# as we delete an address, a new one appears, so we have to
# keep polling
while true ; do
while true; do
local addr=$(_get_inet_address)
[ -z "${addr}" ] && break
if [ "${addr}" = "127.0.0.1/8" ] ; then
if [ "${addr}" = "127.0.0.1/8" ]; then
# Don't delete the loopback address
[ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] && break
fi
@ -242,7 +242,7 @@ _delete_addresses() {
# Remove IPv6 addresses
local addr=
for addr in $(LC_ALL=C ifconfig "${IFACE}" | \
sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p') ; do
sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p'); do
[ "${addr}" = "::1/128" -a "${IFACE}" = "lo" ] && continue
einfo "${addr}"
ifconfig "${IFACE}" inet6 del "${addr}"

View File

@ -35,22 +35,22 @@ ifplugd_depend() {
ifplugd_pre_start() {
local pidfile="/var/run/ifplugd.${IFACE}.pid" timeout= args=
# We don't start netplug if we're being called from the background
# We don't start ifplugd if we're being called from the background
yesno ${IN_BACKGROUND} && return 0
_exists || return 0
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
if ! _get_mac_address >/dev/null 2>/dev/null ; then
vewarn "netplug only works on interfaces with a valid MAC address"
if ! _get_mac_address >/dev/null 2>&1; then
vewarn "ifplugd only works on interfaces with a valid MAC address"
return 0
fi
# We don't work on bonded, bridges, tun/tap, vlan or wireless
for f in bond bridge tuntap vlan wireless ; do
if type "_is_${f}" >/dev/null 2>/dev/null ; then
if _is_${f} ; then
for f in bond bridge tuntap vlan wireless; do
if type "_is_${f}" >/dev/null 2>&1; then
if _is_${f}; then
veinfo "netplug does not work with" "${f}"
return 0
fi
@ -73,28 +73,28 @@ ifplugd_pre_start() {
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=-1
if [ ${timeout} -eq 0 ] ; then
ewarn "WARNING: infinite timeout set for" "${IFACE}" "to come up"
elif [ ${timeout} -lt 0 ] ; then
if [ ${timeout} -eq 0 ]; then
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
elif [ ${timeout} -lt 0 ]; then
einfo "Backgrounding ..."
exit 1
fi
veinfo "Waiting for" "${IFACE}" "to be marked as started"
veinfo "Waiting for ${IFACE} to be marked as started"
local i=0
while true ; do
if service_started "${SVCNAME}" ; then
while true; do
if service_started "${SVCNAME}"; then
_show_address
exit 0
fi
sleep 1
[ ${timeout} -eq 0 ]] && continue
[ ${timeout} -eq 0 ] && continue
i=$((${i} + 1))
[ ${i} -ge ${timeout} ] && break
done
eend 1 "Failed to configure" "${IFACE}" "in the background"
eend 1 "Failed to configure ${IFACE} in the background"
exit 1
}

View File

@ -32,7 +32,7 @@ ip6to4_depend() {
ip6to4_start() {
case " ${MODULES} " in
*" ifconfig "*)
if [ "${IFACE}" != "sit0" ] ; then
if [ "${IFACE}" != "sit0" ]; then
eerror "ip6to4 can only work on the sit0 interface using ifconfig"
eerror "emerge sys-apps/iproute2 to use other interfaces"
return 1
@ -41,7 +41,7 @@ ip6to4_start() {
local host= suffix= relay= addr= iface=${IFACE} new= localip=
eval host=\$link_${IFVAR}
if [ -z "${host}" ] ; then
if [ -z "${host}" ]; then
eerror "link_${IFVAR} not set"
return 1
fi
@ -52,24 +52,24 @@ ip6to4_start() {
IFACE=${host}
addrs=$(_get_inet_addresses)
IFACE=${iface}
if [ -z "${addrs}" ] ; then
if [ -z "${addrs}" ]; then
eerror "${host} is not configured with an IPv4 address"
return 1
fi
for addr in ${addrs} ; do
for addr in ${addrs}; do
# Strip the subnet
local ip="${addr%/*}" subnet="${addr#*/}"
# We don't work on private IPv4 addresses
case "${ip}" in
127.*) continue ;;
10.*) continue ;;
192.168.*) continue ;;
127.*) continue;;
10.*) continue;;
192.168.*) continue;;
172.*)
local i=16
while [ ${i} -lt 32 ] ; do
while [ ${i} -lt 32 ]; do
case "${ip}" in
172.${i}.*) break ;;
172.${i}.*) break;;
esac
i=$((${i} + 1))
done
@ -89,19 +89,19 @@ ip6to4_start() {
# Now apply our IPv6 address to our config
new="${new}${new:+ }${ip6}/16"
if [ -n "${localip}" ] ; then
if [ -n "${localip}" ]; then
localip="any"
else
localip="${ip}"
fi
done
if [ -z "${new}" ] ; then
if [ -z "${new}" ]; then
eerror "No global IPv4 addresses found on interface ${host}"
return 1
fi
if [ "${IFACE}" != "sit0" ] ; then
if [ "${IFACE}" != "sit0" ]; then
ebegin "Creating 6to4 tunnel on ${IFACE}"
_tunnel add "${IFACE}" mode sit ttl 255 remote any local "${localip}"
eend $? || return 1

View File

@ -37,8 +37,8 @@ ipppd_pre_start() {
# Check that we are a valid ippp interface
case "${IFACE}" in
ippp[0-9]*) ;;
*) return 0 ;;
ippp[0-9]*);;
*) return 0;;
esac
# Check that the interface exists

View File

@ -43,7 +43,7 @@ _exists() {
_ifindex() {
local line= i=-2
while read line ; do
while read line; do
i=$((${i} + 1))
[ ${i} -lt 1 ] && continue
case "${line}" in
@ -80,11 +80,11 @@ _get_mac_address() {
-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
case "${mac}" in
00:00:00:00:00:00) ;;
44:44:44:44:44:44) ;;
FF:FF:FF:FF:FF:FF) ;;
"") ;;
*) echo "${mac}"; return 0 ;;
00:00:00:00:00:00);;
44:44:44:44:44:44);;
FF:FF:FF:FF:FF:FF);;
"");;
*) echo "${mac}"; return 0;;
esac
return 1
@ -106,22 +106,22 @@ _get_inet_address() {
}
_add_address() {
if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ] ; then
if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
ip addr add "$@" dev "${IFACE}" 2>/dev/null
return 0
fi
# Convert an ifconfig line to iproute2
if [ "$2" = "netmask" ] ; then
if [ "$2" = "netmask" ]; then
local one="$1" three="$3"
shift ; shift ; shift
shift; shift; shift
set -- "${one}/$(_netmask2cidr "${three}")" "$@"
fi
#config=( "${config[@]//pointopoint/peer}" )
# Always scope lo addresses as host unless specified otherwise
if [ "${IFACE}" = "lo" ] ; then
if [ "${IFACE}" = "lo" ]; then
set -- "$@" "scope" "host"
fi
@ -129,9 +129,9 @@ _add_address() {
case "$1" in
*.*.*.*)
case "$@" in
*" brd "*) ;;
*" broadcast "*) ;;
*) set -- "$@" brd + ;;
*" brd "*);;
*" broadcast "*);;
*) set -- "$@" brd +;;
esac
;;
esac
@ -140,27 +140,27 @@ _add_address() {
}
_add_route() {
if [ $# -eq 3 ] ; then
if [ $# -eq 3 ]; then
set -- "$1" "$2" via "$3"
elif [ "$3" = "gw" ] ; then
elif [ "$3" = "gw" ]; then
local one=$1 two=$2
shift ; shift; shift
shift; shift; shift
set -- "${one}" "${two}" gw "$@"
fi
local cmd= have_metric=false
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
metric) cmd="${cmd} $1"; have_metric=true ;;
netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift ;;
-host|-net) ;;
-A) [ "$2" = "inet6" ] && shift ;;
*) cmd="${cmd} $1" ;;
metric) cmd="${cmd} $1"; have_metric=true;;
netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift;;
-host|-net);;
-A) [ "$2" = "inet6" ] && shift;;
*) cmd="${cmd} $1";;
esac
shift
done
if ! ${have_metric} && [ -n "${metric}" ] ; then
if ! ${have_metric} && [ -n "${metric}" ]; then
cmd="${cmd} metric ${metric}"
fi
@ -171,7 +171,7 @@ _add_route() {
_delete_addresses() {
ip addr flush dev "${IFACE}" scope global 2>/dev/null
ip addr flush dev "${IFACE}" scope site 2>/dev/null
if [ "${IFACE}" != "lo" ] ; then
if [ "${IFACE}" != "lo" ]; then
ip addr flush dev "${IFACE}" scope host 2>/dev/null
fi
return 0
@ -198,7 +198,7 @@ iproute2_pre_start() {
local tunnel=
eval tunnel=\$iptunnel_${IFVAR}
if [ -n "${tunnel}" ] ; then
if [ -n "${tunnel}" ]; then
# Set our base metric to 1000
metric=1000
@ -220,8 +220,8 @@ iproute2_post_start() {
iproute2_post_stop() {
# Don't delete sit0 as it's a special tunnel
if [ "${IFACE}" != "sit0" ] ; then
if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ] ; then
if [ "${IFACE}" != "sit0" ]; then
if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then
ebegin "Destroying tunnel ${IFACE}"
ip tunnel del "${IFACE}"
eend $?

View File

@ -36,7 +36,7 @@ iwconfig_get_wep_status() {
local mode= status="disabled"
# No easy way of doing this grep in bash regex :/
if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]" ; then
if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]"; then
status="enabled"
mode=$(LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p')
[ -n "${mode}" ] && mode=" - ${mode}"
@ -48,9 +48,9 @@ iwconfig_get_wep_status() {
_get_ssid() {
local i=5 ssid=
while [ ${i} -gt 0 ] ; do
while [ ${i} -gt 0 ]; do
ssid=$(iwgetid --raw "${IFACE}")
if [ -n "${ssid}" ] ; then
if [ -n "${ssid}" ]; then
echo "${ssid}"
return 0
fi
@ -64,11 +64,11 @@ _get_ssid() {
_get_ap_mac_address() {
local mac="$(iwgetid --raw --ap "${IFACE}")"
case "${mac}" in
"00:00:00:00:00:00") return 1 ;;
"44:44:44:44:44:44") return 1 ;;
"FF:00:00:00:00:00") return 1 ;;
"FF:FF:FF:FF:FF:FF") return 1 ;;
*) echo "${mac}" ;;
"00:00:00:00:00:00") return 1;;
"44:44:44:44:44:44") return 1;;
"FF:00:00:00:00:00") return 1;;
"FF:FF:FF:FF:FF:FF") return 1;;
*) echo "${mac}";;
esac
}
@ -117,13 +117,13 @@ iwconfig_get_wep_key() {
[ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')"
eval key=\$mac_key_${mac}
[ -z "${key}" ] && eval key=\$key_${SSIDVAR}
if [ -z "${key}" ] ; then
if [ -z "${key}" ]; then
echo "off"
else
set -- ${key}
local x= e=false
for x in "$@" ; do
if [ "${x}" = "enc" ] ; then
for x in "$@"; do
if [ "${x}" = "enc" ]; then
e=true
break
fi
@ -141,7 +141,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
if ! eval iwconfig "${IFACE}" "${conf}" ; then
if ! eval iwconfig "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following configuration commands"
ewarn " ${conf}"
fi
@ -152,7 +152,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
if ! eval iwpriv "${IFACE}" "${conf}" ; then
if ! eval iwpriv "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following private ioctls"
ewarn " ${conf}"
fi
@ -172,7 +172,7 @@ iwconfig_setup_specific() {
iwconfig_set_mode "${mode}"
# Now set the key
if ! eval iwconfig "${IFACE}" key "${key}" ; then
if ! eval iwconfig "${IFACE}" key "${key}"; then
if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
@ -180,7 +180,7 @@ iwconfig_setup_specific() {
fi
# Then set the SSID
if ! iwconfig "${IFACE}" essid "${SSID}" ; then
if ! iwconfig "${IFACE}" essid "${SSID}"; then
eerror "${IFACE} does not support setting SSID to \"${SSID}\""
return 1
fi
@ -188,7 +188,7 @@ iwconfig_setup_specific() {
eval channel=\$channel_${SSIDVAR}
[ -z "${channel}" ] && eval channel=\$channel_${IFVAR}
# We default the channel to 3
if ! iwconfig "${IFACE}" channel "${channel:-3}" ; then
if ! iwconfig "${IFACE}" channel "${channel:-3}"; then
ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\""
return 1
fi
@ -210,8 +210,8 @@ iwconfig_wait_for_association() {
while true; do
# Use sysfs if we can
if [ -e /sys/class/net/"${IFACE}"/carrier ] ; then
if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ] ; then
if [ -e /sys/class/net/"${IFACE}"/carrier ]; then
if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ]; then
# Double check we have an ssid. This is mainly for buggy
# prism54 drivers that always set their carrier on :/
[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
@ -220,10 +220,10 @@ iwconfig_wait_for_association() {
local atest=
eval atest=\$associate_test_${IFVAR}
atest=${atest:-mac}
if [ "${atest}" = "mac" -o "${atest}" = "all" ] ; then
if [ "${atest}" = "mac" -o "${atest}" = "all" ]; then
[ -n "$(_get_ap_mac_address)" ] && return 0
fi
if [ "${atest}" = "quality" -o "${atest}" = "all" ] ; then
if [ "${atest}" = "quality" -o "${atest}" = "all" ]; then
[ "$(sed -n -e 's/^.*'"${IFACE}"': *[0-9]* *\([0-9]*\).*/\1/p' \
/proc/net/wireless)" != "0" ] && return 0
fi
@ -249,17 +249,17 @@ iwconfig_associate() {
else
SSIDVAR=$(_shell_var "${SSID}")
key="$(iwconfig_get_wep_key "${mac}")"
if [ "${wep_required}" = "on" -a "${key}" = "off" ] ; then
if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
return 1
fi
if [ "${wep_required}" = "off" -a "${key}" != "off" ] ; then
if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then
key="off"
ewarn "\"${SSID}\" is not WEP enabled - ignoring setting"
fi
if ! eval iwconfig "${IFACE}" key "${key}" ; then
if [ "${key}" != "off" ] ; then
if ! eval iwconfig "${IFACE}" key "${key}"; then
if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
return 1
@ -268,16 +268,16 @@ iwconfig_associate() {
[ "${key}" != "off" ] && w="$(iwconfig_get_wep_status "${iface}")"
fi
if ! iwconfig "${IFACE}" essid "${SSID}" ; then
if [ "${SSID}" != "any" ] ; then
if ! iwconfig "${IFACE}" essid "${SSID}"; then
if [ "${SSID}" != "any" ]; then
ewarn "${IFACE} does not support setting SSID to \"${SSID}\""
fi
fi
# Only use channel or frequency
if [ -n "${chan}" ] ; then
if [ -n "${chan}" ]; then
iwconfig "${IFACE}" channel "${chan}"
elif [ -n "${freq}" ] ; then
elif [ -n "${freq}" ]; then
iwconfig "${IFACE}" freq "${freq}"
fi
[ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}"
@ -287,19 +287,19 @@ iwconfig_associate() {
ebegin "Connecting to \"${SSID}\" in ${mode} mode ${w}"
if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>/dev/null ; then
if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>&1; then
veinfo "Running preassociate function"
veindent
( preassociate )
local e=$?
veoutdent
if [ ${e} -eq 0 ] ; then
if [ ${e} -eq 0 ]; then
veend 1 "preassociate \"${SSID}\" on ${IFACE} failed"
return 1
fi
fi
if ! iwconfig_wait_for_association ; then
if ! iwconfig_wait_for_association; then
eend 1
return 1
fi
@ -313,7 +313,7 @@ iwconfig_associate() {
iwconfig_report
if type postassociate >/dev/null 2>/dev/null ; then
if type postassociate >/dev/null 2>&1; then
veinfo "Running postassociate function"
veindent
( postassociate )
@ -332,12 +332,12 @@ iwconfig_scan() {
eval x=\$sleep_scan_${IFVAR}
[ -n "${x}" ] && sleep "${x}"
while [ ${i} -lt 3 ] ; do
while [ ${i} -lt 3 ]; do
local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")"
# If this is the first pass and txpower as off and we have no results
# then we need to wait for at least 2 seconds whilst the interface
# does an initial scan.
if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ] ; then
if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ]; then
case "${scan}" in
"'${IFACE} "*"No scan results"*)
sleep 2
@ -349,12 +349,12 @@ iwconfig_scan() {
i=$((${i} + 1))
done
if [ -z "${scan}" ] ; then
if [ -z "${scan}" ]; then
ewarn "${iface} does not support scanning"
eoutdent
eval x=\$adhoc_ssid_${IFVAR}
[ -n "${x}" ] && return 0
if [ -n "${preferred_aps}" ] ; then
if [ -n "${preferred_aps}" ]; then
[ "${associate_order}" = "forcepreferred" ] || \
[ "${associate_order}" = "forcepreferredonly" ] && return 0
fi
@ -373,12 +373,12 @@ iwconfig_scan() {
APS=-1
eval set -- ${scan}
for line in "$@" ; do
for line in "$@"; do
case "${line}" in
*Address:*)
APS=$((${APS} + 1))
eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"
eval QUALITY_${APS}=0
eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
eva l QUALITY_${APS}=0
;;
*ESSID:*)
x=${line#*\"}
@ -387,8 +387,8 @@ iwconfig_scan() {
;;
*Mode:*)
x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
if [ "${x}" = "master" ] ; then
eval MODE_${APS}=\"managed\"
if [ "${x}" = "master" ]; then
eval MODE_${APS}=managed
else
eval MODE_${APS}=\$x
fi
@ -425,14 +425,14 @@ iwconfig_scan() {
# Sort based on quality
local i=0 k=1 a= b= x= t=
while [ ${i} -lt ${APS} ] ; do
while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
while [ ${k} -le ${APS} ] ; do
while [ ${k} -le ${APS} ]; do
eval a=\$QUALITY_${i}
[ -z "${a}" ] && break
eval b=\$QUALITY_${k}
if [ -n "${b}" -a "${a}" -lt "${b}" ] ; then
for x in MAC SSID CHAN QUALITY ENC ; do
if [ -n "${b}" -a "${a}" -lt "${b}" ]; then
for x in MAC SSID CHAN QUALITY ENC; do
eval t=\$${x}_${i}
eval ${x}_${i}=\$${x}_${k}
eval ${x}_${k}=\$t
@ -445,12 +445,12 @@ iwconfig_scan() {
# Strip any duplicates
local i=0 k=1 a= b=
while [ ${i} -lt ${APS} ] ; do
while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
while [ ${k} -le ${APS} ] ; do
while [ ${k} -le ${APS} ]; do
eval a=\$MAC_${i}
eval b=\$MAC_${k}
if [ "${a}" = "${b}" ] ; then
if [ "${a}" = "${b}" ]; then
eval a=\$QUALITY_${i}
eval b=\$QUALITY_${k}
local u=${k}
@ -465,9 +465,9 @@ iwconfig_scan() {
local i=0 e= m= s=
while [ ${i} -le ${APS} ] ; do
while [ ${i} -le ${APS} ]; do
eval x=\$MAC_${i}
if [ -z "${x}" ] ; then
if [ -z "${x}" ]; then
i=$((${i} + 1))
continue
fi
@ -476,12 +476,12 @@ iwconfig_scan() {
eval s=\$SSID_${i}
eval q=\$QUALITY_${i}
eval e=\$ENC_${i}
if [ -n "${e}" -a "${e}" != "off" ] ; then
if [ -n "${e}" -a "${e}" != "off" ]; then
e=", encrypted"
else
e=""
fi
if [ -z "${s}" ] ; then
if [ -z "${s}" ]; then
einfo "Found ${x}, ${m}${e}"
else
einfo "Found \"${s}\" at ${x}, ${m}${e}"
@ -489,7 +489,7 @@ iwconfig_scan() {
x="$(echo "${x}" | sed -e 's/://g')"
eval x=\$mac_ssid_${x}
if [ -n "${x}" ] ; then
if [ -n "${x}" ]; then
eval SSID_${i}=\$x
s=${x}
eindent
@ -500,7 +500,7 @@ iwconfig_scan() {
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
for x in "$@"; do
if [ "${x}" = "${s}" ] ; then
if [ "${x}" = "${s}" ]; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
@ -518,15 +518,15 @@ iwconfig_force_preferred() {
ewarn "Trying to force preferred in case they are hidden"
for ssid in "$@"; do
local found_AP=false i=0 e=
while [ ${i} -le ${APS} ] ; do
while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
if [ "${e}" = "${ssid}" ] ; then
if [ "${e}" = "${ssid}" ]; then
found_AP=true
break
fi
i=$((${i} + 1))
done
if ! ${found_AP} ; then
if ! ${found_AP}; then
SSID=${e}
iwconfig_associate && return 0
fi
@ -544,9 +544,9 @@ iwconfig_connect_preferred() {
for ssid in "$@"; do
unset IFS
i=0
while [ ${i} -le ${APS} ] ; do
while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
if [ "${e}" = "${ssid}" ] ; then
if [ "${e}" = "${ssid}" ]; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@ -566,19 +566,19 @@ iwconfig_connect_preferred() {
iwconfig_connect_not_preferred() {
local ssid= i=0 mode= mac= enc= freq= chan= pref=false
while [ ${i} -le ${APS} ] ; do
while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
if [ -n "${e}" ] ; then
if [ -n "${e}" ]; then
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
for ssid in "$@"; do
if [ "${e}" = "${ssid}" ] ; then
if [ "${e}" = "${ssid}" ]; then
pref=true
break
fi
done
if ! ${pref} ; then
if ! ${pref}; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@ -597,7 +597,7 @@ iwconfig_connect_not_preferred() {
iwconfig_defaults() {
local x=
for x in txpower rate rts frag ; do
for x in txpower rate rts frag; do
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
done
@ -617,12 +617,12 @@ iwconfig_configure() {
# Setup ad-hoc mode?
eval x=\$mode_${IFVAR}
x=${x:-managed}
if [ "${x}" = "ad-hoc" -o "${x}" = "master" ] ; then
if [ "${x}" = "ad-hoc" -o "${x}" = "master" ]; then
iwconfig_setup_specific "${x}"
return $?
fi
if [ "${x}" != "managed" -a "${x}" != "auto" ] ; then
if [ "${x}" != "managed" -a "${x}" != "auto" ]; then
eerror "Only managed, ad-hoc, master and auto modes are supported"
return 1
fi
@ -690,13 +690,13 @@ iwconfig_pre_start() {
save_options "SSID" ""
_exists || return 0
if ! _is_wireless ; then
if ! _is_wireless; then
veinfo "Wireless extensions not found for ${IFACE}"
return 0
fi
# Warn about old file - we want to punt it really
if [ -e /etc/conf.d/wireless ] ; then
if [ -e /etc/conf.d/wireless ]; then
ewarn "/etc/conf.d/wireless is deprecated"
ewarn "Please put all settings into /etc/conf.d/net"
. /etc/conf.d/wireless
@ -715,8 +715,8 @@ iwconfig_pre_start() {
# Check for rf_kill - only ipw supports this at present, but other
# cards may in the future.
if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ] ; then
if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ] ; then
if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ]; then
if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ]; then
eerror "Wireless radio has been killed for interface ${IFACE}"
return 1
fi
@ -736,7 +736,7 @@ iwconfig_pre_start() {
return 1
fi
if iwconfig_configure ; then
if iwconfig_configure; then
save_options "SSID" "${SSID}"
return 0
fi

View File

@ -45,15 +45,15 @@ netplugd_pre_start() {
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
if ! _get_mac_address >/dev/null 2>/dev/null ; then
if ! _get_mac_address >/dev/null 2>&1; then
vewarn "netplug only works on interfaces with a valid MAC address"
return 0
fi
# We don't work on bonded, bridges, tun/tap, vlan or wireless
for f in bond bridge tuntap vlan wireless ; do
if type "_is_${f}" >/dev/null 2>/dev/null ; then
if _is_${f} ; then
for f in bond bridge tuntap vlan wireless; do
if type "_is_${f}" >/dev/null 2>&1; then
if _is_${f}; then
veinfo "netplug does not work with" "${f}"
return 0
fi
@ -75,28 +75,28 @@ netplugd_pre_start() {
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=-1
if [ ${timeout} -eq 0 ] ; then
ewarn "WARNING: infinite timeout set for" "${IFACE}" "to come up"
elif [ ${timeout} -lt 0 ] ; then
if [ ${timeout} -eq 0 ]; then
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
elif [ ${timeout} -lt 0 ]; then
einfo "Backgrounding ..."
exit 1
fi
veinfo "Waiting for" "${IFACE}" "to be marked as started"
veinfo "Waiting for ${IFACE} to be marked as started"
local i=0
while true ; do
if service_started "${SVCNAME}" ; then
while true; do
if service_started "${SVCNAME}"; then
_show_address
exit 0
fi
sleep 1
[ ${timeout} -eq 0 ]] && continue
[ ${timeout} -eq 0 ] && continue
i=$((${i} + 1))
[ ${i} -ge ${timeout} ] && break
done
eend 1 "Failed to configure" "${IFACE}" "in the background"
eend 1 "Failed to configure ${IFACE} in the background"
exit 1
}

View File

@ -49,7 +49,7 @@ pppd_pre_start() {
local config=
eval config=\$config_${IFVAR}
# If no config for ppp then don't default to DHCP
if [ -z "${config}" ] ; then
if [ -z "${config}" ]; then
eval config_${IFVAR}=null
fi
return 0
@ -66,7 +66,7 @@ pppd_pre_start() {
case "${link}" in
/*)
if [ ! -e "${link}" ] ; then
if [ ! -e "${link}" ]; then
eerror "${link} does not exist"
eerror "Please verify hardware or kernel module (driver)"
return 1
@ -74,7 +74,7 @@ pppd_pre_start() {
;;
esac
if [ -z "${unit}" ] ; then
if [ -z "${unit}" ]; then
eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp"
return 1
fi
@ -91,12 +91,12 @@ pppd_pre_start() {
eerror "The option \"${i}\" is not allowed in pppd_${IFVAR}"
return 1
;;
defaultmetric) hasdefaultmetric=true ;;
mtu) hasmtu=true ;;
mru) hasmru=true ;;
maxfail) hasmaxfail=true ;;
persist) haspersist=true ;;
updetach) hasupdetach=true ;;
defaultmetric) hasdefaultmetric=true;;
mtu) hasmtu=true;;
mru) hasmru=true;;
maxfail) hasmaxfail=true;;
persist) haspersist=true;;
updetach) hasupdetach=true;;
esac
done
@ -106,17 +106,17 @@ pppd_pre_start() {
eval password=\$password_${IFVAR}
eval passwordset=\$\{password_${IFVAR}-x\}
if [ -n "${username}" ] \
&& [ -n "${password}" -o -z "${passwordset}" ] ; then
&& [ -n "${password}" -o -z "${passwordset}" ]; then
opts="${opts} plugin passwordfd.so passwordfd 0"
fi
if ! ${hasdefaultmetric} ; then
if ! ${hasdefaultmetric}; then
local m=
eval m=\$metric_${IFVAR}
[ -z "${m}" ] && m=$((${metric} + $(_ifindex)))
opts="${opts} defaultmetric ${m}"
fi
if [ -n "${mtu}" ] ; then
if [ -n "${mtu}" ]; then
${hasmtu} || opts="${opts} mtu ${mtu}"
${hasmru} || opts="${opts} mru ${mtu}"
fi
@ -129,7 +129,7 @@ pppd_pre_start() {
opts="linkname ${IFACE} ${opts}"
# Setup auth info
if [ -n "${username}" ] ; then
if [ -n "${username}" ]; then
opts="user '${username}' remotename ${IFACE} ${opts}"
fi
@ -160,15 +160,15 @@ pppd_pre_start() {
set -- ${i}
case "$1" in
passwordfd) continue;;
pppoa) shift; set -- "pppoatm" "$@" ;;
pppoe) shift; set -- "rp-pppoe" "$@" ;;
capi) shift; set -- "capiplugin" "$@" ;;
pppoa) shift; set -- "pppoatm" "$@";;
pppoe) shift; set -- "rp-pppoe" "$@";;
capi) shift; set -- "capiplugin" "$@";;
esac
case "$1" in
rp-pppoe) haspppoe=true ;;
pppoatm) haspppoa=true ;;
rp-pppoe) haspppoe=true;;
pppoatm) haspppoa=true;;
esac
if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ] ; then
if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ]; then
opts="${opts} connect true"
set -- "$@" "${link}"
fi
@ -180,30 +180,30 @@ pppd_pre_start() {
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
local insert_link_in_opts=1
if ${haspppoe} ; then
if [ ! -e /proc/net/pppoe ] ; then
if ${haspppoe}; then
if [ ! -e /proc/net/pppoe ]; then
# Load the PPPoE kernel module
if ! modprobe pppoe ; then
if ! modprobe pppoe; then
eerror "kernel does not support PPPoE"
return 1
fi
fi
# Ensure that the link exists and is up
( IFACE="${link}" ; _exists true && _up ) || return 1
( IFACE="${link}"; _exists true && _up ) || return 1
insert_link_in_opts=0
fi
if ${haspppoa} ; then
if [ ! -d /proc/net/atm ] ; then
if ${haspppoa}; then
if [ ! -d /proc/net/atm ]; then
# Load the PPPoA kernel module
if ! modprobe pppoatm ; then
if ! modprobe pppoatm; then
eerror "kernel does not support PPPoATM"
return 1
fi
fi
if [ "${link}" != "/dev/null" ] ; then
if [ "${link}" != "/dev/null" ]; then
insert_link_in_opts=0
else
ewarn "WARNING: An [itf.]vpi.vci ATM address was expected in link_${IFVAR}"
@ -215,7 +215,7 @@ pppd_pre_start() {
ebegin "Starting pppd in ${IFACE}"
mark_service_inactive "${SVCNAME}"
if [ -n "${username}" ] \
&& [ -n "${password}" -o -z "${passwordset}" ] ; then
&& [ -n "${password}" -o -z "${passwordset}" ]; then
printf "%s" "${password}" | \
eval start-stop-daemon --start --exec /usr/sbin/pppd \
--pidfile "/var/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
@ -224,12 +224,12 @@ pppd_pre_start() {
--pidfile "/var/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
fi
if ! eend $? "Failed to start PPP" ; then
if ! eend $? "Failed to start PPP"; then
mark_service_stopped "net.${IFACE}"
return 1
fi
if ${hasupdetach} ; then
if ${hasupdetach}; then
_show_address
else
einfo "Backgrounding ..."

View File

@ -39,11 +39,11 @@ pump_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
for opt in ${opts} ; do
for opt in ${opts}; do
case "${opt}" in
nodns) args="${args} --no-dns" ;;
nontp) args="${args} --no-ntp" ;;
nogateway) args="${args} --no-gateway" ;;
nodns) args="${args} --no-dns";;
nontp) args="${args} --no-ntp";;
nogateway) args="${args} --no-gateway";;
esac
done
@ -67,7 +67,7 @@ pump_stop() {
start-stop-daemon --quiet --test --stop --exec /sbin/pump || return 0
# Check that pump is running on the interface
if ! pump --status --interface "${IFACE}" >/dev/null 2>/dev/null ; then
if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then
return 0
fi

View File

@ -42,11 +42,11 @@ udhcpc_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
for opt in ${opts} ; do
for opt in ${opts}; do
case "${opt}" in
nodns) args="${args} --env PEER_DNS=no" ;;
nontp) args="${args} --env PEER_NTP=no" ;;
nogateway) args="${args} --env PEER_ROUTERS=no" ;;
nodns) args="${args} --env PEER_DNS=no";;
nontp) args="${args} --env PEER_NTP=no";;
nogateway) args="${args} --env PEER_ROUTERS=no";;
nosendhost) sendhost=false;
esac
done
@ -58,27 +58,27 @@ udhcpc_start() {
# Try and load the cache if it exists
if [ -f "${cachefile}" ]; then
case "$ {args} " in
*" --request="*|*" -r "*) ;;
*" --request="*|*" -r "*);;
*)
local x=$(cat "${cachefile}")
# Check for a valid ip
case "${x}" in
*.*.*.*) args="${args} --request=${x}" ;;
*.*.*.*) args="${args} --request=${x}";;
esac
;;
esac
fi
case " ${args} " in
*" --quit "*|*" -q "*) x="/sbin/udhcpc" ;;
*" --quit "*|*" -q "*) x="/sbin/udhcpc";;
*) x="start-stop-daemon --start --exec /sbin/udhcpc \
--pidfile \"${pidfile}\" --" ;;
--pidfile \"${pidfile}\" --";;
esac
case " ${args} " in
*" --hosname="*|*" -h "*|*" -H "*) ;;
*" --hosname="*|*" -h "*|*" -H "*);;
*)
if ${sendhost} ; then
if ${sendhost}; then
local hname="$(hostname)"
if [ "${hname}" != "(none)" ] && [ "${hname}" != "localhost" ]; then
args="${args} --hostname='${hname}'"
@ -112,7 +112,7 @@ udhcpc_stop() {
*" release "*)
start-stop-daemon --stop --quiet --oknodo --signal USR2 \
--exec /sbin/udhcpc --pidfile "${pidfile}"
if [ -f /var/cache/udhcpc-"${IFACE}".lease ] ; then
if [ -f /var/cache/udhcpc-"${IFACE}".lease ]; then
rm -f /var/cache/udhcpc-"${IFACE}".lease
fi
;;

View File

@ -43,9 +43,9 @@ _get_vlans() {
}
_check_vlan() {
if [ ! -d /proc/net/vlan ] ; then
if [ ! -d /proc/net/vlan ]; then
modprobe 8021q
if [ ! -d /proc/net/vlan ] ; then
if [ ! -d /proc/net/vlan ]; then
eerror "VLAN (802.1q) support is not present in this kernel"
return 1
fi
@ -64,7 +64,7 @@ vlan_pre_start() {
for v in ${vc}; do
unset IFS
case "${v}" in
set_name_type" "*) x=${v} ;;
set_name_type" "*) x=${v};;
*)
set -- ${v}
x="$1 ${IFACE}"
@ -92,7 +92,7 @@ vlan_post_start() {
for vlan in ${vlans}; do
einfo "Adding VLAN ${vlan} to ${IFACE}"
e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)"
if [ -n "${e}" ] ; then
if [ -n "${e}" ]; then
eend 1 "${e}"
continue
fi

View File

@ -40,19 +40,19 @@ dhclient_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
for opt in ${opts} ; do
for opt in ${opts}; do
case "${opt}" in
nodns) args="${args} -e PEER_DNS=no" ;;
nontp) args="${args} -e PEER_NTP=no" ;;
nogateway) args="${args} -e PEER_ROUTERS=no" ;;
nosendhost) sendhost=false ;;
nodns) args="${args} -e PEER_DNS=no";;
nontp) args="${args} -e PEER_NTP=no";;
nogateway) args="${args} -e PEER_ROUTERS=no";;
nosendhost) sendhost=false;;
esac
done
# Add our route metric
[ "${metric:-0}" != "0" ] && args="${args} -e IF_METRIC=${metric}"
if ${sendhost} ; then
if ${sendhost}; then
local hname="$(hostname)"
if [ "${hname}" != "(none)" -a "${hname}" != "localhost" ]; then
dhconf="${dhconf} interface \"${IFACE}\" {"
@ -76,14 +76,14 @@ dhclient_stop() {
[ ! -f "${pidfile}" ] && return 0
# Get our options
if [ -x /sbin/dhclient ] ; then
if [ -x /sbin/dhclient ]; then
eval opts=\$dhcp_${IFVAR}
[ -z "${opts}" ] && opts=${dhcp}
fi
ebegin "Stopping dhclient on ${IFACE}"
case " ${opts} " in
*" release "*) dhclient -q -r -pf "${pidfile}" "${IFACE}" ;;
*" release "*) dhclient -q -r -pf "${pidfile}" "${IFACE}";;
*)
start-stop-daemon --stop --quiet \
--exec /sbin/dhclient --pidfile "${pidfile}"

View File

@ -44,12 +44,12 @@ dhcpcd_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
for opt in ${opts} ; do
for opt in ${opts}; do
case "${opt}" in
nodns) args="${args} -R" ;;
nontp) args="${args} -N" ;;
nonis) args="${args} -Y" ;;
nogateway) args="${args} -G" ;;
nodns) args="${args} -R";;
nontp) args="${args} -N";;
nonis) args="${args} -Y";;
nogateway) args="${args} -G";;
nosendhost) args="${args} -h ''";
esac
done

View File

@ -51,7 +51,7 @@ macchanger_pre_start() {
[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])
# We don't need macchanger to change to a specific mac address
_set_mac_address "${mac}"
if eend "$?" ; then
if eend "$?"; then
mac=$(_get_mac_address)
eindent
einfo "changed to ${mac}"
@ -62,25 +62,25 @@ macchanger_pre_start() {
;;
# increment MAC address, default macchanger behavior
increment) opts="${opts}" ;;
increment) opts="${opts}";;
# randomize just the ending bytes
random-ending) opts="${opts} -e" ;;
random-ending) opts="${opts} -e";;
# keep the same kind of physical layer (eg fibre, copper)
random-samekind) opts="${opts} -a" ;;
random-samekind) opts="${opts} -a";;
# randomize to any known vendor of any physical layer type
random-anykind) opts="${opts} -A" ;;
random-anykind) opts="${opts} -A";;
# fully random bytes
random-full|random) opts="${opts} -r" ;;
random-full|random) opts="${opts} -r";;
# default case is just to pass on all the options
*) opts="${opts} ${mac}" ;;
*) opts="${opts} ${mac}";;
esac
if [ ! -x /sbin/macchanger ] ; then
if [ ! -x /sbin/macchanger ]; then
eerror "For changing MAC addresses, emerge net-analyzer/macchanger"
return 1
fi
@ -90,12 +90,12 @@ macchanger_pre_start() {
_up
# Sometimes the interface needs to be up ....
if [ -z "${mac}" ] ; then
if [ -z "${mac}" ]; then
mac=$(/sbin/macchanger ${opts} "${IFACE}" \
| sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
fi
if [ -z "${mac}" ] ; then
if [ -z "${mac}" ]; then
eend 1 "Failed to set MAC address"
return 1
fi

View File

@ -57,7 +57,7 @@ _system_dns() {
[ -n "${domain}" ] && buffer="${buffer}domain ${domain}\n"
[ -n "${search}" ] && buffer="${buffer}search ${search}\n"
for x in ${servers} ; do
for x in ${servers}; do
buffer="${buffer}nameserver ${x}\n"
done
@ -65,7 +65,7 @@ _system_dns() {
[ -n "${options}" ] && buffer="${buffer}options ${options}\n"
# Support resolvconf if we have it.
if [ -x /sbin/resolvconf ] ; then
if [ -x /sbin/resolvconf ]; then
printf "${buffer}" | resolvconf -a "${IFACE}"
else
printf "${buffer}" > /etc/resolv.conf
@ -84,7 +84,7 @@ _system_ntp() {
buffer="${buffer}restrict default noquery notrust nomodify\n"
buffer="${buffer}restrict 127.0.0.1\n"
for x in ${servers} ; do
for x in ${servers}; do
buffer="${buffer}restrict ${x} nomodify notrap noquery\n"
buffer="${buffer}server ${x}\n"
done
@ -109,17 +109,17 @@ _system_nis() {
buffer="# Generated by net-scripts for interface ${iface}\n"
if [ -n "${domain}" ] ; then
if [ -n "${domain}" ]; then
hostname -y "${domain}"
if [ -n "${servers}" ] ; then
for x in ${servers} ; do
if [ -n "${servers}" ]; then
for x in ${servers}; do
buffer="${buffer}domain ${domain} server ${x}\n"
done
else
buffer="${buffer}domain ${domain} broadcast\n"
fi
else
for x in ${servers} ; do
for x in ${servers}; do
buffer="${buffer}ypserver ${x}\n"
done
fi

View File

@ -39,13 +39,13 @@ wpa_supplicant_depend() {
# Only set these functions if not set already
# IE, prefer to use iwconfig
if ! type _get_ssid >/dev/null 2>/dev/null ; then
if ! type _get_ssid >/dev/null 2>&1; then
_get_ssid() {
local timeout=5 ssid=
while [ ${timeout} -gt 0 ] ;do
while [ ${timeout} -gt 0 ]; do
ssid=$(wpa_cli -i"${IFACE}" status | sed -n -e 's/^ssid=//p')
if [ -n "${ssid}" ] ; then
if [ -n "${ssid}" ]; then
echo "${ssid}"
return 0
fi
@ -74,14 +74,14 @@ wpa_supplicant_pre_start() {
eval opts=\$wpa_supplicant_${IFVAR}
case " ${opts} " in
*" -Dwired "*) ;;
*" -Dwired "*);;
*) _is_wireless || return 0;;
esac
# We don't configure wireless if we're being called from
# the background unless we're not currently running
if yesno ${IN_BACKGROUND}; then
if service_started_daemon "${SVCNAME}" /sbin/wpa_supplicant ; then
if service_started_daemon "${SVCNAME}" /sbin/wpa_supplicant; then
SSID=$(_get_ssid "${IFACE}")
SSIDVAR=$(_shell_var "${SSID}")
save_options "SSID" "${SSID}"
@ -91,19 +91,19 @@ wpa_supplicant_pre_start() {
fi
save_options "SSID" ""
ebegin "Starting wpa_supplicant on" "${IFVAR}"
ebegin "Starting wpa_supplicant on ${IFVAR}"
if [ -x /sbin/iwconfig ] ; then
if [ -x /sbin/iwconfig ]; then
local x=
for x in txpower rate rts frag ; do
for x in txpower rate rts frag; do
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
done
fi
cfgfile=${opts##* -c}
if [ -n "${cfgfile}" -a "${cfgfile}" != "${opts}" ] ; then
if [ -n "${cfgfile}" -a "${cfgfile}" != "${opts}" ]; then
case "${cfgfile}" in
" "*) cfgfile=${cfgfile# *} ;;
" "*) cfgfile=${cfgfile# *};;
esac
cfgfile=${cfgfile%% *}
else
@ -116,18 +116,18 @@ wpa_supplicant_pre_start() {
opts="${opts} -c ${cfgfile}"
fi
if [ ! -f ${cfgfile} ] ; then
if [ ! -f ${cfgfile} ]; then
eend 1 "/etc/wpa_supplicant/wpa_supplicant.conf not found"
return 1
fi
# Work out where the ctrl_interface dir is if it's not specified
local ctrl_dir=$(sed -n -e 's/[[:space:]]*#.*//g;s/[[:space:]]*$//g;s/^ctrl_interface=//p' "${cfgfile}")
if [ -z "${ctrl_dir}" ] ; then
if [ -z "${ctrl_dir}" ]; then
ctrl_dir=${opts##* -C}
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ] ; then
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then
case "${ctrl_dir}" in
" "*) ctrl_dir=${ctrl_dir# *} ;;
" "*) ctrl_dir=${ctrl_dir# *};;
esac
ctrl_dir=${ctrl_dir%% *}
else
@ -166,7 +166,7 @@ wpa_supplicant_pre_start() {
--pidfile "/var/run/wpa_cli-${IFACE}.pid" \
-- -a /etc/wpa_supplicant/wpa_cli.sh -p "${ctrl_dir}" -i "${IFACE}" \
-P "/var/run/wpa_cli-${IFACE}.pid" -B
if eend $? ; then
if eend $?; then
ebegin "Backgrounding ..."
exit 1
fi
@ -193,14 +193,14 @@ wpa_supplicant_post_stop() {
[ $? != 0 ] && return 0
local pidfile="/var/run/wpa_cli-${IFACE}.pid"
if [ -f ${pidfile} ] ; then
if [ -f ${pidfile} ]; then
ebegin "Stopping wpa_cli on ${IFACE}"
start-stop-daemon --stop --exec "${wpac}" --pidfile "${pidfile}"
eend $?
fi
pidfile="/var/run/wpa_supplicant-${IFACE}.pid"
if [ -f ${pidfile} ] ; then
if [ -f ${pidfile} ]; then
ebegin "Stopping wpa_supplicant on ${IFACE}"
start-stop-daemon --stop --exec "${wpas}" --pidfile "${pidfile}"
eend $?

View File

@ -5,13 +5,13 @@ BOOTDIR = $(LEVELDIR)/boot
DEFAULTDIR = $(LEVELDIR)/default
install:
if ! test -d "$(BOOTDIR)" ; then \
if ! test -d "$(BOOTDIR)"; then \
$(INSTALL) -d $(BOOTDIR) || exit $$?; \
for x in $(BOOT); do ln -snf ../../init.d/"$$x" $(BOOTDIR)/"$$x" || exit $$? ; done \
for x in $(BOOT); do ln -snf ../../init.d/"$$x" $(BOOTDIR)/"$$x" || exit $$?; done \
fi
if ! test -d "$(DEFAULTDIR)" ; then \
if ! test -d "$(DEFAULTDIR)"; then \
$(INSTALL) -d $(DEFAULTDIR) || exit $$?; \
for x in $(DEFAULT); do ln -snf ../../init.d/"$$x" $(DEFAULTDIR)/"$$x" || exit $$? ; done \
for x in $(DEFAULT); do ln -snf ../../init.d/"$$x" $(DEFAULTDIR)/"$$x" || exit $$?; done \
fi
all:

View File

@ -40,7 +40,7 @@ single_user() {
# FreeBSD-7 supports tmpfs now :)
mount_svcdir() {
local dotmp=false release=false
if [ -e "${RC_SVCDIR}"/deptree ] ; then
if [ -e "${RC_SVCDIR}"/deptree ]; then
dotmp=true
if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then
try mdconfig -a -t malloc -s 1m -u 1
@ -56,7 +56,7 @@ mount_svcdir() {
try newfs -b 4096 -i 1024 -n /dev/md0
try mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
fi
if ${dotmp} ; then
if ${dotmp}; then
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
try umount "${RC_LIBDIR}"/tmp

View File

@ -26,12 +26,12 @@
# Try and set a font and as early as we can
if [ -e /etc/runlevels/"${RC_DEFAULTLEVEL}"/consolefont \
-o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ] ; then
-o -e /etc/runlevels/"${RC_BOOTLEVEL}"/consolefont ]; then
termencoding="(K"
[ -e "${RC_LIBDIR}"/console/unicode ] && termencoding="%G"
CONSOLE="${CONSOLE:-/dev/console}"
printf "\033%s" "${termencoding}" >"${CONSOLE}" 2>/dev/null
if [ -r "${RC_LIBDIR}"/console/font -a -x /bin/setfont ] ; then
if [ -r "${RC_LIBDIR}"/console/font -a -x /bin/setfont ]; then
font="$(cat "${RC_LIBDIR}"/console/font)"
[ -c "${CONSOLE}" ] && cons="-C ${CONSOLE}"
setfont ${cons} "${RC_LIBDIR}"/console/"${font}" 2>/dev/null

View File

@ -146,7 +146,7 @@ if [ -e /proc/uptime ]; then
unset up
fi
if ${mountproc} ; then
if ${mountproc}; then
procfs="proc"
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
ebegin "Mounting ${procfs} at /proc"
@ -242,7 +242,7 @@ for x in "devpts /dev/pts 0755 ,gid=5,mode=0620" "tmpfs /dev/shm 1777 ,nodev"; d
if [ ! -d "$2" ] && \
[ "${m}" = "devfs" -o "${m}" = "udev" ]; then
mkdir -m "$3" -p "$2" >/dev/null 2>/dev/null || \
mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \
ewarn "Could not create $2!"
fi

View File

@ -8,9 +8,9 @@ include $(TOPDIR)/default.mk
install::
# Handle lib correctly
if test $(LIB) != "lib" ; then \
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(RC_LIB)/sh/functions.sh || exit $$? ; \
rm -f $(DESTDIR)/$(RC_LIB)/sh/functions.sh.bak ; \
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(RC_LIB)/sh/rc-functions.sh || exit $$? ; \
rm -f $(DESTDIR)/$(RC_LIB)/sh/rc-functions.sh.bak ; \
if test $(LIB) != "lib"; then \
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(RC_LIB)/sh/functions.sh || exit $$?; \
rm -f $(DESTDIR)/$(RC_LIB)/sh/functions.sh.bak; \
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(RC_LIB)/sh/rc-functions.sh || exit $$?; \
rm -f $(DESTDIR)/$(RC_LIB)/sh/rc-functions.sh.bak; \
fi

View File

@ -51,15 +51,15 @@ dolisting() {
local x= y= mylist= mypath="$*"
# Here we use file globbing instead of ls to save on forking
for x in ${mypath} ; do
for x in ${mypath}; do
[ ! -e "${x}" ] && continue
if [ -L "${x}" -o -f "${x}" ] ; then
if [ -L "${x}" -o -f "${x}" ]; then
mylist="${mylist} "${x}
elif [ -d "${x}" ] ; then
elif [ -d "${x}" ]; then
[ "${x%/}" != "${x}" ] && x=${x%/}
for y in "${x}"/* ; do
for y in "${x}"/*; do
[ -e "${y}" ] && mylist="${mylist} ${y}"
done
fi
@ -73,12 +73,12 @@ dolisting() {
# return 0 if any of the files/dirs are newer than
# the reference file
#
# EXAMPLE: if is_older_than a.out *.o ; then ...
# EXAMPLE: if is_older_than a.out *.o; then ...
is_older_than() {
local x= ref="$1"
shift
for x in "$@" ; do
for x in "$@"; do
[ -e "${x}" ] || continue
# We need to check the mtime if it's a directory too as the
# contents may have changed.
@ -91,10 +91,10 @@ is_older_than() {
uniqify() {
local result=
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case " ${result} " in
*" $1 "*) ;;
*) result="${result} $1" ;;
*" $1 "*);;
*) result="${result} $1";;
esac
shift
done
@ -138,17 +138,19 @@ KV_to_int() {
}
_sanitize_path() {
local IFS=":" p=
local IFS=":" p= path=
for p in ${PATH}; do
case "${p}" in
/lib/rc/sbin|/bin|/sbin|/usr/bin|/usr/sbin|/usr/local/bin|/usr/local/sbin) ;;
*) printf "%s" ":${p}";;
/lib/rc/sbin|/bin|/sbin|/usr/bin|/usr/sbin|/usr/local/bin|/usr/local/sbin);;
*) path="${path}:${p}";;
esac
done
echo "${path}"
}
# Allow our scripts to support zsh
if [ -n "${ZSH_VERSION}" ] ; then
if [ -n "${ZSH_VERSION}" ]; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
@ -161,7 +163,7 @@ fi
export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin$(_sanitize_path "${PATH}")"
unset _sanitize_path
for arg in "$@" ; do
for arg in "$@"; do
case "${arg}" in
--nocolor|--nocolour|-C)
export RC_NOCOLOR="yes"

View File

@ -51,7 +51,7 @@ depend() {
}
cd /etc/init.d
for SVCNAME in * ; do
for SVCNAME in *; do
[ -x "${SVCNAME}" ] || continue
# Only generate dependencies for runscripts
@ -65,14 +65,14 @@ for SVCNAME in * ; do
exec 3>&1 1>&2
rc_c=${SVCNAME%%.*}
if [ -n "${rc_c}" -a "${rc_c}" != "${SVCNAME}" ] ; then
if [ -n "${rc_c}" -a "${rc_c}" != "${SVCNAME}" ]; then
[ -e /etc/conf.d/"${rc_c}" ] && . /etc/conf.d/"${rc_c}"
fi
unset rc_c
[ -e /etc/conf.d/"${SVCNAME}" ] && . /etc/conf.d/"${SVCNAME}"
if . /etc/init.d/"${SVCNAME}" ; then
if . /etc/init.d/"${SVCNAME}"; then
echo "${SVCNAME}" >&3
depend

View File

@ -31,7 +31,7 @@ if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then
for x in ${RC_SVCDIR:-/lib/rcscripts/init.d}/*; do
[ -e "${x}" ] || continue
case ${x##*/} in
deptree|ksoftlevel|rc.log) ;;
deptree|ksoftlevel|rc.log);;
*) rm -rf "${x}";;
esac
done

View File

@ -31,13 +31,13 @@ try() {
local errstr
local retval=0
if [ -c /dev/null ] ; then
if [ -c /dev/null ]; then
errstr=$(eval $* 2>&1 >/dev/null)
else
errstr=$(eval $* 2>&1)
fi
retval=$?
if [ ${retval} -ne 0 ] ; then
if [ ${retval} -ne 0 ]; then
#splash "critical" &
eend 1
eerror "The \"$*\" command failed with error:"
@ -58,8 +58,8 @@ try() {
check_statedir() {
[ -z "$1" ] && return 0
if [ ! -d "$1" ] ; then
if ! mkdir -p "$1" &>/dev/null ; then
if [ ! -d "$1" ]; then
if ! mkdir -p "$1" &>/dev/null; then
#splash "critical" &
echo
eerror "To function properly, \"$1\" needs to exist."
@ -72,7 +72,7 @@ check_statedir() {
fi
mkdir -p "$1"
fi
if [ ! -d "$1" ] ; then
if [ ! -d "$1" ]; then
eerror "Please mount your root partition read/write, and execute:"
echo
eerror " # mkdir -p $1"

184
sh/net.sh
View File

@ -36,16 +36,18 @@ description="Configures network interfaces."
__IFS="
"
_shell_var() {
local rem=$1 c= r=
local rem=$1 c= r= var=
while [ -n "${rem}" ]; do
r=${rem#?}
c=${rem%${r}}
case "${c}" in
[a-zA-Z0-9]) printf "%c" "${c}";;
*) printf "_";;
[a-zA-Z0-9]);;
*) c=_;;
esac
var=${var}${c}
rem=${r}
done
echo ${var}
}
depend() {
@ -56,7 +58,7 @@ depend() {
after bootmisc
provide net
case "${IFACE}" in
lo|lo0) ;;
lo|lo0);;
*)
after net.lo net.lo0
local prov=
@ -77,7 +79,7 @@ depend() {
# Support bash arrays - sigh
_get_array() {
local _a=
if [ -n "${BASH}" ] ; then
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
eval "set -- \"\${$1[@]}\""
@ -97,7 +99,7 @@ _get_array() {
# Flatten bash arrays to simple strings
_flatten_array() {
if [ -n "${BASH}" ] ; then
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
eval "set -- \"\${$1[@]}\""
@ -128,9 +130,9 @@ _wait_for_carrier() {
yesno ${RC_PARALLEL} && efunc=einfo
${efunc} "Waiting for carrier (${timeout} seconds) "
while [ ${timeout} -gt 0 ] ; do
while [ ${timeout} -gt 0 ]; do
sleep 1
if _has_carrier ; then
if _has_carrier; then
[ "${efunc}" = "einfon" ] && echo
eend 0
return 0
@ -149,7 +151,7 @@ _netmask2cidr() {
local IFS=.
for i in $1; do
while [ ${i} != "0" ] ; do
while [ ${i} != "0" ]; do
len=$((${len} + ${i} % 2))
i=$((${i} >> 1))
done
@ -161,11 +163,11 @@ _netmask2cidr() {
_configure_variables() {
local var= v= t=
for var in ${_config_vars} ; do
for var in ${_config_vars}; do
local v=
for t in "$@" ; do
for t in "$@"; do
eval v=\$${var}_${t}
if [ -n "${v}" ] ; then
if [ -n "${v}" ]; then
eval ${var}_${IFVAR}=\$${var}_${t}
continue 2
fi
@ -180,11 +182,11 @@ _show_address() {
# Basically sorts our modules into order and saves the list
_gen_module_list() {
local x= f= force=$1
if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ] ; then
if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then
local update=false
for x in "${MODULESDIR}"/* ; do
for x in "${MODULESDIR}"/*; do
[ -e "${x}" ] || continue
if [ "${x}" -nt "${MODULESLIST}" ] ; then
if [ "${x}" -nt "${MODULESLIST}" ]; then
update=true
break
fi
@ -202,13 +204,13 @@ _gen_module_list() {
before() {
local mod=${MODULE}
local MODULE=
for MODULE in "$@" ; do
for MODULE in "$@"; do
after "${mod}"
done
}
program() {
if [ "$1" = "start" -o "$1" = "stop" ] ; then
if [ "$1" = "start" -o "$1" = "stop" ]; then
local s="$1"
shift
eval ${MODULE}_program_${s}="\"\${${MODULE}_program_${s}}\${${MODULE}_program_${s}:+ }$*\""
@ -220,12 +222,12 @@ _gen_module_list() {
provide() {
eval ${MODULE}_provide="\"\${${MODULE}_provide}\${${MODULE}_provide:+ }$*\""
local x
for x in $* ; do
for x in $*; do
eval ${x}_providedby="\"\${${MODULE}_providedby}\${${MODULE}_providedby:+ }${MODULE}\""
done
}
for MODULE in "${MODULESDIR}"/* ; do
for MODULE in "${MODULESDIR}"/*; do
sh -n "${MODULE}" || continue
. "${MODULE}" || continue
MODULE=${MODULE#${MODULESDIR}/}
@ -238,15 +240,15 @@ _gen_module_list() {
SORTED=
visit() {
case " ${VISITED} " in
*" $1 "*) return ;;
*" $1 "*) return;;
esac
VISITED="${VISITED} $1"
eval AFTER=\$${1}_after
for MODULE in ${AFTER} ; do
for MODULE in ${AFTER}; do
eval PROVIDEDBY=\$${MODULE}_providedby
if [ -n "${PROVIDEDBY}" ] ; then
for MODULE in ${PROVIDEDBY} ; do
if [ -n "${PROVIDEDBY}" ]; then
for MODULE in ${PROVIDEDBY}; do
visit "${MODULE}"
done
else
@ -255,7 +257,7 @@ _gen_module_list() {
done
eval PROVIDE=\$${1}_provide
for MODULE in ${PROVIDE} ; do
for MODULE in ${PROVIDE}; do
visit "${MODULE}"
done
@ -263,13 +265,13 @@ _gen_module_list() {
[ -z "${PROVIDEDBY}" ] && SORTED="${SORTED} $1"
}
for MODULE in ${MODULES} ; do
for MODULE in ${MODULES}; do
visit "${MODULE}"
done
printf "" > "${MODULESLIST}"
i=0
for MODULE in ${SORTED} ; do
for MODULE in ${SORTED}; do
eval PROGRAM=\$${MODULE}_program
eval PROGRAM_START=\$${MODULE}_program_start
eval PROGRAM_STOP=\$${MODULE}_program_stop
@ -292,56 +294,56 @@ _load_modules() {
# Ensure our list is up to date
_gen_module_list false
if ! . "${MODULESLIST}" ; then
if ! . "${MODULESLIST}"; then
_gen_module_list true
. "${MODULESLIST}"
fi
MODULES=
if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ] ; then
if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
eval mymods=\$modules_${IFVAR}
[ -z "${mymods}" ] && mymods=${modules}
fi
local i=-1 x= mod= f= provides=
while true ; do
while true; do
i=$((${i} + 1))
eval mod=\$module_${i}
[ -z "${mod}" ] && break
[ -e "${MODULESDIR}/${mod}.sh" ] || continue
eval set -- \$module_${i}_program
if [ -n "$1" ] ; then
if [ -n "$1" ]; then
x=
for x in "$@" ; do
for x in "$@"; do
[ -x "${x}" ] && break
done
[ -x "${x}" ] || continue
fi
if ${starting} ; then
if ${starting}; then
eval set -- \$module_${i}_program_start
else
eval set -- \$module_${i}_program_stop
fi
if [ -n "$1" ] ; then
if [ -n "$1" ]; then
x=
for x in "$@" ; do
for x in "$@"; do
[ -x "${x}" ] && break
done
[ -x "${x}" ] || continue
fi
eval provides=\$module_${i}_provide
if ${starting} ; then
if ${starting}; then
case " ${mymods} " in
*" !${mod} "*) continue ;;
*" !${provides} "*) [ -n "${provides}" ] && continue ;;
*" !${mod} "*) continue;;
*" !${provides} "*) [ -n "${provides}" ] && continue;;
esac
fi
MODULES="${MODULES}${MODULES:+ }${mod}"
# Now load and wrap our functions
if ! . "${MODULESDIR}/${mod}.sh" ; then
if ! . "${MODULESDIR}/${mod}.sh"; then
eend 1 "${SVCNAME}: error loading module \`${mod}'"
exit 1
fi
@ -350,8 +352,8 @@ _load_modules() {
# Wrap our provides
local f=
for f in pre_start start post_start ; do
eval "${provides}_${f}() { type ${mod}_${f} >/dev/null 2>/dev/null || return 0; ${mod}_${f} \"\$@\"; }"
for f in pre_start start post_start; do
eval "${provides}_${f}() { type ${mod}_${f} >/dev/null 2>&1 || return 0; ${mod}_${f} \"\$@\"; }"
done
eval module_${mod}_provides="${provides}"
@ -359,13 +361,13 @@ _load_modules() {
done
# Wrap our preferred modules
for mod in ${mymods} ; do
for mod in ${mymods}; do
case " ${MODULES} " in
*" ${mod} "*)
eval x=\$module_${mod}_provides
[ -z "${x}" ] && continue
for f in pre_start start post_start ; do
eval "${x}_${f}() { type ${mod}_${f} >/dev/null 2>/dev/null || return 0; ${mod}_${f} \"\$@\"; }"
for f in pre_start start post_start; do
eval "${x}_${f}() { type ${mod}_${f} >/dev/null 2>&1 || return 0; ${mod}_${f} \"\$@\"; }"
done
eval module_${x}_providedby="${mod}"
;;
@ -376,17 +378,17 @@ _load_modules() {
# Otherwise reverse the list
local LIST="${MODULES}" p=
MODULES=
if ${starting} ; then
for mod in ${LIST} ; do
if ${starting}; then
for mod in ${LIST}; do
eval x=\$module_${mod}_provides
if [ -n "${x}" ] ; then
if [ -n "${x}" ]; then
eval p=\$module_${x}_providedby
[ "${mod}" != "${p}" ] && continue
fi
MODULES="${MODULES}${MODULES:+ }${mod}"
done
else
for mod in ${LIST} ; do
for mod in ${LIST}; do
MODULES="${mod}${MODULES:+ }${MODULES}"
done
fi
@ -398,11 +400,11 @@ _load_config() {
local config="$(_get_array "config_${IFVAR}")"
local fallback="$(_get_array fallback_${IFVAR})"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
[ "${config}" != "null" ] && config="127.0.0.1/8
${config}"
else
if [ -z "${config}" ] ; then
if [ -z "${config}" ]; then
ewarn "No configuration specified; defaulting to DHCP"
config="dhcp"
fi
@ -438,7 +440,7 @@ start() {
einfo "Bringing up interface ${IFACE}"
eindent
if [ -z "${MODULES}" ] ; then
if [ -z "${MODULES}" ]; then
local MODULES=
_load_modules true
fi
@ -446,7 +448,7 @@ start() {
# We up the iface twice if we have a preup to ensure it's up if
# available in preup and afterwards incase the user inadvertently
# brings it down
if type preup >/dev/null 2>/dev/null ; then
if type preup >/dev/null 2>&1; then
_up 2>/dev/null
ebegin "Running preup"
eindent
@ -456,23 +458,23 @@ start() {
_up 2>/dev/null
for module in ${MODULES} ; do
if type "${module}_pre_start" >/dev/null 2>/dev/null ; then
if ! ${module}_pre_start ; then
for module in ${MODULES}; do
if type "${module}_pre_start" >/dev/null 2>&1; then
if ! ${module}_pre_start; then
eend 1
exit 1
fi
fi
done
if ! _exists ; then
if ! _exists; then
eerror "ERROR: interface ${IFACE} does not exist"
eerror "Ensure that you have loaded the correct kernel module for your hardware"
return 1
fi
if ! _wait_for_carrier ; then
if service_started devd ; then
if ! _wait_for_carrier; then
if service_started devd; then
ewarn "no carrier, but devd will start us when we have one"
mark_service_inactive "${SVCNAME}"
else
@ -485,13 +487,13 @@ start() {
_load_config
config_index=0
if [ -n "${our_metric}" ] ; then
if [ -n "${our_metric}" ]; then
metric=${our_metric}
elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ] ; then
elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
metric=$((${metric} + $(_ifindex)))
fi
while true ; do
while true; do
eval config=\$config_${config_index}
[ -z "${config}" ] && break
@ -500,26 +502,26 @@ start() {
eindent
case "$1" in
noop)
if [ -n "$(_get_inet_address)" ] ; then
if [ -n "$(_get_inet_address)" ]; then
oneworked=true
break
fi
;;
null) : ;;
[0-9]*|*:*) _add_address ${config} ;;
null) :;;
[0-9]*|*:*) _add_address ${config};;
*)
if type "${config}_start" >/dev/null 2>/dev/null ; then
if type "${config}_start" >/dev/null 2>&1; then
"${config}"_start
else
eerror "nothing provides \`${config}'"
fi
;;
esac
if eend $? ; then
if eend $?; then
oneworked=true
else
eval config=\$fallback_${config_index}
if [ -n "${config}" ] ; then
if [ -n "${config}" ]; then
eoutdent
ewarn "Trying fallback configuration ${config}"
eindent
@ -532,8 +534,8 @@ start() {
config_index=$((${config_index} + 1))
done
if ! ${oneworked} ; then
if type failup >/dev/null 2>/dev/null ; then
if ! ${oneworked}; then
if type failup >/dev/null 2>&1; then
ebegin "Running failup"
eindent
failup
@ -544,7 +546,7 @@ start() {
local hidefirstroute=false first=true
local routes="$(_get_array "routes_${IFVAR}")"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
if [ "${config_0}" != "null" ]; then
routes="127.0.0.0/8 via 127.0.0.1
${routes}"
@ -562,14 +564,14 @@ ${routes}"
ebegin ${cmd}
# Work out if we're a host or a net if not told
case ${cmd} in
*" -net "*|*" -host "*) ;;
*" netmask "*) cmd="-net ${cmd}" ;;
*.*.*.*/32) cmd="-host ${cmd}" ;;
*.*.*.*/*|0.0.0.0|default) cmd="-net ${cmd}" ;;
*) cmd="-host ${cmd}" ;;
*" -net "*|*" -host "*);;
*" netmask "*) cmd="-net ${cmd}";;
*.*.*.*/32) cmd="-host ${cmd}";;
*.*.*.*/*|0.0.0.0|default) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
if ${hidefirstroute} ; then
_add_route ${cmd} >/dev/null 2>/dev/null
if ${hidefirstroute}; then
_add_route ${cmd} >/dev/null 2>&1
hidefirstroute=false
else
_add_route ${cmd} >/dev/null
@ -579,16 +581,16 @@ ${routes}"
done
unset IFS
for module in ${MODULES} ; do
if type "${module}_post_start" >/dev/null 2>/dev/null ; then
if ! ${module}_post_start ; then
for module in ${MODULES}; do
if type "${module}_post_start" >/dev/null 2>&1; then
if ! ${module}_post_start; then
eend 1
exit 1
fi
fi
done
if type postup >/dev/null 2>/dev/null ; then
if type postup >/dev/null 2>&1; then
ebegin "Running postup"
eindent
postup
@ -605,12 +607,12 @@ stop() {
einfo "Bringing down interface ${IFACE}"
eindent
if [ -z "${MODULES}" ] ; then
if [ -z "${MODULES}" ]; then
local MODULES=
_load_modules false
fi
if type predown >/dev/null 2>/dev/null ; then
if type predown >/dev/null 2>&1; then
ebegin "Running predown"
eindent
predown || return 1
@ -622,28 +624,28 @@ stop() {
fi
fi
for module in ${MODULES} ; do
if type "${module}_pre_stop" >/dev/null 2>/dev/null ; then
if ! ${module}_pre_stop ; then
for module in ${MODULES}; do
if type "${module}_pre_stop" >/dev/null 2>&1; then
if ! ${module}_pre_stop; then
eend 1
exit 1
fi
fi
done
for module in ${MODULES} ; do
if type "${module}_stop" >/dev/null 2>/dev/null ; then
for module in ${MODULES}; do
if type "${module}_stop" >/dev/null 2>&1; then
${module}_stop
fi
done
# Only delete addresses for non PPP interfaces
if ! type is_ppp >/dev/null 2>/dev/null || ! is_ppp ; then
if ! type is_ppp >/dev/null 2>&1 || ! is_ppp; then
_delete_addresses "${IFACE}"
fi
for module in ${MODULES} ; do
if type "${module}_post_stop" >/dev/null 2>/dev/null ; then
for module in ${MODULES}; do
if type "${module}_post_stop" >/dev/null 2>&1; then
${module}_post_stop
fi
done
@ -654,7 +656,7 @@ stop() {
type resolvconf >/dev/null 2>&1 && resolvconf -d "${IFACE}"
if type postdown >/dev/null 2>/dev/null ; then
if type postdown >/dev/null 2>&1; then
ebegin "Running postdown"
eindent
postdown

View File

@ -63,7 +63,7 @@ is_net_fs() {
is_union_fs() {
[ ! -x /sbin/unionctl ] && return 1
unionctl "$1" --list >/dev/null 2>/dev/null
unionctl "$1" --list >/dev/null 2>&1
}
get_bootparam() {
@ -89,8 +89,8 @@ get_bootparam() {
# Add our sbin to $PATH
case "${PATH}" in
/lib/rc/sbin|/lib/rc/sbin:*) ;;
*) export PATH="/lib/rc/sbin:${PATH}" ;;
/lib/rc/sbin|/lib/rc/sbin:*);;
*) export PATH="/lib/rc/sbin:${PATH}";;
esac
# vim: set ts=4 :

View File

@ -34,19 +34,19 @@ else
fi
myscript=$1
if [ -z "${myscript}" ] ; then
if [ -z "${myscript}" ]; then
echo "Please execute an init.d script"
exit 1
fi
if [ -L "${myscript}" ] ; then
if [ -L "${myscript}" ]; then
SERVICE=$(readlink "${myscript}")
else
SERVICE=${myscript}
fi
SERVICE=${SERVICE##*/}
if [ "$2" = "help" ] ; then
if [ "$2" = "help" ]; then
BE_VERBOSE="yes"
NL="\n"
else
@ -55,7 +55,7 @@ else
fi
default_commands="describe help start status stop restart zap"
extra_commands="$(. "${myscript}" 2>/dev/null ; echo "${extra_commands:-${opts}}")"
extra_commands="$(. "${myscript}" 2>/dev/null; echo "${extra_commands:-${opts}}")"
printf "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} >
@ -121,7 +121,7 @@ printf " ${GREEN}${default_commands}${OFF}
fi
if [ -n "${extra_commands}" ] ; then
if [ -n "${extra_commands}" ]; then
printf "
${CYAN}Additional Options:${OFF}${NL}
${GREEN}${extra_commands}${OFF}

View File

@ -32,7 +32,7 @@ do_unmount() {
local cmd="$1" retval=0 retry=
local f_opts="-m -c" f_kill="-s " mnt=
if [ "${RC_UNAME}" = "Linux" ] ; then
if [ "${RC_UNAME}" = "Linux" ]; then
f_opts="-m"
f_kill="-"
fi
@ -57,24 +57,24 @@ do_unmount() {
esac
retry=3
while ! LC_ALL=C ${cmd} "${mnt}" 2>/dev/null ; do
while ! LC_ALL=C ${cmd} "${mnt}" 2>/dev/null; do
# Don't kill if it's us (/ and possibly /usr)
local pids="$(fuser ${f_opts} "${mnt}" 2>/dev/null)"
case " ${pids} " in
*" $$ "*) retry=0 ;;
" ") eend 1 "in use but fuser finds nothing"; retry=0 ;;
*" $$ "*) retry=0;;
" ") eend 1 "in use but fuser finds nothing"; retry=0;;
*)
local sig="KILL"
[ ${retry} -gt 0 ] && sig="TERM"
fuser ${f_kill}${sig} -k ${f_opts} "${mnt}" \
>/dev/null 2>/dev/null
>/dev/null 2>&1
sleep 1
retry=$((${retry} - 1))
;;
esac
# OK, try forcing things
if [ ${retry} -le 0 ] ; then
if [ ${retry} -le 0 ]; then
case "${cmd}" in
umount*)
LC_ALL=C ${cmd} -f "${mnt}" || retry=-999
@ -86,7 +86,7 @@ do_unmount() {
break
fi
done
if [ ${retry} -eq -999 ] ; then
if [ ${retry} -eq -999 ]; then
eend 1
retval=1
else

View File

@ -150,9 +150,9 @@ install:: $(TARGET)
for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
for x in $(RC_BINLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(RC_LIB)/bin/$$x; done
for x in $(RC_SBINLINKS); do ln -sf ../../../sbin/rc $(DESTDIR)/$(RC_LIB)/sbin/$$x; done
if test "$(PAM)" = "pam" ; then \
install -d $(DESTDIR)/etc/pam.d ; \
install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon ; \
if test "$(PAM)" = "pam"; then \
install -d $(DESTDIR)/etc/pam.d; \
install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon; \
fi
clean-links:

View File

@ -67,7 +67,7 @@
#include <security/pam_appl.h>
/* We are not supporting authentication conversations */
static struct pam_conv conv = { NULL, NULL} ;
static struct pam_conv conv = { NULL, NULL};
#endif
#include "builtins.h"

View File

@ -10,7 +10,7 @@ export LD_LIBRARY_PATH=${builddir}:${LD_LIBRARY_PATH}
export PATH=${builddir}:${PATH}
checkit() {
local base=$1 ; shift
local base=$1; shift
echo "$@" | tr ' ' '\n' > ${base}.out
diff -u ${base}.list ${base}.out
eend $?

View File

@ -62,7 +62,7 @@ done
if [ -n "${NS}" ]; then
DNS="# Generated by openvpn for interface ${dev}\n"
if [ -n "${SEARCH}" ] ; then
if [ -n "${SEARCH}" ]; then
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
else
DNS="${DNS}domain ${DOMAIN}\n"
@ -72,7 +72,7 @@ if [ -n "${NS}" ]; then
printf "${DNS}" | resolvconf -a "${dev}"
else
# Preserve the existing resolv.conf
if [ -e /etc/resolv.conf ] ; then
if [ -e /etc/resolv.conf ]; then
cp -p /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
fi
(umask 022; printf "${DNS}" > /etc/resolv.conf)