/[baselayout]/trunk/net/dhcpcd.sh
Gentoo

Contents of /trunk/net/dhcpcd.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (11 years, 7 months ago) by uberlord
File MIME type: text/x-sh
File size: 1469 byte(s)
    Rewrite the core parts in C. We now provide librc so other programs can
    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.
1 # Copyright 2004-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 dhcpcd_depend() {
5 after interface
6 program start /sbin/dhcpcd
7 provide dhcp
8
9 # We prefer dhcpcd over the others
10 after dhclient pump udhcpc
11 }
12
13 _config_vars="$_config_vars dhcp dhcpcd"
14
15 dhcpcd_start() {
16 local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid"
17
18 _wait_for_carrier || return 1
19
20 eval args=\$dhcpcd_${IFVAR}
21
22 # Get our options
23 eval opts=\$dhcp_${IFVAR}
24 [ -z "${opts}" ] && opts=${dhcp}
25
26 # Map some generic options to dhcpcd
27 for opt in ${opts} ; do
28 case "${opt}" in
29 nodns) args="${args} -R" ;;
30 nontp) args="${args} -N" ;;
31 nonis) args="${args} -Y" ;;
32 nogateway) args="${args} -G" ;;
33 nosendhost) args="${args} -h ''";
34 esac
35 done
36
37 # Add our route metric
38 [ "${metric:-0}" != "0" ] && args="${args} -m ${metric}"
39
40 # Bring up DHCP for this interface
41 ebegin "Running dhcpcd"
42
43 eval /sbin/dhcpcd "${args}" "${IFACE}"
44 eend $? || return 1
45
46 _show_address
47 return 0
48 }
49
50 dhcpcd_stop() {
51 local pidfile="/var/run/dhcpcd-${IFACE}.pid" opts=
52 [ ! -f "${pidfile}" ] && return 0
53
54 # Get our options
55 if [ -x /sbin/dhcpcd ] ; then
56 eval opts=\$dhcp_${IFVAR}
57 [ -z "${opts}" ] && opts=${dhcp}
58 fi
59
60 ebegin "Stopping dhcpcd on ${IFACE}"
61 case " ${opts} " in
62 *" release "*) dhcpcd -k "${IFACE}" ;;
63 *)
64 start-stop-daemon --stop --quiet \
65 --exec /sbin/dhcpcd --pidfile "${pidfile}"
66 ;;
67 esac
68 eend $?
69 }
70
71 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20