modules.d: get rid of "tr"
[platform/upstream/dracut.git] / modules.d / 40network / parse-ifname.sh
1 #!/bin/sh
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 #
5 # Format:
6 #       ifname=<interface>:<mac>
7 #
8 # Note letters in the macaddress must be lowercase!
9 #
10 # Examples:
11 # ifname=eth0:4a:3f:4c:04:f8:d7
12 #
13 # Note when using ifname= to get persistent interface names, you must specify
14 # an ifname= argument for each interface used in an ip= or fcoe= argument
15
16 # check if there are any ifname parameters
17 if ! getarg ifname= >/dev/null ; then
18     return
19 fi
20
21 parse_ifname_opts() {
22     local IFS=:
23     set $1
24
25     case $# in
26         7)
27             ifname_if=$1
28             # udev requires MAC addresses to be lower case
29             ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
30             ;;
31         *)
32             die "Invalid arguments for ifname="
33             ;;
34     esac
35 }
36
37 # Check ifname= lines
38 for p in $(getargs ifname=); do
39     parse_ifname_opts $p
40 done