refs #273 adds a function to changes kea parameters to use ipxe scripts and delete some comments
parent
17286940e4
commit
7fa8a60421
|
@ -35,23 +35,26 @@ function add_tftpboot_files() {
|
||||||
src_dir="tftpboot"
|
src_dir="tftpboot"
|
||||||
dest_dir="/opt/opengnsys/tftpboot"
|
dest_dir="/opt/opengnsys/tftpboot"
|
||||||
|
|
||||||
# Crear el directorio de destino si no existe
|
|
||||||
mkdir -p "$dest_dir"
|
mkdir -p "$dest_dir"
|
||||||
|
|
||||||
# Copiar los archivos sin sobrescribir los existentes
|
|
||||||
cp -rn "$src_dir/." "$dest_dir/"
|
cp -rn "$src_dir/." "$dest_dir/"
|
||||||
|
|
||||||
# Comprobar si la copia fue exitosa
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Los archivos se añadieron con éxito."
|
echo "Los archivos se añadieron con éxito."
|
||||||
else
|
else
|
||||||
echo "Hubo un error al añadir los archivos."
|
echo "Hubo un error al añadir los archivos."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Volver al directorio original
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
replace_in_config_kea() {
|
||||||
|
local config_file="/etc/kea/kea-dhcp4.conf"
|
||||||
|
|
||||||
|
sed -i 's/"boot-file-name": "shimx64.efi.signed"/"boot-file-name": "ipxe.efi"/g' "$config_file"
|
||||||
|
sed -i 's/"boot-file-name": "grldr"/"boot-file-name": "undionly.kpxe"/g' "$config_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
generate_ipxe_script() {
|
generate_ipxe_script() {
|
||||||
|
|
||||||
echo "Generando script IPXE..."
|
echo "Generando script IPXE..."
|
||||||
|
@ -60,7 +63,6 @@ generate_ipxe_script() {
|
||||||
|
|
||||||
ipxe_output="/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
|
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_server/g" "$template" > "$ipxe_output"
|
sed "s/SERVERIP/$ip_address_server/g" "$template" > "$ipxe_output"
|
||||||
|
|
||||||
template_default="tftpboot/ipxe_scripts/default.ipxe"
|
template_default="tftpboot/ipxe_scripts/default.ipxe"
|
||||||
|
@ -72,7 +74,6 @@ generate_ipxe_script() {
|
||||||
sed "s/SERVERIP/$ip_address_server/g" "$template_default" > "$default_output"
|
sed "s/SERVERIP/$ip_address_server/g" "$template_default" > "$default_output"
|
||||||
echo "Creando ficheros MAC script"
|
echo "Creando ficheros MAC script"
|
||||||
for client_declaration in "${CLIENTS[@]}"; do
|
for client_declaration in "${CLIENTS[@]}"; do
|
||||||
# Evaluar la cadena para reconstruir el array asociativo del cliente
|
|
||||||
eval "$client_declaration"
|
eval "$client_declaration"
|
||||||
|
|
||||||
hostname="${CLIENT[hostname]}"
|
hostname="${CLIENT[hostname]}"
|
||||||
|
@ -92,7 +93,6 @@ generate_ipxe_script() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Definir la función
|
|
||||||
mount_NFS() {
|
mount_NFS() {
|
||||||
if sudo mount -t nfs ognartefactos.evlt.uma.es:/ /mnt; then
|
if sudo mount -t nfs ognartefactos.evlt.uma.es:/ /mnt; then
|
||||||
echo "Sistema NFS montado correctamente."
|
echo "Sistema NFS montado correctamente."
|
||||||
|
@ -146,6 +146,14 @@ if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
replace_in_config_kea
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error en la sustitución de valores en el archivo de configuración de KEA DHCP"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
generate_ipxe_script
|
generate_ipxe_script
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error en la generación de scripts IPXE"
|
echo "Error en la generación de scripts IPXE"
|
||||||
|
|
Loading…
Reference in New Issue