/[baselayout]/trunk/net.Linux/ifplugd.sh
Gentoo

Contents of /trunk/net.Linux/ifplugd.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (7 years ago) by uberlord
File MIME type: text/x-sh
File size: 2178 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 2005-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 _config_vars="$_config_vars plug_timeout"
5
6 ifplugd_depend() {
7 program start /usr/sbin/ifplugd
8 after macnet rename
9 before interface
10 provide plug
11 }
12
13 ifplugd_pre_start() {
14 local pidfile="/var/run/ifplugd.${IFACE}.pid" timeout= args=
15
16 # We don't start netplug if we're being called from the background
17 ${IN_BACKGROUND} && return 0
18
19 _exists || return 0
20
21 # We need a valid MAC address
22 # It's a basic test to ensure it's not a virtual interface
23 if ! _get_mac_address >/dev/null 2>/dev/null ; then
24 vewarn "netplug only works on interfaces with a valid MAC address"
25 return 0
26 fi
27
28 # We don't work on bonded, bridges, tun/tap, vlan or wireless
29 for f in bond bridge tuntap vlan wireless ; do
30 if type "_is_${f}" >/dev/null 2>/dev/null ; then
31 if _is_${f} ; then
32 veinfo "netplug does not work with" "${f}"
33 return 0
34 fi
35 fi
36 done
37
38 ebegin "Starting ifplugd on" "${IFACE}"
39
40 eval args=\$ifplugd_${IFVAR}
41
42 # Mark the us as inactive so netplug can restart us
43 mark_service_inactive "${SVCNAME}"
44
45 # Start ifplugd
46 eval start-stop-daemon --start --exec /usr/sbin/ifplugd \
47 --pidfile "${pidfile}" -- "${args}" --iface="${IFACE}"
48 eend "$?" || return 1
49
50 eindent
51
52 eval timeout=\$plug_timeout_${IFVAR}
53 [ -z "${timeout}" ] && timeout=-1
54 if [ ${timeout} -eq 0 ] ; then
55 ewarn "WARNING: infinite timeout set for" "${IFACE}" "to come up"
56 elif [ ${timeout} -lt 0 ] ; then
57 einfo "Backgrounding ..."
58 exit 1
59 fi
60
61 veinfo "Waiting for" "${IFACE}" "to be marked as started"
62
63 local i=0
64 while true ; do
65 if service_started "${SVCNAME}" ; then
66 _show_address
67 exit 0
68 fi
69 sleep 1
70 [ ${timeout} -eq 0 ]] && continue
71 i=$((${i} + 1))
72 [ ${i} -ge ${timeout} ] && break
73 done
74
75 eend 1 "Failed to configure" "${IFACE}" "in the background"
76 exit 1
77 }
78
79 ifplugd_stop() {
80 ${IN_BACKGROUND} && return 0
81
82 local pidfile="/var/run/ifplugd.${IFACE}.pid"
83 [ ! -e "${pidfile}" ] && return 0
84
85 ebegin "Stopping ifplugd on" "${IFACE}"
86 start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \
87 --pidfile "${pidfile}" --signal QUIT
88 eend $?
89 }
90
91 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20