]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-50-MULTINIC/client-init.sh
test/MULTINIC: correctly note activated devices when using network-manager
[thirdparty/dracut.git] / test / TEST-50-MULTINIC / client-init.sh
CommitLineData
a71f1b49 1#!/bin/sh
781f1971
HH
2getcmdline() {
3 while read -r _line || [ -n "$_line" ]; do
b039b20e 4 printf "%s" "$_line"
781f1971
HH
5 done </proc/cmdline;
6}
7
8_dogetarg() {
9 local _o _val _doecho
10 unset _val
11 unset _o
12 unset _doecho
13 CMDLINE=$(getcmdline)
14
15 for _o in $CMDLINE; do
16 if [ "${_o%%=*}" = "${1%%=*}" ]; then
17 if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
18 # if $1 has a "=<value>", we want the exact match
19 if [ "$_o" = "$1" ]; then
20 _val="1";
21 unset _doecho
22 fi
23 continue
24 fi
25
26 if [ "${_o#*=}" = "$_o" ]; then
27 # if cmdline argument has no "=<value>", we assume "=1"
28 _val="1";
29 unset _doecho
30 continue
31 fi
32
33 _val="${_o#*=}"
34 _doecho=1
35 fi
36 done
37 if [ -n "$_val" ]; then
38 [ "x$_doecho" != "x" ] && echo "$_val";
39 return 0;
40 fi
41 return 1;
42}
43
44getarg() {
45 local _deprecated _newoption
46 while [ $# -gt 0 ]; do
47 case $1 in
48 -d) _deprecated=1; shift;;
49 -y) if _dogetarg $2 >/dev/null; then
50 if [ "$_deprecated" = "1" ]; then
51 [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated."
52 fi
53 echo 1
54 return 0
55 fi
56 _deprecated=0
57 shift 2;;
58 -n) if _dogetarg $2 >/dev/null; then
59 echo 0;
60 if [ "$_deprecated" = "1" ]; then
61 [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated."
62 fi
63 return 1
64 fi
65 _deprecated=0
66 shift 2;;
67 *) if [ -z "$_newoption" ]; then
68 _newoption="$1"
69 fi
70 if _dogetarg $1; then
71 if [ "$_deprecated" = "1" ]; then
72 [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated."
73 fi
74 return 0;
75 fi
76 _deprecated=0
77 shift;;
78 esac
79 done
80 return 1
81}
82
83getargbool() {
84 local _b
85 unset _b
86 local _default
87 _default="$1"; shift
88 _b=$(getarg "$@")
89 [ $? -ne 0 -a -z "$_b" ] && _b="$_default"
90 if [ -n "$_b" ]; then
91 [ $_b = "0" ] && return 1
92 [ $_b = "no" ] && return 1
93 [ $_b = "off" ] && return 1
94 fi
95 return 0
96}
97
67ab4f77
HH
98exec >/dev/console 2>&1
99set -x
387bf82e 100export PATH=/sbin:/bin:/usr/sbin:/usr/bin
9cf339ad
CF
101strstr() { [ "${1##*"$2"*}" != "$1" ]; }
102strglobin() { [ -n "$1" -a -z "${1##*$2*}" ]; }
6d58fa27 103CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
a71f1b49
PS
104export TERM=linux
105export PS1='initramfs-test:\w\$ '
106stty sane
107echo "made it to the rootfs! Powering down."
393fb1ac
LR
108for i in /sys/class/net/*/
109do
110 # booting with network-manager module
111 state=/run/NetworkManager/devices/$(cat $i/ifindex)
112 grep -q connection-uuid= $state 2>/dev/null || continue
113 i=${i##*/}
114 ip link show $i |grep -q master && continue
115 IFACES+="$i "
116done
a94cd56d 117for i in /run/initramfs/net.*.did-setup; do
393fb1ac 118 # booting with network-legacy module
06853123
HH
119 [ -f "$i" ] || continue
120 strglobin "$i" ":*:*:*:*:" && continue
121 i=${i%.did-setup}
122 IFACES+="${i##*/net.} "
a94cd56d 123done
84bc1929
HH
124{
125 echo "OK"
126 echo "$IFACES"
127} > /dev/sda
a94cd56d 128
781f1971 129getargbool 0 rd.shell && sh -i
a71f1b49 130poweroff -f