summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/dhcpcd
blob: 5dba10a721f870895e74acb322c4c8a5256e4eed (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
30
31
32
33
type dhcpcd &> /dev/null || return

dhcpcd_start() {
    local options
    case $1 in
      4) options="$DhcpcdOptions -L";;
      6) options=$DhcpcdOptions6;;
      *) return 1;;
    esac
    if [[ $2 == "noaddr" ]]; then
        report_error "Using 'dhcpcd' for configuration without address assignment is unsupported"
        return 1
    fi
    # If using own dns, tell dhcpcd to NOT replace resolv.conf
    [[ $DNS ]] && options+=" -C resolv.conf"
    do_debug do_readable dhcpcd -$1 -q -t "${TimeoutDHCP:-30}" $options "$Interface"
    # The first array value of PIPESTATUS is the exit status of dhcpcd
    if (( PIPESTATUS != 0 )); then
        report_error "DHCP IPv$1 lease attempt failed on interface '$Interface'"
        return 1
    fi
}

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


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