Add support for translating ifcfg kernel cmdline argument to ip#1957
Add support for translating ifcfg kernel cmdline argument to ip#1957teclator merged 4 commits intoinfo_paramfrom
Conversation
dgdavid
left a comment
There was a problem hiding this comment.
I'm approving it because reading the code it makes sense, but be aware I do not know too much bash scripting.
Also, I trust in the fact that it has been manually tested. Which make me thing that in a no far future we could evaluate the introduction of a shell testing tool like https://github.com/shellspec/shellspec or similar. Just saying 🙄
dgdavid
left a comment
There was a problem hiding this comment.
Question: Does it deserves an entry in some changelog file?
Probably yes, I will add it, we probably should add an unique entry as this PR is against Jozef branch. |
Ah, right. I overlooked that small detail :) Thanks! |
| done | ||
|
|
||
| if [[ $# -eq 0 ]]; then | ||
| echo "IFCFG 0 options given, must be wrong" |
There was a problem hiding this comment.
the text looks a bit strange..I would write something like "no parameters given to ifcfg option. Skipping" ( or what action happen after return 1
There was a problem hiding this comment.
was adde mainly for debugging we could even skip it.. or modify as suggested
| if str_starts "$1" "dhcp"; then | ||
| autoconf="$1" | ||
| if [ "$autoconf" = "dhcp4" ]; then | ||
| echo "AUTOCONF" |
There was a problem hiding this comment.
this looks like debug output, not?
There was a problem hiding this comment.
yep, look like a leftover
| case $autoconf in | ||
| "dhcp" | "dhcp6") | ||
| if [ "$interface" = "*" ]; then | ||
| echo "ip=${1}" >>"/etc/cmdline.d/40-agama-network.conf" |
There was a problem hiding this comment.
why not $conf_path here? it should be same, not?
There was a problem hiding this comment.
should be there ... probably missing when modified...
| fi | ||
| ;; | ||
| *) | ||
| echo "No supported option ${1}" |
There was a problem hiding this comment.
I would write "Unsupported option ${1}"
| echo "nameserver=${nameserver%% *}" >>$conf_path | ||
| nameserver="${nameserver#* }" | ||
| done | ||
| fi |
There was a problem hiding this comment.
I have to say that without automatic testing I would be very scared to touch this file to avoid breaking anything.
e3a5cb2 to
69d7351
Compare
Prepare for releasing Agama 12: * #1858 * #1887 * #1890 * #1892 * #1893 * #1894 * #1896 * #1898 * #1899 * #1900 * #1901 * #1906 * #1908 * #1909 * #1910 * #1911 * #1912 * #1914 * #1915 * #1917 * #1919 * #1920 * #1921 * #1922 * #1923 * #1924 * #1926 * #1927 * #1928 * #1929 * #1930 * #1931 * #1932 * #1933 * #1934 * #1935 * #1936 * #1937 * #1938 * #1939 * #1942 * #1943 * #1945 * #1948 * #1949 * #1952 * #1953 * #1954 * #1955 * #1957 * #1958 * #1959 * #1961 * #1963 * #1964 * #1967 * #1969 * #1970 * #1971 * #1972 * #1973 * #1974 * #1975 * #1976 * #1977 * #1979 * #1980 * #1981 * #1982 * #1984 * #1986 * #1987 * #1988 * #1990 * #1991 * #1992 * #1993 * #1995 * #1996 * #1997 * #1999 * #2000 * #2001 * #2002 * #2003 * #2004 * #2005 * #2006 * #2007 * #2008 * #2009 * #2010 * #2011 * #2012 * #2013 * #2014 * #2015 * #2016 * #2017 * #2019 * #2021 * #2022 * #2025 * #2027 * #2029 * #2030 * #2031 * #2033 * #2034 * #2035 * #2036 * #2037 * #2038 * #2039 * #2040 * #2045 * #2046 * #2050 * #2053 * #2054 * #2055 * #2056 * #2058 * #2060 * #2061 * #2062 * #2063 * #2064 * #2066 * #2067 * #2068 * #2069 * #2070 * #2071 * #2072 * #2073 * #2075 * #2076 * #2080 * #2082 * #2083
Problem
As there is no linuxrc in Agama we wanted to explore the possibility of translating linuxrc network-related boot arguments into the dracut equivalent (which is the supported and recommended method for the new installation media).
Solution
A basic translation of the ifcfg boot argument has being implemented as a prof of concept but as the nm-initrd-generator parses de cmdline as a cmdline hook it is too early for doing some kind of checks about the devices present in the system and trying to match against the device name and the mac address therefore any kind of pattern except the '*' wildcard.
Supported examples
ifcfg=*=dhcp
ip=dhcp
ifcfg=eth0=dhcp
ip=eth0:dhcp
ifcfg=eth0.10=192.168.0.100/24,192.168.0.1
vlan=eth0.10:eth0 ip=192.168.0.100::192.168.0.1:24::eth0.10
ifcfg="eth0=192.168.0.33/24 10.0.0.100/24,192.168.0.1,192.168.0.1 10.0.0.1,suse.de"
ip=192.168.0.33::192.168.0.1:24::eth0 nameserver=192.168.0.1 nameserver=10.0.0.1 ip=10.0.0.100:::24::eth0
The parser is also added as a cmdline hook, we explored the possibility to call it as a initqueue/settle hook, in that case we could try to call the nm_generate_connections function directly passing it the getcmdline result. At that point we can check the devices present in /sys/class/net/ doing some filtering based in the name or mac address but for example the try function requires to run the configuration in order to check if the interface was configured or not for continuing trying... for that kind of support we might need to add it to NetworkManager and the nm-initrd-generator.
Testing