- add scripts for migration from legacy device configs to zdev
Add scripts that will do a migration from the legacy Fedora/RHEL persistent device config files to the modern zdev style. Also update the %files section with Fedora/RHEL specific content to match the current state. Related: RHEL-145841
This commit is contained in:
parent
5ef1e14c14
commit
ab1e590aeb
48
dasdconfmigrate.sh
Normal file
48
dasdconfmigrate.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright IBM Corp. 2023
|
||||
|
||||
# This is just a wrapper to migrate old /etc/dasd.conf to the new
|
||||
# consolidated persistent configuration of s390 devices with chzdev.
|
||||
|
||||
CONFIG=/etc/dasd.conf
|
||||
PATH=/sbin:/bin
|
||||
export PATH
|
||||
|
||||
DATE=$(date --iso-8601=seconds)
|
||||
PREFIX="${CONFIG}.${DATE}.migrated-to-chzdev"
|
||||
|
||||
if [ -f "$CONFIG" ]; then
|
||||
# show migration output to users and log it into file
|
||||
exec > >(tee "${PREFIX}.log") 2>&1
|
||||
sed 'y/ABCDEF/abcdef/' < $CONFIG | while read -r line; do
|
||||
case $line in
|
||||
\#*) ;;
|
||||
*)
|
||||
[ -z "$line" ] && continue
|
||||
# shellcheck disable=SC2086
|
||||
set -- $line
|
||||
|
||||
chzdev --enable --active --persistent dasd "$@" --yes --no-root-update --force --no-settle
|
||||
case $? in
|
||||
0)
|
||||
# If device exists and could be actively enabled,
|
||||
# chzdev could infer the actual dasd device type; done.
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
# Configure persistently only to allow migration of
|
||||
# configuration for devices that currently do not exist.
|
||||
# Chzdev cannot infer the actual dasd device type for an
|
||||
# absent device. Therefore, create duplicate configurations
|
||||
# for both dasd-eckd and dasd-fba, so either one of them
|
||||
# can enable such device when it appears.
|
||||
chzdev --enable --persistent dasd-eckd "$@" --yes --no-root-update --force --no-settle
|
||||
chzdev --enable --persistent dasd-fba "$@" --yes --no-root-update --force --no-settle
|
||||
;;
|
||||
esac
|
||||
done
|
||||
mv "$CONFIG" "$CONFIG"."$DATE".migrated-to-chzdev
|
||||
echo "dasdconfmigrate.sh: Information: Your persistent dasd device configuration file $CONFIG was migrated to the new consolidated mechanism. From now on, please use lszdev and chzdev from s390utils instead. To finally complete the migration, please run: kdumpctl rebuild; systemctl restart kdump; dracut -f; zipl"
|
||||
fi
|
||||
@ -37,6 +37,9 @@ Source21: https://fedorapeople.org/cgit/sharkcz/public_git/utils.git/tree/
|
||||
Source23: 20-zipl-kernel.install
|
||||
Source24: 52-zipl-rescue.install
|
||||
Source25: 91-zipl.install
|
||||
Source26: https://fedorapeople.org/cgit/sharkcz/public_git/utils.git/tree/zfcpconfmigrate.sh
|
||||
Source27: https://fedorapeople.org/cgit/sharkcz/public_git/utils.git/tree/dasdconfmigrate.sh
|
||||
Source28: https://fedorapeople.org/cgit/sharkcz/public_git/utils.git/tree/znetconfmigrate.sh
|
||||
|
||||
%if %{with signzipl}
|
||||
%define pesign_name redhatsecureboot302
|
||||
@ -203,6 +206,9 @@ mv %{buildroot}%{_datadir}/s390-tools/netboot/mk-s390image.1 %{buildroot}%{_mand
|
||||
mkdir -p %{buildroot}{/boot,%{_udevrulesdir},%{_sysconfdir}/{profile.d,sysconfig},%{_prefix}/lib/modules-load.d}
|
||||
install -p -m 644 zipl/boot/tape0.bin %{buildroot}/boot/tape0
|
||||
install -p -m 755 %{SOURCE5} %{buildroot}%{_sbindir}
|
||||
install -p -m 755 %{SOURCE26} %{buildroot}%{_sbindir}
|
||||
install -p -m 755 %{SOURCE27} %{buildroot}%{_sbindir}
|
||||
install -p -m 755 %{SOURCE28} %{buildroot}%{_sbindir}
|
||||
install -p -m 755 %{SOURCE13} %{buildroot}%{_sbindir}
|
||||
install -p -m 755 %{SOURCE21} %{buildroot}%{_sbindir}
|
||||
install -p -m 644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/56-zfcp.rules
|
||||
@ -377,36 +383,39 @@ This package provides minimal set of tools needed to system to boot.
|
||||
%{_mandir}/man8/vmcp.8*
|
||||
%{_mandir}/man8/zipl.8*
|
||||
%{_mandir}/man8/zipl-editenv.8*
|
||||
%{_udevrulesdir}/40-z90crypt.rules
|
||||
%{_udevrulesdir}/59-dasd.rules
|
||||
%{_udevrulesdir}/59-virtio-blk.rules
|
||||
%{_udevrulesdir}/60-readahead.rules
|
||||
%{_udevrulesdir}/81-dpm.rules
|
||||
%{_udevrulesdir}/90-cpi.rules
|
||||
%{_prefix}/lib/modules-load.d/s390-pkey.conf
|
||||
# rule provided by systemd-udev
|
||||
%exclude %{_udevrulesdir}/80-hotplug-cpu.rules
|
||||
|
||||
# Additional Fedora/RHEL specific stuff
|
||||
%ghost %config(noreplace) %{_sysconfdir}/dasd.conf
|
||||
%ghost %config(noreplace) %{_sysconfdir}/zfcp.conf
|
||||
%{_sbindir}/dasdconf.sh
|
||||
%{_sbindir}/normalize_dasd_arg
|
||||
%{_sbindir}/dasdconfmigrate.sh
|
||||
%{_sbindir}/zfcpconf.sh
|
||||
%{_sbindir}/zfcpconfmigrate.sh
|
||||
%{_sbindir}/znetconfmigrate.sh
|
||||
%{_sbindir}/device_cio_free
|
||||
%{_sbindir}/dasd_cio_free
|
||||
%{_sbindir}/zfcp_cio_free
|
||||
%{_sbindir}/znet_cio_free
|
||||
%{_unitdir}/device_cio_free.service
|
||||
/usr/lib/udev/ccw_init
|
||||
%{_udevrulesdir}/40-z90crypt.rules
|
||||
%{_udevrulesdir}/56-dasd.rules
|
||||
%{_udevrulesdir}/56-zfcp.rules
|
||||
%{_udevrulesdir}/59-dasd.rules
|
||||
%{_udevrulesdir}/59-virtio-blk.rules
|
||||
%{_udevrulesdir}/60-readahead.rules
|
||||
%{_udevrulesdir}/81-ccw.rules
|
||||
%{_udevrulesdir}/81-dpm.rules
|
||||
%{_udevrulesdir}/90-cpi.rules
|
||||
# rule provided by systemd-udev
|
||||
%exclude %{_udevrulesdir}/80-hotplug-cpu.rules
|
||||
%{_sysconfdir}/kernel/install.d/20-grubby.install
|
||||
%{_prefix}/lib/kernel/install.d/10-zfcpdump.install
|
||||
%{_prefix}/lib/kernel/install.d/20-zipl-kernel.install
|
||||
%{_prefix}/lib/kernel/install.d/52-zipl-rescue.install
|
||||
%{_prefix}/lib/kernel/install.d/91-zipl.install
|
||||
%{_prefix}/lib/modules-load.d/s390-pkey.conf
|
||||
|
||||
#
|
||||
# *********************** s390-tools base package ***********************
|
||||
|
||||
47
zfcpconfmigrate.sh
Normal file
47
zfcpconfmigrate.sh
Normal file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright IBM Corp. 2023
|
||||
|
||||
# This is just a wrapper to migrate old /etc/zfcp.conf to the new
|
||||
# consolidated persistent configuration of s390 devices with chzdev.
|
||||
|
||||
CONFIG=/etc/zfcp.conf
|
||||
PATH=/bin:/sbin
|
||||
|
||||
DATE=$(date --iso-8601=seconds)
|
||||
PREFIX="${CONFIG}.${DATE}.migrated-to-chzdev"
|
||||
|
||||
if [ -f "$CONFIG" ]; then
|
||||
# show migration output to users and log it into file
|
||||
exec > >(tee "${PREFIX}.log") 2>&1
|
||||
sed 'y/ABCDEF/abcdef/' < $CONFIG | while read -r line; do
|
||||
case $line in
|
||||
\#*) ;;
|
||||
*)
|
||||
[ -z "$line" ] && continue
|
||||
# shellcheck disable=SC2086
|
||||
set -- $line
|
||||
if [ $# -eq 1 ]; then
|
||||
DEVICE=${1##*0x}
|
||||
chzdev --enable --persistent zfcp-host "$DEVICE" --yes --no-root-update --force --no-settle
|
||||
continue
|
||||
fi
|
||||
if [ $# -eq 5 ]; then
|
||||
DEVICE=$1
|
||||
#SCSIID=$2
|
||||
WWPN=$3
|
||||
#SCSILUN=$4
|
||||
FCPLUN=$5
|
||||
elif [ $# -eq 3 ]; then
|
||||
DEVICE=${1##*0x}
|
||||
WWPN=$2
|
||||
FCPLUN=$3
|
||||
fi
|
||||
chzdev --enable --persistent zfcp-lun "$DEVICE:$WWPN:$FCPLUN" --yes --no-root-update --force --no-settle
|
||||
;;
|
||||
esac
|
||||
done
|
||||
mv "$CONFIG" "$PREFIX"
|
||||
echo "zfcpconfmigrate.sh: Information: Your persistent zfcp device configuration file $CONFIG was migrated to the new consolidated mechanism. From now on, please use lszdev and chzdev from s390utils instead. To finally complete the migration, please run: kdumpctl rebuild; systemctl restart kdump; dracut -f; zipl"
|
||||
fi
|
||||
103
znetconfmigrate.sh
Normal file
103
znetconfmigrate.sh
Normal file
@ -0,0 +1,103 @@
|
||||
#! /bin/bash
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Largely based on the old ccw_init script.
|
||||
|
||||
# This is just a wrapper to migrate old s390 channel-attached network
|
||||
# device config to the new consolidated persistent configuration with
|
||||
# chzdev.
|
||||
|
||||
DATE=$(date --iso-8601=seconds)
|
||||
|
||||
# borrowed from network-scrips, initscripts along with the get_config_by_subchannel
|
||||
[ -z "$__sed_discard_ignored_files" ] && __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
|
||||
|
||||
get_configs ()
|
||||
{
|
||||
LANG=C grep -E -i -l \
|
||||
"^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+)(,[0-9]\.[0-9]\.[a-f0-9]+){1,2}['\"]?([[:space:]]+#|[[:space:]]*$)" \
|
||||
/etc/sysconfig/network-scripts/ifcfg-* \
|
||||
| LC_ALL=C sed -e "$__sed_discard_ignored_files"
|
||||
}
|
||||
|
||||
get_configs_nm ()
|
||||
{
|
||||
LANG=C grep -E -i -l \
|
||||
"^s390-subchannels=([0-9]\.[0-9]\.[a-f0-9]+;){2,3}$" \
|
||||
/etc/NetworkManager/system-connections/*.nmconnection \
|
||||
| LC_ALL=C sed -e "$__sed_discard_ignored_files"
|
||||
}
|
||||
|
||||
migrate ()
|
||||
{
|
||||
# translate variables from the interface config files to OPTIONS
|
||||
if [ -n "$PORTNAME" ]; then
|
||||
if [ "$NETTYPE" = "lcs" ]; then
|
||||
OPTIONS="$OPTIONS portno=$PORTNAME"
|
||||
else
|
||||
OPTIONS="$OPTIONS portname=$PORTNAME"
|
||||
fi
|
||||
fi
|
||||
if [ "$NETTYPE" = "ctc" -a -n "$CTCPROT" ]; then
|
||||
OPTIONS="$OPTIONS protocol=$CTCPROT"
|
||||
fi
|
||||
|
||||
# SUBCHANNELS is only set on mainframe ccwgroup devices
|
||||
[ -z "$SUBCHANNELS" -o -z "$NETTYPE" ] && return
|
||||
|
||||
SUBCHANNELS=$(echo "$SUBCHANNELS" | tr ',' ':')
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
chzdev --enable --persistent "$NETTYPE" "$SUBCHANNELS" $OPTIONS --yes --no-root-update --force --no-settle
|
||||
|
||||
# Leave all s390-specifics in original $CONFIG_FILE because NetworkManager
|
||||
# does something with NETTYPE, PORTNAME, CTCPROT, OPTIONS.
|
||||
# Definitively Leave SUBCHANNELS as it might serve as interface identifier key,
|
||||
# which is not HWADDR.
|
||||
|
||||
echo "znetconfmigrate.sh: Information: Your low-level persistent s390 network device configuration $CONFIG_FILE was migrated to the new consolidated mechanism. From now on, please use lszdev and chzdev from s390utils instead. To finally complete the migration, please run: kdumpctl rebuild; systemctl restart kdump; dracut -f; zipl"
|
||||
|
||||
# re-initialize global variables before next possible iteration loop
|
||||
NETTYPE=""
|
||||
SUBCHANNELS=""
|
||||
OPTIONS=""
|
||||
PORTNAME=""
|
||||
CTCPROT=""
|
||||
}
|
||||
|
||||
NOLOCALE="yes"
|
||||
|
||||
CONFIG_FILES=$(get_configs)
|
||||
if [ -n "$CONFIG_FILES" ]; then
|
||||
for CONFIG_FILE in $CONFIG_FILES; do
|
||||
PREFIX="znet.${CONFIG_FILE##*/}.${DATE}.migrated-to-chzdev"
|
||||
# show migration output to users and log it into file
|
||||
exec > >(tee "$PREFIX.log") 2>&1
|
||||
. "$CONFIG_FILE"
|
||||
migrate
|
||||
done
|
||||
else
|
||||
CONFIG_FILES=$(get_configs_nm)
|
||||
for CONFIG_FILE in $CONFIG_FILES; do
|
||||
PREFIX="znet.${CONFIG_FILE##*/}.${DATE}.migrated-to-chzdev"
|
||||
# show migration output to users and log it into file
|
||||
exec > >(tee "$PREFIX.log") 2>&1
|
||||
NETTYPE=$(sed -nr "/^\[ethernet\]/ { :l /^s390-nettype[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" "$CONFIG_FILE")
|
||||
SUBCHANNELS=$(sed -nr "/^\[ethernet\]/ { :l /^s390-subchannels[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" "$CONFIG_FILE" | sed -e "s/;/,/g" -e "s/,$//")
|
||||
OPTIONS=$(sed -nr "
|
||||
/^\[ethernet-s390-options\]/ {
|
||||
n # skip matched line with beginning of section
|
||||
:l # set label
|
||||
/^[^#].*=.*/ { # match non-comment key value line
|
||||
p # print
|
||||
}
|
||||
/^[ ]*\[/ { # match beginning of next section
|
||||
q # quit
|
||||
}
|
||||
n # next
|
||||
b l # branch to label
|
||||
}
|
||||
" "$CONFIG_FILE")
|
||||
migrate
|
||||
done
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user