-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for translating ifcfg kernel cmdline argument to ip #1957
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🙄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like debug output, not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not $conf_path here? it should be same, not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be there ... probably missing when modified...
fi | ||
;; | ||
*) | ||
echo "No supported option ${1}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write "Unsupported option ${1}"
echo "nameserver=${nameserver%% *}" >>$conf_path | ||
nameserver="${nameserver#* }" | ||
done | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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