On Fri, Apr 22, 2022 at 05:29:49PM +0200, Philipp Rudo wrote:
Hi Coiby,
On Sat, 2 Apr 2022 11:23:46 +0800 Coiby Xu coxu@redhat.com wrote:
NetworkManager defaults to use keyfile i.e. .nmconnnection file but still supports reading ifcfg-* file [1]. Make use of "nmcli connection clone --temporary" to automatically convert a ifcfg-* file to a .nmconnection file.
[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifc...
Signed-off-by: Coiby Xu coxu@redhat.com
dracut-module-setup.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3b6b1c3..91bebcb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -348,12 +348,30 @@ kdump_setup_ifname() {
kdump_copy_nmconnection_file() { local _dev _nmconnection_file_path _nmconnection_name _initrd_nmconnection_file_path
- local _cloned_nmconnection_file_path _uniq_name _old_uuid _old_name _uuid
s/uniq/unique/ ?
_dev="$1"
_nmconnection_file_path=${nmconnection_map[$_dev]} _nmconnection_name=$(basename "$_nmconnection_file_path") _initrd_nmconnection_file_path="/etc/NetworkManager/system-connections/$_nmconnection_name"
- inst "$_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- _old_uuid=$(nmcli --get-values connection.uuid c show "$_nmconnection_file_path")
- _old_name=$(nmcli --get-values connection.id c show "$_nmconnection_file_path")
- _uniq_name=$(cat /proc/sys/kernel/random/uuid)
- nmcli connection clone --temporary "$_nmconnection_file_path" "$_uniq_name"
- _uuid=$(nmcli --get-values connection.uuid c show "$_uniq_name")
- # change back connection.id for the sake of readibility
- nmcli connection modify --temporary "$_uuid" connection.id "$_old_name"
- _cloned_nmconnection_file_path=$(nmcli -g UUID,FILENAME connection show | sed -n "s/^${_uuid}://p")
I find it a little bit confusing that you are switching between the long --get-value and short -g as well as the long 'connection' and shot 'c'. I would prefer to have it consistent.
Thanks for catching this issue! I'll use the long version to make it consistent.
Thanks Philipp
- inst "$_cloned_nmconnection_file_path" "$_initrd_nmconnection_file_path"
- # change uuid back to old value in case it's refered by other connection
- # profile e.g. connection.master could be Interface name of the master
- # device or UUID of the master connection.
- sed -i -r "s/(^uuid=).*$/\1${_old_uuid}/g" "${initdir}/$_initrd_nmconnection_file_path"
- nmcli connection del "$_uuid"
}
kdump_setup_bridge() {