2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
2011-06-29 19:46:31 -04:00
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2008-01-11 15:08:57 +00:00
|
|
|
dhcpcd_depend()
|
|
|
|
{
|
2007-04-05 11:18:42 +00:00
|
|
|
after interface
|
2008-01-10 23:23:39 +00:00
|
|
|
program start dhcpcd
|
2007-04-05 11:18:42 +00:00
|
|
|
provide dhcp
|
|
|
|
|
|
|
|
# We prefer dhcpcd over the others
|
|
|
|
after dhclient pump udhcpc
|
|
|
|
}
|
|
|
|
|
|
|
|
_config_vars="$_config_vars dhcp dhcpcd"
|
|
|
|
|
2008-01-11 15:08:57 +00:00
|
|
|
dhcpcd_start()
|
|
|
|
{
|
2008-05-10 12:29:49 +00:00
|
|
|
local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true
|
2007-04-05 11:18:42 +00:00
|
|
|
eval args=\$dhcpcd_${IFVAR}
|
2008-08-19 22:30:59 +00:00
|
|
|
[ -z "${args}" ] && args=${dhcpcd}
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# Get our options
|
|
|
|
eval opts=\$dhcp_${IFVAR}
|
|
|
|
[ -z "${opts}" ] && opts=${dhcp}
|
|
|
|
|
2008-05-10 12:29:49 +00:00
|
|
|
case "$(dhcpcd --version)" in
|
|
|
|
"dhcpcd "[123]*) new=false;;
|
|
|
|
esac
|
|
|
|
|
2007-04-05 11:18:42 +00:00
|
|
|
# Map some generic options to dhcpcd
|
2007-11-28 15:45:03 +00:00
|
|
|
for opt in ${opts}; do
|
2007-04-05 11:18:42 +00:00
|
|
|
case "${opt}" in
|
2008-05-10 12:29:49 +00:00
|
|
|
nodns)
|
|
|
|
if ${new}; then
|
2008-05-25 22:57:44 +00:00
|
|
|
args="${args} -C resolv.conf"
|
2008-05-10 12:29:49 +00:00
|
|
|
else
|
|
|
|
args="${args} -R"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
nontp)
|
|
|
|
if ${new}; then
|
2008-05-25 22:57:44 +00:00
|
|
|
args="${args} -C ntp.conf"
|
2008-05-10 12:29:49 +00:00
|
|
|
else
|
|
|
|
args="${args} -N"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
nonis)
|
|
|
|
if ${new}; then
|
2008-05-25 22:57:44 +00:00
|
|
|
args="${args} -C yp.conf"
|
2008-05-10 12:29:49 +00:00
|
|
|
else
|
|
|
|
args="${args} -Y"
|
|
|
|
fi
|
|
|
|
;;
|
2007-11-28 15:45:03 +00:00
|
|
|
nogateway) args="${args} -G";;
|
2007-04-05 11:18:42 +00:00
|
|
|
nosendhost) args="${args} -h ''";
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2009-11-25 02:07:22 +00:00
|
|
|
# Add our route metric if not given
|
|
|
|
case " $args " in
|
|
|
|
*" -m "*) ;;
|
|
|
|
*) [ "${metric:-0}" != 0 ] && args="$args -m $metric";;
|
|
|
|
esac
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# Bring up DHCP for this interface
|
|
|
|
ebegin "Running dhcpcd"
|
|
|
|
|
2007-11-21 15:39:19 +00:00
|
|
|
eval dhcpcd "${args}" "${IFACE}"
|
2007-04-05 11:18:42 +00:00
|
|
|
eend $? || return 1
|
|
|
|
|
|
|
|
_show_address
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2008-01-11 15:08:57 +00:00
|
|
|
dhcpcd_stop()
|
|
|
|
{
|
2007-11-21 15:39:19 +00:00
|
|
|
local pidfile="/var/run/dhcpcd-${IFACE}.pid" opts= sig=SIGTERM
|
2007-04-05 11:18:42 +00:00
|
|
|
[ ! -f "${pidfile}" ] && return 0
|
|
|
|
|
|
|
|
ebegin "Stopping dhcpcd on ${IFACE}"
|
2007-11-21 15:39:19 +00:00
|
|
|
eval opts=\$dhcp_${IFVAR}
|
|
|
|
[ -z "${opts}" ] && opts=${dhcp}
|
2007-04-05 11:18:42 +00:00
|
|
|
case " ${opts} " in
|
2007-11-21 15:39:19 +00:00
|
|
|
*" release "*) sig=SIGHUP;;
|
2007-04-05 11:18:42 +00:00
|
|
|
esac
|
2008-01-11 15:08:57 +00:00
|
|
|
start-stop-daemon --stop --quiet --signal ${sig} --pidfile "${pidfile}"
|
2007-04-05 11:18:42 +00:00
|
|
|
eend $?
|
|
|
|
}
|