2024-11-27 06:19:41 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Do network related script patches
|
2024-11-28 00:39:37 +08:00
|
|
|
# First parameter is the root mount point of the new LFS system
|
|
|
|
# Second parameter is the user requested BLFS packages
|
2024-11-27 06:19:41 +08:00
|
|
|
_patch_network_scripts()
|
|
|
|
{
|
|
|
|
# Patch network script
|
|
|
|
local dir_commands="$1/jhalfs/lfs-commands"
|
2024-11-27 08:47:00 +08:00
|
|
|
local net_script=$(find "$dir_commands" -type f -iname "*-network")
|
2024-11-27 06:19:41 +08:00
|
|
|
if [ ! -f "$net_script" ] ; then
|
|
|
|
echo "Failed to find the network script file." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
sed -i "s/-static/0/g" "$net_script" &&
|
|
|
|
sed -i "/^\(Gateway\)\|\(Address\)\|\(DNS\)\|\(Domains\)=/d" "$net_script" &&
|
|
|
|
sed -i "/^\[Network\]/a DHCP=yes" "$net_script" &&
|
|
|
|
sed -i "s/^.*PKR-LINUX.local/127.0.0.1 PKR-LINUX.local/" "$net_script"
|
|
|
|
if [[ $? -gt 0 ]] ; then
|
|
|
|
echo "Failed to patch network script." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if wpa_supplicant is required and patch its install script if yes
|
|
|
|
if [[ $2 == *"wpa_supplicant"* ]] ; then
|
|
|
|
sed -i "/^cat > \/etc\/systemd\/network/i cat > /etc/systemd/network/20-wlan0.network << \"EOF\"\n\[Match\]\nName=wlan0\n\n\[Network\]\nDHCP=yes\nEOF" "$net_script" &&
|
2024-12-24 01:37:46 +08:00
|
|
|
sed -i "/20-wlan0.network/i mkdir -pv /etc/wpa_supplicant\ncat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf << \"EOF\"\nnetwork=\{\nssid=\"Telekom-737166_5Ghz\"\n#psk=\"teuf95a2e2fb\"\npsk=c8bac18b5379c7c80f01daad882e978c7a803b5404a69705b977552640608863\n\}\nEOF" "$net_script" &&
|
2024-11-27 06:19:41 +08:00
|
|
|
sed -i "/wpa_supplicant@/s/@.*/@wlan0/" "$(find "$1/blfs_root/scripts/" -type f -iname "*-wpa_supplicant")"
|
|
|
|
if [[ $? -gt 0 ]] ; then
|
|
|
|
echo "Failed to patch wpa_supplicant script." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|