mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdev: add helper to convert from zdev config to rd.znet
Converts zdev configuration into the syntax of the dracut cmdline option rd.znet. Only znet options with non-default values are emitted. The result string occurs on stdout. It represents one device-specification for the given network interface name. Example: /lib/s390-tools/zdev-to-rd.znet persistent encbdf0 qeth,0.0.bdf0,0.0.bdf1,0.0.bdf2,layer2=1 User: https://github.com/rhinstaller/anaconda/pull/5250 to generate dracut cmdline entries such as rd.znet=qeth,0.0.bdf0,0.0.bdf1,0.0.bdf2,layer2=1 Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158 Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com> Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Steffen Maier <maier@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
bc4f455151
commit
73f51e45a8
@@ -106,13 +106,15 @@ libs = $(rootdir)/libap/libap.a \
|
||||
chzdev: $(chzdev_objects) $(libs)
|
||||
lszdev: $(lszdev_objects) $(libs)
|
||||
|
||||
install: chzdev zdev_id zdev-to-dasd_mod.dasd zdev-from-dasd_mod.dasd
|
||||
install: chzdev zdev_id zdev-to-dasd_mod.dasd zdev-from-dasd_mod.dasd \
|
||||
zdev-to-rd.znet
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c chzdev $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c lszdev $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c zdev_id $(DESTDIR)$(TOOLS_LIBDIR)
|
||||
$(INSTALL) -c zdev-to-dasd_mod.dasd $(DESTDIR)$(TOOLS_LIBDIR)
|
||||
$(INSTALL) -c -m 644 zdev-from-dasd_mod.dasd $(DESTDIR)$(TOOLS_LIBDIR)
|
||||
$(INSTALL) -c zdev-to-rd.znet $(DESTDIR)$(TOOLS_LIBDIR)
|
||||
ifeq ($(HAVE_DRACUT),1)
|
||||
$(INSTALL) -m 755 zdev-root-update.dracut \
|
||||
$(DESTDIR)$(TOOLS_LIBDIR)/zdev-root-update
|
||||
|
||||
49
zdev/src/zdev-to-rd.znet
Executable file
49
zdev/src/zdev-to-rd.znet
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright IBM Corp. 2023
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
# zdev-to-rd.znet
|
||||
# Converts zdev configuration into the syntax of the dracut cmdline option
|
||||
# rd.znet. Only znet options with non-default values are emitted. The
|
||||
# result string occurs on stdout. It represents one device-specification for
|
||||
# the given network interface name.
|
||||
#
|
||||
|
||||
function usage() {
|
||||
echo "usage: ${0##*/} active|persistent <network interface name>" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ $# -eq 2 ]] || usage
|
||||
|
||||
[[ "$1" == active ]] || [[ "$1" == persistent ]] || usage
|
||||
|
||||
_selection="--${1}"
|
||||
_ifname="$2"
|
||||
|
||||
while read -r _line; do
|
||||
case "$_line" in
|
||||
\#*) ;;
|
||||
\[*)
|
||||
SAVED_IFS="$IFS"
|
||||
IFS="${IFS}:]"
|
||||
# shellcheck disable=SC2086
|
||||
set -- $_line
|
||||
shift # skip "[..." prefix
|
||||
_nettype="$1"
|
||||
shift # skip nettype
|
||||
IFS="," # comma-separated subchannel list
|
||||
_subchannels="$*"
|
||||
IFS="$SAVED_IFS"
|
||||
;;
|
||||
"online=1") ;;
|
||||
zdev:early=*) ;;
|
||||
*)
|
||||
_attrs="${_attrs},${_line}"
|
||||
;;
|
||||
esac
|
||||
done < <(chzdev --by-interface "$_ifname" "$_selection" --export - --quiet)
|
||||
printf "%s,%s%s\n" "$_nettype" "$_subchannels" "$_attrs"
|
||||
Reference in New Issue
Block a user