refs #273 adds SERVER IP variable to the template

ipxe-study
Luis Gerardo Romero Garcia 2024-04-30 13:34:08 +02:00
parent 766c113fbb
commit 17286940e4
1 changed files with 4 additions and 5 deletions

View File

@ -55,13 +55,13 @@ function add_tftpboot_files() {
generate_ipxe_script() {
echo "Generando script IPXE..."
ip_address=$(ifconfig eth0 | awk '/inet / {print $2}')
ip_address_server=$(ifconfig eth0 | awk '/inet / {print $2}')
template="etc/dhcp_boot.ipxe.tmpl"
ipxe_output="/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
# Reemplazar SERVERIP con la dirección IP en la plantilla y guardarla en el archivo de salida
sed "s/SERVERIP/$ip_address/g" "$template" > "$ipxe_output"
sed "s/SERVERIP/$ip_address_server/g" "$template" > "$ipxe_output"
template_default="tftpboot/ipxe_scripts/default.ipxe"
@ -69,7 +69,7 @@ generate_ipxe_script() {
mac_script_template="etc/mac_script.ipxe.tmpl"
sed "s/SERVERIP/$ip_address/g" "$template_default" > "$default_output"
sed "s/SERVERIP/$ip_address_server/g" "$template_default" > "$default_output"
echo "Creando ficheros MAC script"
for client_declaration in "${CLIENTS[@]}"; do
# Evaluar la cadena para reconstruir el array asociativo del cliente
@ -80,8 +80,7 @@ generate_ipxe_script() {
ip_address="${CLIENT[ip_address]}"
mac_address_lower=$(echo "$mac_address" | tr '[:upper:]' '[:lower:]')
filename="01-${mac_address_lower}"
sed "s/IP_ADDRESS/$ip_address/g; s/HOSTNAME/$hostname/g; s/MAC_ADDRESS/$mac_address/g" $mac_script_template > "/opt/opengnsys/tftpboot/ipxe_scripts/$filename"
sed "s/SERVERIP/$ip_address_server/g; s/IP_ADDRESS/$ip_address/g; s/HOSTNAME/$hostname/g; s/MAC_ADDRESS/$mac_address/g" $mac_script_template > "/opt/opengnsys/tftpboot/ipxe_scripts/$filename"
echo "Archivo $filename creado con los parámetros modificados."
done