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