Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../lib/dracut/modules..../45ifcfg
File: write-ifcfg.sh
#!/bin/sh
[0] Fix | Delete
[1] Fix | Delete
# NFS root might have reached here before /tmp/net.ifaces was written
[2] Fix | Delete
type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
[3] Fix | Delete
[4] Fix | Delete
udevadm settle --timeout=30
[5] Fix | Delete
[6] Fix | Delete
mkdir -m 0755 -p /tmp/ifcfg/
[7] Fix | Delete
mkdir -m 0755 -p /tmp/ifcfg-leases/
[8] Fix | Delete
[9] Fix | Delete
get_config_line_by_subchannel()
[10] Fix | Delete
{
[11] Fix | Delete
local CHANNEL
[12] Fix | Delete
local line
[13] Fix | Delete
[14] Fix | Delete
CHANNELS="$1"
[15] Fix | Delete
while read line || [ -n "$line" ]; do
[16] Fix | Delete
if strstr "$line" "$CHANNELS"; then
[17] Fix | Delete
echo $line
[18] Fix | Delete
return 0
[19] Fix | Delete
fi
[20] Fix | Delete
done < /etc/ccw.conf
[21] Fix | Delete
return 1
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
print_s390() {
[25] Fix | Delete
local _netif
[26] Fix | Delete
local SUBCHANNELS
[27] Fix | Delete
local OPTIONS
[28] Fix | Delete
local NETTYPE
[29] Fix | Delete
local CONFIG_LINE
[30] Fix | Delete
local i
[31] Fix | Delete
local channel
[32] Fix | Delete
local OLD_IFS
[33] Fix | Delete
[34] Fix | Delete
_netif="$1"
[35] Fix | Delete
# if we find ccw channel, then use those, instead of
[36] Fix | Delete
# of the MAC
[37] Fix | Delete
SUBCHANNELS=$({
[38] Fix | Delete
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
[39] Fix | Delete
[ -e $i ] || continue
[40] Fix | Delete
channel=$(readlink -f $i)
[41] Fix | Delete
printf '%s' "${channel##*/},"
[42] Fix | Delete
done
[43] Fix | Delete
})
[44] Fix | Delete
[ -n "$SUBCHANNELS" ] || return 1
[45] Fix | Delete
[46] Fix | Delete
SUBCHANNELS=${SUBCHANNELS%,}
[47] Fix | Delete
echo "SUBCHANNELS=\"${SUBCHANNELS}\""
[48] Fix | Delete
[49] Fix | Delete
CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
[50] Fix | Delete
[ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0
[51] Fix | Delete
[52] Fix | Delete
OLD_IFS=$IFS
[53] Fix | Delete
IFS=","
[54] Fix | Delete
set -- $CONFIG_LINE
[55] Fix | Delete
IFS=$OLD_IFS
[56] Fix | Delete
NETTYPE=$1
[57] Fix | Delete
shift
[58] Fix | Delete
SUBCHANNELS="$1"
[59] Fix | Delete
OPTIONS=""
[60] Fix | Delete
shift
[61] Fix | Delete
while [ $# -gt 0 ]; do
[62] Fix | Delete
case $1 in
[63] Fix | Delete
*=*) OPTIONS="$OPTIONS $1";;
[64] Fix | Delete
esac
[65] Fix | Delete
shift
[66] Fix | Delete
done
[67] Fix | Delete
OPTIONS=${OPTIONS## }
[68] Fix | Delete
echo "NETTYPE=\"${NETTYPE}\""
[69] Fix | Delete
echo "OPTIONS=\"${OPTIONS}\""
[70] Fix | Delete
return 0
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
hw_bind() {
[74] Fix | Delete
local _netif="$1"
[75] Fix | Delete
local _macaddr="$2"
[76] Fix | Delete
[77] Fix | Delete
[ -n "$_macaddr" ] \
[78] Fix | Delete
&& echo "MACADDR=\"$_macaddr\""
[79] Fix | Delete
[80] Fix | Delete
print_s390 "$_netif" \
[81] Fix | Delete
&& return 0
[82] Fix | Delete
[83] Fix | Delete
[ -n "$_macaddr" ] && return 0
[84] Fix | Delete
[85] Fix | Delete
is_persistent_ethernet_name "$_netif" && return 0
[86] Fix | Delete
[87] Fix | Delete
[ -f "/sys/class/net/$_netif/addr_assign_type" ] \
[88] Fix | Delete
&& [ "$(cat "/sys/class/net/$_netif/addr_assign_type")" != "0" ] \
[89] Fix | Delete
&& return 1
[90] Fix | Delete
[91] Fix | Delete
[ -f "/sys/class/net/$_netif/address" ] \
[92] Fix | Delete
|| return 1
[93] Fix | Delete
[94] Fix | Delete
echo "HWADDR=\"$(cat /sys/class/net/$_netif/address)\""
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
interface_bind() {
[98] Fix | Delete
local _netif="$1"
[99] Fix | Delete
local _macaddr="$2"
[100] Fix | Delete
[101] Fix | Delete
if [ ! -e "/sys/class/net/$_netif" ]; then
[102] Fix | Delete
derror "Cannot find network interface '$_netif'!"
[103] Fix | Delete
return 1
[104] Fix | Delete
fi
[105] Fix | Delete
[106] Fix | Delete
# see, if we can bind it to some hw parms
[107] Fix | Delete
if hw_bind "$_netif" "$_macaddr"; then
[108] Fix | Delete
# only print out DEVICE, if it's user assigned
[109] Fix | Delete
is_kernel_ethernet_name "$_netif" && return 0
[110] Fix | Delete
fi
[111] Fix | Delete
[112] Fix | Delete
echo "DEVICE=\"$_netif\""
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
for netup in /tmp/net.*.did-setup ; do
[116] Fix | Delete
[ -f $netup ] || continue
[117] Fix | Delete
[118] Fix | Delete
netif=${netup%%.did-setup}
[119] Fix | Delete
netif=${netif##*/net.}
[120] Fix | Delete
strglobin "$netif" ":*:*:*:*:" && continue
[121] Fix | Delete
[ -e /tmp/ifcfg/ifcfg-$netif ] && continue
[122] Fix | Delete
unset bridge
[123] Fix | Delete
unset bond
[124] Fix | Delete
unset bondslaves
[125] Fix | Delete
unset bondname
[126] Fix | Delete
unset bondoptions
[127] Fix | Delete
unset bridgename
[128] Fix | Delete
unset bridgeslaves
[129] Fix | Delete
unset team
[130] Fix | Delete
unset uuid
[131] Fix | Delete
unset ip
[132] Fix | Delete
unset gw
[133] Fix | Delete
unset mtu
[134] Fix | Delete
unset mask
[135] Fix | Delete
unset macaddr
[136] Fix | Delete
unset slave
[137] Fix | Delete
unset ethname
[138] Fix | Delete
unset vlan
[139] Fix | Delete
unset vlanname
[140] Fix | Delete
unset phydevice
[141] Fix | Delete
[142] Fix | Delete
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
[143] Fix | Delete
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
[144] Fix | Delete
[ -e /tmp/team.${netif}.info ] && . /tmp/team.${netif}.info
[145] Fix | Delete
[146] Fix | Delete
uuid=$(cat /proc/sys/kernel/random/uuid)
[147] Fix | Delete
if [ "$netif" = "$bridgename" ]; then
[148] Fix | Delete
bridge=yes
[149] Fix | Delete
elif [ "$netif" = "$teammaster" ]; then
[150] Fix | Delete
team=yes
[151] Fix | Delete
elif [ "$netif" = "$bondname" ]; then
[152] Fix | Delete
# $netif can't be bridge and bond at the same time
[153] Fix | Delete
bond=yes
[154] Fix | Delete
fi
[155] Fix | Delete
[156] Fix | Delete
for i in /tmp/vlan.${netif}.*; do
[157] Fix | Delete
[ ! -e "$i" ] && continue
[158] Fix | Delete
. "$i"
[159] Fix | Delete
vlan=yes
[160] Fix | Delete
break
[161] Fix | Delete
done
[162] Fix | Delete
[163] Fix | Delete
# skip team interfaces for now, the host config must be in sync
[164] Fix | Delete
[ "$netif" = "$teammaster" ] && continue
[165] Fix | Delete
[166] Fix | Delete
{
[167] Fix | Delete
echo "# Generated by dracut initrd"
[168] Fix | Delete
echo "NAME=\"$netif\""
[169] Fix | Delete
[ -z "$vlan" ] && interface_bind "$netif" "$macaddr"
[170] Fix | Delete
echo "ONBOOT=yes"
[171] Fix | Delete
echo "NETBOOT=yes"
[172] Fix | Delete
echo "UUID=\"$uuid\""
[173] Fix | Delete
strstr "$(ip -6 addr show dev $netif)" 'inet6' && echo "IPV6INIT=yes"
[174] Fix | Delete
if [ -f /tmp/dhclient.$netif.lease ]; then
[175] Fix | Delete
[ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
[176] Fix | Delete
if [ -f /tmp/net.$netif.has_ibft_config ]; then
[177] Fix | Delete
echo "BOOTPROTO=ibft"
[178] Fix | Delete
else
[179] Fix | Delete
echo "BOOTPROTO=dhcp"
[180] Fix | Delete
fi
[181] Fix | Delete
cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
[182] Fix | Delete
else
[183] Fix | Delete
# If we've booted with static ip= lines, the override file is there
[184] Fix | Delete
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
[185] Fix | Delete
if strglobin "$ip" '*:*:*'; then
[186] Fix | Delete
echo "IPV6INIT=yes"
[187] Fix | Delete
echo "IPV6_AUTOCONF=no"
[188] Fix | Delete
echo "IPV6ADDR=\"$ip/$mask\""
[189] Fix | Delete
else
[190] Fix | Delete
if [ -f /tmp/net.$netif.has_ibft_config ]; then
[191] Fix | Delete
echo "BOOTPROTO=ibft"
[192] Fix | Delete
else
[193] Fix | Delete
echo "BOOTPROTO=none"
[194] Fix | Delete
echo "IPADDR=\"$ip\""
[195] Fix | Delete
if strstr "$mask" "."; then
[196] Fix | Delete
echo "NETMASK=\"$mask\""
[197] Fix | Delete
else
[198] Fix | Delete
echo "PREFIX=\"$mask\""
[199] Fix | Delete
fi
[200] Fix | Delete
fi
[201] Fix | Delete
fi
[202] Fix | Delete
if strglobin "$gw" '*:*:*'; then
[203] Fix | Delete
echo "IPV6_DEFAULTGW=\"$gw\""
[204] Fix | Delete
elif [ -n "$gw" ]; then
[205] Fix | Delete
echo "GATEWAY=\"$gw\""
[206] Fix | Delete
fi
[207] Fix | Delete
fi
[208] Fix | Delete
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
[209] Fix | Delete
} > /tmp/ifcfg/ifcfg-$netif
[210] Fix | Delete
[211] Fix | Delete
# bridge needs different things written to ifcfg
[212] Fix | Delete
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
[213] Fix | Delete
# standard interface
[214] Fix | Delete
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
[215] Fix | Delete
fi
[216] Fix | Delete
[217] Fix | Delete
if [ -n "$vlan" ] ; then
[218] Fix | Delete
{
[219] Fix | Delete
echo "TYPE=Vlan"
[220] Fix | Delete
echo "DEVICE=\"$netif\""
[221] Fix | Delete
echo "VLAN=yes"
[222] Fix | Delete
echo "PHYSDEV=\"$phydevice\""
[223] Fix | Delete
} >> /tmp/ifcfg/ifcfg-$netif
[224] Fix | Delete
fi
[225] Fix | Delete
[226] Fix | Delete
if [ -n "$bond" ] ; then
[227] Fix | Delete
# bond interface
[228] Fix | Delete
{
[229] Fix | Delete
# This variable is an indicator of a bond interface for initscripts
[230] Fix | Delete
echo "BONDING_OPTS=\"$bondoptions\""
[231] Fix | Delete
echo "NAME=\"$netif\""
[232] Fix | Delete
echo "TYPE=Bond"
[233] Fix | Delete
} >> /tmp/ifcfg/ifcfg-$netif
[234] Fix | Delete
[235] Fix | Delete
for slave in $bondslaves ; do
[236] Fix | Delete
# write separate ifcfg file for the raw eth interface
[237] Fix | Delete
(
[238] Fix | Delete
echo "# Generated by dracut initrd"
[239] Fix | Delete
echo "NAME=\"$slave\""
[240] Fix | Delete
echo "TYPE=Ethernet"
[241] Fix | Delete
echo "ONBOOT=yes"
[242] Fix | Delete
echo "NETBOOT=yes"
[243] Fix | Delete
echo "SLAVE=yes"
[244] Fix | Delete
echo "MASTER=\"$netif\""
[245] Fix | Delete
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
[246] Fix | Delete
unset macaddr
[247] Fix | Delete
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[248] Fix | Delete
interface_bind "$slave" "$macaddr"
[249] Fix | Delete
) >> /tmp/ifcfg/ifcfg-$slave
[250] Fix | Delete
done
[251] Fix | Delete
fi
[252] Fix | Delete
[253] Fix | Delete
if [ -n "$bridge" ] ; then
[254] Fix | Delete
# bridge
[255] Fix | Delete
{
[256] Fix | Delete
echo "TYPE=Bridge"
[257] Fix | Delete
echo "NAME=\"$netif\""
[258] Fix | Delete
} >> /tmp/ifcfg/ifcfg-$netif
[259] Fix | Delete
for slave in $bridgeslaves ; do
[260] Fix | Delete
# write separate ifcfg file for the raw eth interface
[261] Fix | Delete
(
[262] Fix | Delete
echo "# Generated by dracut initrd"
[263] Fix | Delete
echo "NAME=\"$slave\""
[264] Fix | Delete
echo "TYPE=Ethernet"
[265] Fix | Delete
echo "ONBOOT=yes"
[266] Fix | Delete
echo "NETBOOT=yes"
[267] Fix | Delete
echo "BRIDGE=\"$bridgename\""
[268] Fix | Delete
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
[269] Fix | Delete
unset macaddr
[270] Fix | Delete
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[271] Fix | Delete
interface_bind "$slave" "$macaddr"
[272] Fix | Delete
) >> /tmp/ifcfg/ifcfg-$slave
[273] Fix | Delete
done
[274] Fix | Delete
fi
[275] Fix | Delete
i=1
[276] Fix | Delete
for ns in $(getargs nameserver) $dns1 $dns2; do
[277] Fix | Delete
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
[278] Fix | Delete
i=$((i+1))
[279] Fix | Delete
done
[280] Fix | Delete
[281] Fix | Delete
[ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
[282] Fix | Delete
[ -f /tmp/net.route."$netif" ] && cp /tmp/net.route."$netif" /tmp/ifcfg/route-"$netif"
[283] Fix | Delete
done
[284] Fix | Delete
[285] Fix | Delete
# Pass network opts
[286] Fix | Delete
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
[287] Fix | Delete
mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
[288] Fix | Delete
echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
[289] Fix | Delete
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
[290] Fix | Delete
{
[291] Fix | Delete
cp /tmp/net.* /run/initramfs/
[292] Fix | Delete
for i in /tmp/net.*.resolv.conf; do
[293] Fix | Delete
[ -f "$i" ] && cat "$i"
[294] Fix | Delete
done | sort -u > /run/initramfs/state/etc/resolv.conf
[295] Fix | Delete
[ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
[296] Fix | Delete
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
[297] Fix | Delete
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
[298] Fix | Delete
} > /dev/null 2>&1
[299] Fix | Delete
[300] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function