summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/dhcpcd
blob: c729c081fa101dfd52905e6c44d9467fdda90c42 (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
27
28
29
type dhcpcd &> /dev/null || return

dhcpcd_start() {
    if [[ $1 != "4" ]]; then
        report_error "Using 'dhcpcd' for IPv6 is currently not possible in netctl"
        return 1
    fi
    rm -f "/run/dhcpcd-$Interface".{pid,cache}
    # If using own dns, tell dhcpcd to NOT replace resolv.conf
    [[ $DNS ]] && DhcpcdOptions+=" -C resolv.conf"
    do_debug dhcpcd -4qL -t "${TimeoutDHCP:-30}" $DhcpcdOptions "$Interface" |& report_debug "$(cat)"
    # The first array value of PIPESTATUS is the exit status of dhcpcd
    if (( PIPESTATUS != 0 )); then
        report_error "DHCP IP lease attempt failed on interface '$Interface'"
        return 1
    fi
    chmod 644 "/run/dhcpcd-$Interface.pid"
}

dhcpcd_stop() {
    local stop="-x"
    if [[ -f "/run/dhcpcd-$Interface.pid" ]]; then
        is_yes "${DHCPReleaseOnStop:-no}" && stop="-k"
        do_debug dhcpcd -q $stop "$Interface" > /dev/null
    fi
}


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