Remove a defined class

Markus Rexhepi-Lindberg Markus.Rexhepi-Lindberg at axis.com
Fri Dec 11 09:32:47 CET 2020


> > Is it possible to remove a defined class during a install?
> Uuuuh. It may be possible but in 2006 we already had this questions
> https://lists.uni-koeln.de/pipermail/linux-fai/2006-November/004613.html

Thanks, I did not manage to find that thread.

> The clean way would be to write a hook with suffix .sh (then it is
> sourced). This hook must remove the class from $LOGDIR/FAI_CLASSES and
> also redefine the shell variable $classes. We use this command in FAI
> for setting $classes
> classes=$(< $LOGDIR/FAI_CLASSES)

This worked out well. I now use the following hook to append _EFI to a
disk class which was defined during task_defclass. My disk classes
always start with HD_ and a BIOS and EFI version of them exists were
the EFI version always ends with _EFI (which makes it scriptable in
this case).

  #!/bin/sh
  
  sFaiClassFile="FAI_CLASSES"
  sInitDiskClass="$(grep -E "^HD_" ${LOGDIR}/${sFaiClassFile})"
  
  # Check if a EFI based disk class has already been defined, if so exit.
  if (echo "${sInitDiskClass}" | grep -qE "^HD_.*_EFI$"); then
    exit 0
  fi
  
  
  if [ -e "${FAI}/disk_config/${sInitDiskClass}_EFI" ]; then
    # Remove inital disk class.
    sed -i '/^HD_/d' ${LOGDIR}/${sFaiClassFile}
    # Redefine inital disk class and append _EFI to it.
    echo "${sInitDiskClass}_EFI" >> ${LOGDIR}/${sFaiClassFile}
    # Redefine the classes variable.
    classes=$(< ${LOGDIR}/${sFaiClassFile})
  else
    echo "A '${sInitDiskClass}_EFI' disk_config was not found. Falling back to initial disk_config '${sInitDiskClass}'."
    exit 0
  fi

--
Markus


More information about the linux-fai mailing list