summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/dhclient
blob: 87e9a927658dd3726e95dc24274140ccd885be1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
type dhclient &> /dev/null || return

dhclient_start() {
    local options pidfile="/run/dhclient-$Interface-$1.pid"
    case $1 in
      4) options=$DhclientOptions;;
      6) options=$DhclientOptions6;;
      *) return 1;;
    esac
    [[ $2 == "noaddr" ]] && options+=" -S"
    if ! do_debug do_readable dhclient -$1 -q -e "TIMEOUT=${TimeoutDHCP:-30}" -pf "$pidfile" $options "$Interface"; then
        report_error "DHCP IPv$1 lease attempt failed on interface '$Interface'"
        return 1
    fi
}

dhclient_stop() {
    local stop="-x" pidfile="/run/dhclient-$Interface-$1.pid"
    if [[ -f $pidfile ]]; then
        is_yes "${DHCPReleaseOnStop:-no}" && stop="-r"
        do_debug dhclient -$1 -q $stop "$Interface" -pf "$pidfile" > /dev/null
    fi
}


# vim: ft=sh ts=4 et sw=4: