anaconda/anaconda-40.22.3.13/dracut/anaconda-ks-sendheaders.sh

34 lines
1.1 KiB
Bash
Raw Normal View History

2024-11-14 21:39:56 -08:00
#!/bin/sh
# anaconda-ks-sendheaders.sh - set various HTTP headers for kickstarting
[ -f /tmp/.ks_sendheaders ] && return
command -v set_http_header >/dev/null || . /lib/url-lib.sh
# inst.ks.sendmac: send MAC addresses in HTTP headers
if getargbool 0 inst.ks.sendmac; then
ifnum=0
for ifname in /sys/class/net/*; do
[ -e "$ifname/address" ] || continue
mac=$(cat "$ifname/address")
ifname=${ifname#/sys/class/net/}
# TODO: might need to choose devices better
if [ "$ifname" != "lo" ] && [ -n "$mac" ]; then
# set_http_header is from url-lib.sh, sourced earlier
set_http_header "X-RHN-Provisioning-MAC-$ifnum" "$ifname $mac"
ifnum=$((ifnum+1))
fi
done
fi
# inst.ks.sendsn: send system serial number in HTTP headers
if getargbool 0 inst.ks.sendsn; then
system_serial=$(cat /sys/class/dmi/id/product_serial 2>/dev/null)
if [ -z "$system_serial" ]; then
warn "inst.ks.sendsn: can't find system serial number"
else
set_http_header "X-System-Serial-Number" "$system_serial"
fi
fi
true > /tmp/.ks_sendheaders