5af58b4514
query runlevels, services and state without using bash. We also provide libeinfo so other programs can easily use our informational functions. As such, we have dropped the requirement of using bash as the init script shell. We now use /bin/sh and have strived to make the scripts as portable as possible. Shells that work are bash and dash. busybox works provided you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you should disable find too. zsh and ksh do not work at this time. Networking support is currently being re-vamped also as it was heavily bash array based. As such, a new config format is available like so config_eth0="1.2.3.4/24 5.6.7.8/16" or like so config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'" We will still support the old bash array format provided that /bin/sh IS a link it bash. ChangeLog for baselayout-1 can be found in our SVN repo.
94 lines
2.1 KiB
Bash
94 lines
2.1 KiB
Bash
# Copyright 2005-2007 Gentoo Foundation
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
_config_vars="$_config_vars plug_timeout"
|
|
|
|
netplugd_depend() {
|
|
program start /sbin/netplugd
|
|
after macnet rename
|
|
before interface
|
|
provide plug
|
|
|
|
# Prefer us to ifplugd
|
|
after ifplugd
|
|
}
|
|
|
|
netplugd_pre_start() {
|
|
local pidfile="/var/run/netplugd-${IFACE}.pid" timeout=
|
|
|
|
# We don't start netplug if we're being called from the background
|
|
${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"
|
|
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
|
|
veinfo "netplug does not work with" "${f}"
|
|
return 0
|
|
fi
|
|
fi
|
|
done
|
|
|
|
ebegin "Starting netplug on" "${IFACE}"
|
|
|
|
# Mark the us as inactive so netplug can restart us
|
|
mark_service_inactive "${SVCNAME}"
|
|
|
|
# Start netplug
|
|
start-stop-daemon --start --exec /sbin/netplugd \
|
|
--pidfile "${pidfile}" \
|
|
-- -i "${IFACE}" -P -p "${pidfile}" -c /dev/null
|
|
eend "$?" || return 1
|
|
|
|
eindent
|
|
|
|
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
|
|
einfo "Backgrounding ..."
|
|
exit 1
|
|
fi
|
|
|
|
veinfo "Waiting for" "${IFACE}" "to be marked as started"
|
|
|
|
local i=0
|
|
while true ; do
|
|
if service_started "${SVCNAME}" ; then
|
|
_show_address
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
[ ${timeout} -eq 0 ]] && continue
|
|
i=$((${i} + 1))
|
|
[ ${i} -ge ${timeout} ] && break
|
|
done
|
|
|
|
eend 1 "Failed to configure" "${IFACE}" "in the background"
|
|
exit 1
|
|
}
|
|
|
|
netplugd_stop() {
|
|
${IN_BACKGROUND} && return 0
|
|
|
|
local pidfile="/var/run/netplugd-${IFACE}.pid"
|
|
[ ! -e "${pidfile}" ] && return 0
|
|
|
|
ebegin "Stopping netplug on" "${IFACE}"
|
|
start-stop-daemon --stop --quiet --exec /sbin/netplugd \
|
|
--pidfile "${pidfile}"
|
|
eend $?
|
|
}
|
|
|
|
# vim: set ts=4 :
|