summaryrefslogtreecommitdiffstats
path: root/dracut/parse-anaconda-net.sh
blob: 0b8e6bf44757483a3a1dc0143f6eeb57c31c14ca (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# parse-anaconda-net.sh - parse old deprecated anaconda network setup args

net_conf=/etc/cmdline.d/75-anaconda-network-options.conf

check_depr_arg "dns" "nameserver=%s"

mac_to_bootif() {
    local bootif=${1}
    local IFS=':'
    bootif=$(for i in ${bootif} ; do echo -n $i-; done)
    bootif=${bootif%-}
    bootif="01-$bootif"
    echo $bootif
}

# handle ksdevice (tell us which device to use for ip= stuff later)
export ksdevice=""
ksdev_val=$(getarg ksdevice=)
if [ -n "$ksdev_val" ]; then
    case "$ksdev_val" in
        link)
            warn "'ksdevice=link' does nothing (it's the default behavior)"
        ;;
        ibft)
            warn "'ksdevice=ibft' is deprecated. Using 'ip=ibft' instead."
            echo "ip=ibft" > $net_conf
        ;;
        bootif)
            warn "'ksdevice=bootif' does nothing (BOOTIF is used by default if present)"
        ;;
        ??:??:??:??:??:??)

            BOOTIF=$(getarg 'BOOTIF=')
            if [ -n "$BOOTIF" ] ; then
                warn "'ksdevice=<MAC>' is deprecated. Supplied BOOTIF takes precedence."
            else
                bootif=$(mac_to_bootif "$ksdev_val")
                warn "'ksdevice=<MAC>' is deprecated. Using BOOTIF=$bootif instead."
                echo "BOOTIF=$bootif" > $net_conf
            fi
        ;;
        *) ksdevice="$ksdev_val" ;;
    esac
fi
[ -n "$ksdevice" ] && echo "bootdev=$ksdevice" >> $net_conf

ip="$(getarg ip=)"
ipv6="$(getarg ipv6=)"

# XXX NOTE: dracut doesn't do ipv4 + ipv6 (mostly because dhclient doesn't)
if [ -n "$ipv6" ] && [ -n "$ip" ]; then
    warn "'ipv6=$ipv6': can't use ipv6= and ip= simultaneously!"
    warn "defaulting to 'ip=$ip', since 'ipv6=' is deprecated."
    warn "if you need ipv6, use ip=dhcp6|auto6|[v6-address]."
elif [ -n "$ipv6" ]; then # just ipv6
    case "$ipv6" in
        auto) check_depr_arg "ipv6=auto"  "ip=${ksdevice:+$ksdevice:}auto6" ;;
        dhcp) check_depr_arg "ipv6=dhcp"  "ip=${ksdevice:+$ksdevice:}dhcp6" ;;
        *)    check_depr_arg "ipv6="      "ip=${ksdevice:+$ksdevice:}[%s]" ;;
    esac
fi

[ -n "$ip$ipv6$ksdev_val" ] && set_neednet

# set dhcp vendor class
dhcpclass=$(getarg inst.dhcpclass) || dhcpclass="anaconda-$(uname -srm)"
echo "send vendor-class-identifier \"$dhcpclass\";" >> /etc/dhclient.conf

unset CMDLINE